"Replace Color" action for Sprite object

New releases and general discussions.

Post » Tue Feb 16, 2010 8:40 pm

does Range Tinter work with alpha?


Just in case it doesn't, or if you want to retrofit Color Replace with alpha support

Premultiplied alpha means color rgb(0.8,0.8,0.8) with an opacity of 50% gets stored as rgba(0.4, 0.4, 0.4, 0.5).

To get the original color, just divide by the stored alpha!

color = rgb(0.4, 0.4, 0.4) / 0.5 = rgb(0.8,0.8,0.8)

then do your color replacing magickqs and then re-multiply by alpha.

*All vector notation here is faux and does not work at all like that in shader code.
B
3
S
2
G
4
Posts: 1,445
Reputation: 4,665

Post » Thu Feb 25, 2010 8:13 am

You can store 3 masks in the RGB channels of a sprite and tint these areas independently. This method allows for gradients and semi transparent tinting as well, but this is the most basic implementation so any untinted areas will be black (which works fine for your citizens Namelezz).



I put together a basic shader and sample CAP file (edit:forgot to include the .FX file before, but should be there now)
[url:as3sz5ix]http://www.filedropper.com/colourtinting2[/url:as3sz5ix]

Right now the shader takes independent RGB values for all three masks so thats 9 numbers. I don't know if there's a more elegant way to have just 3 colour pickers or something.

This shader can also be made much more useful if instead of storing the transparency in the alpha channel you store a 4th mask, and then have a seperate sprite beneath the tinting sprite to provide the monochrome detail and blend with an overlay mode. The down side to that would be that you need two sprites per character. But yeay, for this kind of pixel art stuff that's not really necessary.
B
3
S
1
G
4
Posts: 42
Reputation: 1,609

Previous

Return to Construct Classic Discussion

Who is online

Users browsing this forum: No registered users and 1 guest