Grayscale

I have a place where I want the background of my scene to be in grayscale, and then draw colored things on top. So I draw a bunch of stuff, then I want to draw a layer over top of that which makes the previous renderings look gray, and draw new stuff.

Is that feasible or will I have to do something before all of the other rendering occurs to enable some sort of grayscale filter? Either way, I have no idea how to do it. Anyone have any pointers for me? Thanks! :slight_smile:

It would be fairly trivial to write a fragment shader to output greyscale values instead of colours (even with correct intensity weighting) but that obviously requires somewhat higher spec hardware. However I don’t know of any other drop in solution (short of processing all your textures to be greyscale and forcing lights etc. as well).

Is the grayscale stuff going to be static ? IE you fade the game screen to gray when you’re displaying a trade or destination menu or something, but freeze the game ? In that case you could render off to a texture and process it on the CPU into grayscale and use it as a backdrop, drawing your UI elements over it in full color. This’d obviously take a bit of time but it’d be okay to do just the once when entering the menu system …

D.

Hmmm I was just expecting it to be rather simple like how I draw textures with a certain color set to colorize them. How about in just drawing a single image? Say I have an image, like a button, and when I press it down, I want it to be gray. Can I do that?

Same thing really, easy in a suitable fragment shader, hard otherwise.

You could use glColourMask to reduce it to just red or green or blue monochrome, but I don’t know if you’d be able to get a greyscale from that.

Too bad SGI_color_matrix is not part of core opengl…

Actually, now i think of it you could do a colour->greyscale conversion on the fly with GF1+ hardware. You’d just have to render to a texture, then render that back to the screen with a dot3 texture environment by a constant (grey) colour.

my video card only supports OpenGL 1.0, and no nice effects or shader things or any of that. Do I still have options there?