Two images, one is the plain image of the unit, the other is a "greyscale" of the colored overlay onto that unit. I had both have an alpha channel. The "greyscale" image is colorized to the player color, then blitted onto the plain image.
ADVANTAGES:
a) Plain color-less unit can be useful
b) full unit-edge blending
c) Gradients of player color
d) full playercolor-edge blending
DISADVANTAGES:
a) umm... two images?
(SDL) Help figuring out RTS style colorswitching
Quote: Original post by JonnyQuestQuote: Original post by Raduprv
That way works fine until you want to have some blue on the units, but you don't want that blue to be repalced with the unit color.
That's hardly going to be an issue. If the colour key is (0,0,255), just use (0,0,254) instead of real occurrances of 255 blue. Don't tell me you can tell the difference in-game.
~phil
Sure, but you might have some trouble convincing your exporting program not to use 0,0,255 (and tell all your artists to be carefull not to use that specific color either).
Quote: Original post by C-Junkie
DISADVANTAGES:
a) umm... two images?
b) not being able to have two different colors on different units.
What C-Junkie suggested is what I would have done, and infact have done, although with OpenGL rather than SDL.
Why would this prevent you having 2 different colors on different units? I'm not even sure what this means, but I disagree with it anyway :p
Why would this prevent you having 2 different colors on different units? I'm not even sure what this means, but I disagree with it anyway :p
Done this in VB. Solution: 2 images.
- full colour underneath
- 1-bit alpha mask.
- also, you need a 3-channel multiplyer. R,G,B, each being a value from 0 to 2.
1) Use the alpha mask to pull a masked-out copy of the full colour image, so you have only the parts of the image you want to be in the team's colour.
2) Discard the colour information from the copy (average out 3 channels).
3) Apply a colorisation multiplier. One multiplier for each channel. If any channel goes over maximum, redistribute it into the other two channels to whiten the pixel. Now you have an image containing only the teamcoloured areas of your original image.
4) Invert your alpha-mask to pull a masked copy of the original image, this time the non-teamcolour regions. Masked-blit that onto your copy.
So, now we've recoloured regions of your image according to the multiplier.
Depending on how you use your alpha mask, there may be more intermediate copies needed. I'm assuming you have a single-step "copy/apply mask" operation.
- full colour underneath
- 1-bit alpha mask.
- also, you need a 3-channel multiplyer. R,G,B, each being a value from 0 to 2.
1) Use the alpha mask to pull a masked-out copy of the full colour image, so you have only the parts of the image you want to be in the team's colour.
2) Discard the colour information from the copy (average out 3 channels).
3) Apply a colorisation multiplier. One multiplier for each channel. If any channel goes over maximum, redistribute it into the other two channels to whiten the pixel. Now you have an image containing only the teamcoloured areas of your original image.
4) Invert your alpha-mask to pull a masked copy of the original image, this time the non-teamcolour regions. Masked-blit that onto your copy.
So, now we've recoloured regions of your image according to the multiplier.
Depending on how you use your alpha mask, there may be more intermediate copies needed. I'm assuming you have a single-step "copy/apply mask" operation.
-- Single player is masturbation.
Simplified approach, but more difficult for artist, using standard bitblt.
- grayscale image, black background, of colourisable regions.
- Colour image of full thingy, blackened out the colourisable regions.
so, first, copy and recolour your grayscale image using multipliers, as mentioned above. Then, just use an image "add" operator to bring in the full image with the blackened colourisable regions. Bingo, regionally colourised image in three steps, one copy, one colour, one add. If you add black to an image, you get the original image, if you add image to black, you get image. So you just merge two images together where the image data never intersects, only the black. Start with one being grayscale then colourise it and merge.
- grayscale image, black background, of colourisable regions.
- Colour image of full thingy, blackened out the colourisable regions.
so, first, copy and recolour your grayscale image using multipliers, as mentioned above. Then, just use an image "add" operator to bring in the full image with the blackened colourisable regions. Bingo, regionally colourised image in three steps, one copy, one colour, one add. If you add black to an image, you get the original image, if you add image to black, you get image. So you just merge two images together where the image data never intersects, only the black. Start with one being grayscale then colourise it and merge.
-- Single player is masturbation.
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement