Finding bounding cone/pyramid for spot light

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

Recommended Posts

I have the following problem : given: -a direction vector for the light ( from the origin to the target ) -the lenght of the vector ( the brightness of the light ) -the cone opening ( degrees/radians ) How do I find the bounding cone for the light ? Or bounding pyramid even better, less vertices. I need it for checking stuff against this volume.

Share on other sites
You also need the position p of the light.

To test if a vertex is inside the bounding cone, test if the angle between the direction vector of the light and the vector from the lightsource to p is smaller than the cone opening. You get the cosine of the angle between two vectors by normalizing the vectors and then computing the dot product. Compare the cosine with the cosine of the cone opening - if the latter is smaller, the vertex is inside the cone.

Share on other sites
That doesnt work if the surface is not highly tesselated.
So if the surface is huge and the light only lits the middle of the surface then the formula doesnt work, tryed it already.
That`s why I need the bounding cone, so I can check against each of the planes if a vertex is in front/back of it.

Share on other sites
Rather than converting the cone to a bunch of planes, you'd probably be better off intersecting the cone directly with a simple bounding volume. It would be much less expensive and easier to code. For example, you could use bounding spheres. If that is of interest to you, a thread on sphere/cone intersection can be found here.

• What is your GameDev Story?

In 2019 we are celebrating 20 years of GameDev.net! Share your GameDev Story with us.

• 11
• 15
• 11
• 11
• 9
• Forum Statistics

• Total Topics
634151
• Total Posts
3015825
×