Jump to content
• Advertisement

# lights! lights and more lights.

This topic is 4612 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

##### Share on other sites
Advertisement
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

##### 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

##### Share on other sites

• Advertisement
• Advertisement

• ### Popular Contributors

1. 1
Rutin
26
2. 2
3. 3
4. 4
5. 5
• Advertisement

• 9
• 13
• 19
• 14
• 9
• ### Forum Statistics

• Total Topics
632940
• Total Posts
3009329
• ### Who's Online (See full list)

There are no registered users currently online

×

## Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!