Sign in to follow this  

lights! lights and more lights.

This topic is 4305 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

ok... for some opinions/experience of people with lights: 1) at about how many lights is worth having per pbject (i.e. if a scene has lots of lights, a given object would be only lit by the nearest N lights) what is a good value of N to avoid saturation? 2) normal mapping and all: typcically one converts the unit vector from the "pixel" to the light source in the vertex shader (though the unit-ness of that vector may become not so good as it is interpolated across the face of a triangle)... one does this so that you don't have to do the matrix*vector multiply in the fragment shader on a per-pixel basis... however, then you are bounded by (about) atmost 6 or so light sources, since each light's unit vector will need 3 floats, another float for the attenuation (as one does not want to compute that on a per-pixel basis either) .... however I have an idea (though it does have some issues with normal maps): in the vertex shader, calculate 3 "summed" light vectors, 1 for each color via: sum.r= a1*light1.color.r*light1.unitVector + ... + aN*lightN.color.r*light1.unitVector similar for .g (green) and .b (blue), where a1 is attenuation for light1 if dot(normalVector,light1.unitVector)>0 and 0 otherwise, and so on for a2, a3, .., aN... note that sum.r is a vec3, not a float... and then "rotate sum.r, sum.g, sum.b" to be in texture space, then at pixel shader, one just would do: "gl_frag.rgb=vec3( dot(sum.r, normalTexture) *color.r, dot(sum.g,normalTexture)*color.g dot(sum.g,normalTexture)*color.a); now my thinking is that when one looks at a normal map, it is mostly sticking stright up at you, so the descision on which lights contribute at the vertex shader is not such a bad approximation (maybe) IF the light source is far enought away.... so would it be worth the bother to use only one light source whose usage is caclulated on a per-pixel basis (i.e. using method (1)) and the rest use (2).. the special light source being the closest one? or just say the hell with lots of lights and just use the closest light for the object?? [Edited by - kRogue on March 3, 2006 6:22:36 AM]

Share this post


Link to post
Share on other sites
1/ personally i find u shouldnt limit the number of lights, i used to limit the number of lights to max 12 per obj but even then i sometimes saw visually anomalies

2/ use multiple passes, i personally use one pass per light (im also doing shadowing)

also your shading equation looks wrong
u should be doing
diffuse = dot( lightdirection vector in model space, normalTexture);

Share this post


Link to post
Share on other sites
diffuse = dot( lightdirection vector in model space, normalTexture);

the ' then "rotate sum.r, sum.g, sum.b" to be in texture space ' is the light direction (sum of lights that is) in model space

for multipe passes like you say, one usually does deffered shading, so I would need either MRT (GeForce6 class hardware) or have to do 3 passes on the geometry and then do the lighting per pixel but have to convert to model space on a per pixel basis: on GeForce FX class that would jut kill it.

Share this post


Link to post
Share on other sites

This topic is 4305 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this