PDA

View Full Version : Luminance Rendering Without Shaders



cjacob
11-12-2002, 10:38 AM
I can't find a way to render the luminance of the scene. The goal is to create a night vision effect that would render the luminance of the scene modulated in green. Does someone have a clue on how to achieve this without using shaders ?

Humus
11-12-2002, 12:20 PM
glColorMask(GL_FALSE, GL_TRUE, GL_FALSE, GL_FALSE) maybe http://www.opengl.org/discussion_boards/ubb/tongue.gif

cjacob
11-12-2002, 12:50 PM
Unfortunately, I can't do that. This doesn't modulate the luminance. If you have an object with no green component, let say a red ball, it will appear black ! I need to do something like this: G' = L where L = xR + yG + zB, then do a colorMask( false, true, false, false ). I just don't know how to make the hardware compute the Luminance... I need something similar to the extension GL_SGI_color_matrix.

Zeno
11-12-2002, 01:07 PM
The typical way of converting color to a luminance value is to dot the RGB color vector with (0.3, 0.59, 0.11). You can then place the resulting brightness in the green channel.

-- Zeno

cjacob
11-12-2002, 01:18 PM
Ok, I agree with the theory, but can you give me more details on which methods I can use? I want this to be computed by the hardware. I know I can call glPixelTransfer and set the proper scaling factor for each of my components, but how can I put the result back in the green channel?

Bob
11-12-2002, 01:33 PM
You should have a look at ARB_texture_env_combine and ARB_texture_env_dot3. These two extensions gives you all you need.

Zeno
11-12-2002, 01:43 PM
Follow Bob's advice or use register combiners to perform the math. Do what Humus said to limit yourself to the green channel. Try to avoid pixel transfer if you're want to do this real-time.

zed
11-12-2002, 07:35 PM
u mean like this? 3/4 way down http://uk.geocities.com/sloppyturds/kea/kea.html
i think i just used readpixels (pretty quick if u do it right)
ill leave u to work out what to do with the data after youve read it (as its a nobrainer http://www.opengl.org/discussion_boards/ubb/smile.gif)

dorbie
11-12-2002, 09:12 PM
zed, you've been busy. That's starting to look pretty darned good. Dunno if you ever saw a game called Virus on the Amiga, a very unique 3D scroller over terrain with a hover hover control using the mouse. It looks like you have a great engine for a revamp. Your screenshots are reminiscent of that game for some reason. Probably the angle of the shots and scale of the ships.
http://www.amigagames.com/gage/v/virus.html

cjacob
11-13-2002, 10:53 AM
Thanks everyone! I've found the answer.
Using the color matrix of the imaging subset does all the job for us...

glMatrixMode( GL_COLOR );
glMultMatrixf( m );

and that's it ! http://www.opengl.org/discussion_boards/ubb/smile.gif

zed
11-13-2002, 11:45 AM
i remember that game, that was the follow up game done by the guy who done elite.
oddly IIRC it didnt get the praise it deserved cause if memory served correct it ran blindily quick (fast 3d graphics on an amiga, sure there were no textures but still a fabulous piece of programming)
one fault IIRC was it was difficult to control the spacecraft (it used quasi proper physics like lonar lander and not some gamephysics). unfortunatly im having to 'dumb down' the controls or else its too difficult to control.