Colourise greyscale without shaders
Is it possible to colourise a texture on hardware without shader support (specifically, GF1 and GF2 era cards and up)? Hopefully in a vendor-independant (OpenGL) way?
More specifically, applying a 1d colour gradient to a greyscale 2d texture, where the grey intensity converts to a colour from the gradient.
I think I might be able to do something similar with palleted textures, but I don't know how much support they get (and I hear they're being phased out).
I'd stay away from palettes, but there is a way to do 7-bit grayscale on gf1+, at least in directx.
The easiest way is just to calculate your whole scene in color, then copy the back buffer to a texture, then apply a simple operation to the texture to display it.
The idea is to do, in ps.1.1 syntax
ps_1_1
def c0 0.29, 0.59, 0.12, 0.0 // luminance constants
tex t0 // fetch color scene
dp3 r0, t0, c0
I'm not sure if there is a simple opengl extension that does dot products...
The easiest way is just to calculate your whole scene in color, then copy the back buffer to a texture, then apply a simple operation to the texture to display it.
The idea is to do, in ps.1.1 syntax
ps_1_1
def c0 0.29, 0.59, 0.12, 0.0 // luminance constants
tex t0 // fetch color scene
dp3 r0, t0, c0
I'm not sure if there is a simple opengl extension that does dot products...
Further investigation shows that palettes are unusable in OpenGL unfortunatly (ATi don't support them, nVidia are dropping support in FX cards).
SimmerD: I want to go the other way to that - the input of a greyscale texture gets coloured according to the colour gradient on the 1d texture. I suspect theres no way to do this other than a dependant texture read, so I might be screwed for any hardware <GF3.
SimmerD: I want to go the other way to that - the input of a greyscale texture gets coloured according to the colour gradient on the 1d texture. I suspect theres no way to do this other than a dependant texture read, so I might be screwed for any hardware <GF3.
Well, you are not totally screwed. You could still very easily modulate the greyscale texture with the gradient texture. And do it in one pass on all but the oldest hardware. To get the best effect, you may have to change from a simple 1D gradient to a 2D gradient.
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement