How I can do a palette? (Changing specific colors of a Sprite)

:information_source: Attention Topic was automatically imported from the old Question2Answer platform.
:bust_in_silhouette: Asked By Vernon3264


I’m trying to make a retro-styled game and I want to do a Sprite that changes its colors simulating a palette like in NES games , I tried to find tutorials but none of them worked for me, I only know that I need to do a shader for the sprite, but I don’t know how to simulate the palette.

Anyone can help me? Thanks.

:bust_in_silhouette: Reply From: Zylann

Using a palette means you should not draw your sprites with arbitrary colors, but rather specific colors which you can then swap in a shader with a bit of math to map the original color to a palette texture coordinate, which you then use to replace the final color.

Did you see this technique? I wrote a shader to replace the palette of a sprite with another palette. Is this the best way? Any way to optimize? - Archive - Godot Forum

There are many other ways, but in any case it would help you a lot to learn shaders so you can find your preferred way.

Thanks for answering my question. But I found an another method using “Color 1”, “Replace 1”, “Color 2”, “Replace 2”, etc.

Vernon3264 | 2019-06-28 15:06