Skip to main content
gamedev.net
🔒 Locked

ShadowKey

Started by PaD Dec 27, 2006 at 4:17 AM 2 replies 500+ views
Original Post
PaD
PaD
Hey people! It might sound weird in a forum full of 3D specific questions but anyway: I'm working with 8bit-images and I want a specific color of the 256 colors to be shadowing the background (I'd call this a "ShadowKey"). A really good example for this feature is the C&C games. http://acdc-radio.de/bn/powr.png The green pixels in this image would be darkening the background (alpha-blended?). What I'm searching for is a technique to do this. My first idea was blitting the 8bit-image to a 32bit-Surface, browsing through every single pixel and make them black with a 50% alpha or something. But before blitting, there's still remapping, which isn't easy on 32bit-images... There must be a less complicated and less CPU/GPU eating method, since this already worked in old games like C&C or Settlers II, where 32bit-images weren't thinkable yet. I'd appreciate help here! Regards.
dv
dv
Well 8-bit images are usually indexed. So, a 8x8-bit LUT is possible:

uint8_t darkColor[presentColor][newColor]

Where presentColor is the color index already painted on screen, and newColor is the color being drawn. On most occasions, darkColor equals newColor, but sometimes it may be a darker version of presentColor.
~dv();
PaD
PaD
Hm... LUTs are probably a good idea, but I didn't quite get the second part of your post...
Could you go a little bit more into detail?
Todo
Todo
I think what he means is (or what you want to achieve is) this:

a LUT that matches the given color-key (green) and any other entry in the color-palette with a darker version of the latter, like this:

LUT[a] = b; where a = [0..255] and b = shadowed equivalent of a

Notice you only need to store one dimension for this to work, since the other always equals green in this case (the lookup depends only on the background, not the color-key).

This could give:

LUT[1] = 64; where palette[1] = RGB( 0, 0, 255 ) and palette[64] = RGB( 0, 0, 127 )

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.