Sign in to follow this  
eviltwigflipper

Light surface detection...

Recommended Posts

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

Share this post


Link to post
Share on other sites
leoptimus    106
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.

Share this post


Link to post
Share on other sites
deavik    570
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

Share this post


Link to post
Share on other sites

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