![]() ![]() ![]() In the loop I iterate from 0 up to the x textureSize: for(float x = 0.0 x <= pal_size x += pixel_size). I am not sure about the number that comes out of textureSize(base_palette, 0).I'm also a bit lazy but that's unimportant deleted 4 yr. The palette should be a n x 1 sprite, where n is the amount of palettes x 3. Oh, and two things: - Place the 'Draw End' code in a global, persistent object. I am happy with the end result (It works!), but I am not totally comfortable with using a loop to look for the base color for EVERY pixel of the sprite. Just change the palette sprite name, window size,etc.Then I read the color from the new_palette that is in the same pixel position. To be able to find the replacement color, for every pixel, I search the original color with a custom function called find_color_in_base_palette, which loops the base_palette looking for the color (the function returns the x position of the color). New palette + sprite with colors replaced (shader running) - don't mind the saturated colors, I chose them to be easier to see the shader at work: If shaders are not available (say, because the graphics card doesn't support them) then it is possible to clone the 'original' textures and generate different versions with the color changes pre-applied. With this shader I don't need to create any sprite masks, I can use the original sprites. Use a shader and write some GLSL to perform the 'palette swapping' behavior. I wrote a simple canvas_item shader that gets an input base palette (the original palette of the sprite) and a new palette (the replacement palette) and correctly replaces the original colors with the new colors. ![]()
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |