I'm currently working on palette swap feature for my game's sprites on Unity . I know that this is normaly achieved by using a gayscale texture and then using a ramp texture to replace the colors or mapping each base color to a given channel value and then doing a lookup . BUT , since every sprite is hand drawn and painted , there are like a gazillion different RGB values and applying those techniques are a little troublesome .
So , what I want to do is write a shader that does the following :
-Get the RGB value of the pixel being processed
-Find the coordinate of that value in a palette texture ([n-colors]x2) (This is the part that i have no idea how to accomplish)
-With its coordinate , get the swap color that would be one row beneat the original color inside the palette texture
-Apply the new color to the sprite
Basically , this
![alt text][1]
[1]: https://i.stack.imgur.com/AHNCm.png
What i need to know is how to find the color inside the palette texture , **basicaly a reverse tex2D(_Texture,coord)**
Is there any way I could achieve this? If so , how efficient it is? Is there any other way?
↧