Then for each non white pixel (255,255,255) on the image I apply the mask vs palette translation The total size of the palette (image width) Then the shader where the magic happens: uniform texture palette Megaman cyan color is 2,2,2 which is index 2 on paletteĪnd then the palettes, because I need only 3 colors I created my palette of 4x1 pixels, more colors to map, the bigger the palette. Megaman blue color is 1,1,1 which is index 1 on palette Megaman black color is 0,0,0 which is index 0 on palette They are greyscale images without alpha where each color is represented by a correlative number and then this number represents the color index on the palette: This solution only requires a greyscale mask for each frame and the palette textures which saved on the correct format are a minimal memory overheadįirst you need a mask which represent the areas that change color for map on the palette, on my example these are like this: UPDATE, Now this work perfect on Intel GPUS, blame bad precision on intel gpus for uniform float vars.Īlso use ASEPRITE for generate the greyscale mask, Photoshop alters the palette on saveĪfter playing a bit with godot I found maybe the best solution for this problem without using if for each color or a loop: To everyone finding this post useful and willing to use this code, feel free to do so as you wish! answered by Alex\doc ( 109 points) I'm mot sure if you can actually use this shader per-instance, but might be useful anyway. Where test_col is a mask color that you use only for mask-testing, for instance (1.0,0.0,1.0) and new_col is the color you will replace the mask with. the new texture color is now new_color * diff if the difference is less than our threshold calculate the difference between our color and test color Uniform color test_col //the color to test against The only way I have in mind is by doing a shader like this: uniform texture in_tex //input texture
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |