Jump to content
  • Advertisement
Sign in to follow this  
OrangyTang

OpenGL Colourise greyscale without shaders

This topic is 4881 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

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).

Share this post


Link to post
Share on other sites
Advertisement
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...

Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites
A simple modulate won't get the effect I'm after - and if I move to a 2d 'gradient' then I could of just gone for a pre-baked 2d texture. [razz]

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!