Light surface detection...

Started by
1 comment, last by deavik 18 years, 4 months ago
Hey, If anyone has a second, I know this has probley been asked multiple times, but how can you detect what lights hit a given surface? What im trying to do is add multiple light sources to my scene(which Ive done), but odviouslly it runs pretty slow if it has to redraw the entire scene so many times for each light. So im trying to add detection to see what lights hit a given polygon, if it doesn't touch that polygon then dont keep redrawing that surface. -Justin
Advertisement
You have to use a collision detection engine.
Try OPCODE at www.codercorner.com/Opcode.htm

Think about that your light must have a shape like an Sphere, a cylinder, or a polihedron.
Opcode can give you the collided triangles of the AnyShape-to-Mesh intersection.
"Technocracy Rules With Supremacy" visit: http://gimpact.sourceforge.net
The lights theoretically have effect till infinite distances (in real life intensity varies as the inverse square of distance). You could just stop using lights if they are a prespecified distance away from the light. But a quick way to cull out back surfaces is to chekc their normals.

Take your light's direction in a vector (this direction may be just the difference between the position vectors of the object and the light) 'v', and let your surface normakl be n.

You don't need to make lighting calculations if:

-v.n < 0, or
v.n > 0

'.' is the dot product

This topic is closed to new replies.

Advertisement