Black and White
Messing about with a texture, and I want it to fade from the full colour bmp untill all the colour has gone out of it leaving me with a greyscale version of the bmp.
Not totally sure how I would do it, anyone able to point me in the right direction?
Thanks
June 20, 2003 05:44 PM
(r,g,b) -> grayscale
------------------------------
grayscale = 0.59*g + 0.21*r + 0.2*g(I don''t remember the exact formula - coefficients are taken "from air", except 0.59)
So you''ve got the same color but in grayscale: (gs,gs,gs)
Then determine "inc" values
ir = (gs-r)/number_of_steps
ig = (gs-g)/number_of_steps
ib = (gs-b)/number_of_steps
Then use ir,ig,ib to interpolate between rgb an gs:
for(number_of_steps)
{
r += ir
}
Hope it''ll help you somehow!
------------------------------
grayscale = 0.59*g + 0.21*r + 0.2*g(I don''t remember the exact formula - coefficients are taken "from air", except 0.59)
So you''ve got the same color but in grayscale: (gs,gs,gs)
Then determine "inc" values
ir = (gs-r)/number_of_steps
ig = (gs-g)/number_of_steps
ib = (gs-b)/number_of_steps
Then use ir,ig,ib to interpolate between rgb an gs:
for(number_of_steps)
{
r += ir
}
Hope it''ll help you somehow!
Thanks for the replies to this, but I have to admit that doesn''t help me too much.
It''s my fault, for sure.
With those formulas, I think i would have to change the color value of each pixel of the picture.
Not 100% sure at all, but that''s the image i get.
It''s my fault, for sure.
With those formulas, I think i would have to change the color value of each pixel of the picture.
Not 100% sure at all, but that''s the image i get.
Checking a few places the formula seems to be R=0.30, G=0.59, B=0.11 - you''ll have to take every pixel and multiply them by the above ratio.
How about using 2 textures... color and greyscale of the same image. Fade one to the other with blending.
-solo (my site)
-solo (my site)
-solo (my site)
5010 is right! That should be the easiest and fastest way, to do that, though it isn''t the best way to save alot of VRAM 
I had this thought that you should not even need to have 2 different textures because loading the colored texture as a luminance map should result in a greyscale image (didn''t try that
).
The only, and even the hardest con about doing it like this is, that you are really pissed if you already have 2 texture units. Most graphic boards won''t support more than 2 texture layers
This could be solved by using 2-pass multitexturing (2 Texture Units * 2 Passes = 4 Texture Units) but that''s not that fast again.
Another possibility is, that you could use a pixel-shader (fragment program). Don''t know if that''s fast since only very new cards support pixel-shaders by hardware and emulation on older boards is damn slow, but maybe a simple program is fast enough (also didn''t try this
)

I had this thought that you should not even need to have 2 different textures because loading the colored texture as a luminance map should result in a greyscale image (didn''t try that

The only, and even the hardest con about doing it like this is, that you are really pissed if you already have 2 texture units. Most graphic boards won''t support more than 2 texture layers

This could be solved by using 2-pass multitexturing (2 Texture Units * 2 Passes = 4 Texture Units) but that''s not that fast again.
Another possibility is, that you could use a pixel-shader (fragment program). Don''t know if that''s fast since only very new cards support pixel-shaders by hardware and emulation on older boards is damn slow, but maybe a simple program is fast enough (also didn''t try this

This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement
Recommended Tutorials
Advertisement