PDA

View Full Version : Rendering in grayscale



Laz
06-22-2003, 03:59 PM
Hey, I was wondering if there is a way to render my scene in grayscale on the fly (without storing both color versions and grayscale versions of the textures). I'm looking for this to be pretty fast, as it will be happening in the middle of a game. Any ideas would be really helpful, thanks http://www.opengl.org/discussion_boards/ubb/smile.gif

brute
06-22-2003, 11:45 PM
You can use the glPixelTransfer function to convert RGB to luminance on the fly.
Set GL_RED_SCALE to 0.3
GL_BLUE_SCALE to .59
GL_GREEN_SCALE to .11

This will display as grayscale.
brute

Laz
06-23-2003, 12:51 PM
Originally posted by brute:
You can use the glPixelTransfer function to convert RGB to luminance on the fly.
Set GL_RED_SCALE to 0.3
GL_BLUE_SCALE to .59
GL_GREEN_SCALE to .11

This will display as grayscale.
brute

This method pretty muched turned the scene purple. Also, it wasn'tvery fast. It slowed me down quite a bit. I'll look into it a little further though. Thanks!

chowe6685
06-23-2003, 05:16 PM
ok, this is cheating a bit but what if you took advantage of the fact that unless you set material colors or enable GL_COLOR_MATERIAL the default rendering looks like greyscale. If you made all the lights white, and used glColor instead of glMaterial then depending on whether you had GL_COLOR_MATERIAL enabled you would get greyscale. Let me know if this works, I havn't tried it, but it seems like it would work and should be very fast.

Ok, just realized you will have troubles with the textures. I'm not sure if there even exists a fast way to convert them from color to greyscale, but remember that greyscale versions will be 1/3 the size of the RGB ones, so you might be able to store both copies without problems.

[This message has been edited by chowe6685 (edited 06-23-2003).]

Mazy
06-23-2003, 08:07 PM
If you dont use alpha in the textures, then you have a nice place to put your grayscale data in. And you can easily fade to and from it by using env_combiners and the interpolate mode, since you can have alpha as a color input. ( using only one texturestage for the whole operation).

It doesnt solve untextured objects, but thats easier to fix with just the correct glMaterial calls


[This message has been edited by Mazy (edited 06-23-2003).]