PDA

View Full Version : question about rendering order of 2 passes



Nil_z
02-07-2002, 11:48 PM
I am writing the part of code that renders a polygon with lightmap in 2 passes. I do not know if I should render the lightmap first or the texture first. I have referred to some sample code, and some of them render lightmap first. If I should render lightmap first, can anyone tell me why? I just want to get clear about it.

Thanks.

Tom Nuydens
02-08-2002, 12:18 AM
If all you're doing is combining a lightmap L with a texture T, then what you're calculating is L*T. As you should know, this equals T*L http://www.opengl.org/discussion_boards/ubb/smile.gif

-- Tom

jwatte
02-08-2002, 08:59 AM
If you have multiple lights, it makes more sense to paint all lights first, in accumulate (additive) mode. Once you've done that, you can modulate in the base texture map. The nice thing with this design is that it scales to as many lights as you want (with some loss of frame rate each time you get a new texturing pass, of course).

zed
02-08-2002, 12:07 PM
personally i find for light/detail maps using add_signed better than modulating. ie modulating is only gonna make things darker but with add signed u can make things darker + brighter. 0.5 == no change

Moz
02-08-2002, 12:17 PM
I'd say, use both.
MODULATE for diffuse lighting and ADD_SIGNED for the ambiant light.
Preprocess the lightmap (diffuse lighting), then use it in texture unit 0 with ADD_SIGNED of some primary color (ambiant light) and modulate with a color map in texture unit 1.
This way, you keep control of both ambiant and diffuse lighting, something you wouldn't be able to do otherwise.
That's what I do in my terrain engine. You could also add the ambiant light at preprocessing time, I don't do that cause I already use the texture combiners fully during preprocessing.