This can the be used in a shader, to swap all colors to the goal palette, while the sprite itself is made in the base palette. The palettes are also wider than, for example, 8 pixels for 8 colors, so the colors can actually be unevenly distributed and no strange edge cases happen with the lookup. The result will look something like this: 'll notice the colors are not evenly distributed, but take the space exactly so that the "uneven" lookup from the base color does hit the right swap color. The "doing some math on it" in this case is just taking the average across all color channels (= the grey value). It the calculates a new goal palette, so that the color value lookups from the base palette always hit the right color. I wrote a small program that takes a base palette that is used for all your sprites and a goal palette. I'm not sure if this is common knowledge, but i found a way around it (which might be obvious after this introduction): the swap palettes don't need to be evenly distributed, but can distribute their colors in a way to make the lookup from the base palette always hit correctly. That would mean the lookup on the goal palette would probably hit the same swap color for multiple base colors. However, the problem with having your base palette not as evenly distributed greyscale is that the lookup on the swap texture can get the wrong color. On the other hand, i don't like having grey sprites everywhere either, or having to run a converter program after getting a new sprite. I didn't like this, because i don't think any pixel artist likes to pixel in greyscale, or likes the additional work saving everything as grey. This is the easiest to do, because you can control the base colors well by evenly distributing the color values. So for example, you see a pixel with a red value of 0.6, and then sample from the goal palette at uv=(0.6, 0.0) to get your swap color.Īll examples i found required the sprites to be in greyscale (or do strange things you don't want to do in shaders, like tons of if clauses). The basic idea behind palette swaps is usually this: Take a color value from the original texture, do some math on it and use it to look up color in a swap palette, to use that color instead. I was always interested in palette swaps, especially for out current game in development, as it has a small palette.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |