PDA

View Full Version : Multiple glLight & GL_DOT3_RGBA



bobGL
01-10-2009, 07:18 PM
Is there an easier way to handle DOT3 bumpmap with multiple lights instead or having to calculate the TBN on a glLight basis? and have to render multiple pass per light?

Tks in advance,

Cheers,

remdul
01-11-2009, 09:23 AM
No need for multi-pass:

1) pass light properties as array to shader
2) transform the light positions to tangent space
3) use a 'for' loop to do the dot3 for each light, accumulate result

satan
01-11-2009, 09:37 AM
The TBNs don't need to be calculated per light as they don't change. It is good enough to calculate them once and then use them for all lights.
And I don't know why you think you need multiple passes per light. One pass per light is good enough. You can even process multiple lights in one shader reducing the number of passes even more.

bobGL
01-11-2009, 02:35 PM
No shader is available to me... only combiners... In this case what would be the best approach? Cuz I really don't know how to handle multiple lights without shaders...

arekkusu
01-11-2009, 04:02 PM
BobGL, if you're using a device like the iPhone, then you really need a pass per light. You're primarily limited by the vertex attributes you're able to pass in to the combiners-- if you calculate the light direction at each vertex and pass it in as primary color, you use up one unit to perform the dot product between that interpolated color and the normalmap texture. That leaves you one more unit that you could do another light dot product on, but you don't really have any more vertex attributes to use (you could use the TexEnv constant color, but I don't recommend it.)

bobGL
01-11-2009, 09:57 PM
I see... well does anyone out there have an example / tutorial on how to use the DOT3 combiner with multiple light source, cuz I just can't figure out how this can be done without multiple pass blended together where all triangles are tested on a per light basis... (which seems to me to be the only way... but is like REALLY expensive)

Tks in advance,