tags:

views:

58

answers:

3

Is there a way to set the blending parameters so the whole scene renders in grayscale? (without using GLSL, only pipeline functions)

Thanks

A: 

No, all colors are separated. You need a pixel shader for that

VJo
A: 

Hm, maybe if it was rendered to a luminoscity+alpha FBO, and then that drawn?

Well, either that or copied onto such a texture, then the texture back onto the FBO - that said, FBO's would be a better solution (if available) in most cases.

Please note that I haven't tested this.

Tim Čas
Is it possible to create such FBO?
VJo
Maybe you can render to luminance+alpha texture
VJo
Yes, that's what I meant - FBO is basically just that, render to texture. If that fails, try a normal copy-to-texture and then copy back onto the framebuffer. I should try that myself once I get around to it... Oh and, alpha may or may not be required, depending on your requirements.
Tim Čas
A: 

Actually, for completeness sake, I'll mention that there is one possible solution if the GL_ARB_imaging extension is supported: the GL_COLOR_MATRIX, which transforms incoming RGBA values. You could set the upper 3x3 matrix to all 1/3.0 like so:

GLFloat graymat[] = {.33,.33,.33,0,.33,.33,.33,0,.33,.33,.33,0,0,0,0,1};
glMatrixMode(GL_COLOR_MATRIX)
glLoadIdentity()
glMultMatrixf(graymat)

However great this may sound, though, not all drivers support this in hardware, which means that depending on your opengl implementation, your driver might: A) ignore the color matrix totally, B) fall back to software rendering, or C) (if the extension is not supported) raise a GLError.

If you are writing your code for a limited set of platforms, and they support this extension, then it would be the easiest way. Otherwise, you'll need another approach.

Matthew Hall