Hey everyone, do you have any info/tips or techniques on manipulating palettes like in old 8/16 bit consoles or pico8? Looking for a way to do palette cycling and swapping mainly and working with a limited set of colors.
First option is to read png from resources using imageloader extension, then manipulate it’s buffer to switch colors and apply such edited texture to a model or sprite.
Another option is to write a shader that would change colors on the GPU.
If we could pass arrays to shaders instead of only vectors doing this kind of thing would be way easier. I think that’s coming… eventually…
Better shader support the biggest thing I envy Unity. (Then it’s dynamic content generation and more supported platforms)
For sure… but Defold is still better… once it has those things it will be the… King.
Heh. I see what you did there.
Yeah it’s a bit annoying that uniform setting is so limited. We have an exploration day tomorrow so I might take a look at it. I was planning to look at setting a matrix as uniform as well.
Whoa, whoa, here is a list of things I will be grateful if you take a look at: matrix uniform, gl_VertexID, tangent info from model, array uniform. Thanks!
gl_VertexID is a bit tricky since it requires an es3 context unless you do it with vertex attributes or something similar (until we finish the Vulkan support which has this by default).
So I explored the array uniform setting and user matrix constants. I can do something like:
// In shader uniform vec4 tint; // In main.script sprite.set_constant("#sprite", "tint", vmath.vector4(1,0,0,1)) sprite.set_constant("#sprite", "tint", vmath.vector4(0,1,0,1))
Also, this works:
// In shader.vp uniform mat4 my_matrix; uniform mat4 my_matrix_array; // In main script sprite.set_constant("#sprite", "my_matrix, vmath.matrix4(...)) sprite.set_constant("#sprite", "my_matrix_array", vmath.matrix4(...)) sprite.set_constant("#sprite", "my_matrix_array", vmath.matrix4(...))
This should also work, but haven’t tested it:
// Shader uniform mat4 my_matrix; uniform mat4 my_matrix_array[MATRIX_COUNT]; uniform vec4 my_vector_array[ARRAY_COUNT]; // Script go.set("my_matrix", vmath.matrix4(...)) go.set("my_matrix_array", vmath.matrix4(...)) go.set("my_vector_array", vmath.vector4(...))
… but as always, not sure if/when/how this can be added, I think it needs a proper design discussion first at least since it kinda requires a big change in our engine structures.
Excited! For arrays can’t we use tables in go.set()? And automatically shift indexes under the hood.
Maybe, but I don’t know how well that would mesh with our current property representation, I wouldn’t want to add too much complexity just to add functionality that you can wrap in a small function. But I’ll formalize this into a design and we’ll see