Take the 2-minute tour ×
Game Development Stack Exchange is a question and answer site for professional and independent game developers. It's 100% free, no registration required.

When I use "normal" spot lights as presented in tutorials such as this (with the exception that I use inverse square fall-off and then gamma correction), the spot light doesn't behave like a real spot light would, because in real life I would expect a narrow spot light to cast a brighter light than a broad one. In my primitive understanding this is because the light that would be cast outside of the spot lights casting angle is reflected on the inside of the spotlight device (e.g. flashlight) and effectively cast inside spotlights cone.

The spotlights usually presented in tutorials do not account for this, because the light calculation is still based on a spot light that distributes all of its energy evenly in a 360 degree radius, and the light that isn't visible is simply "clipped away", thus removing energy from the system.

My question is this:

I plan on accounting for this by just multiplying the outgoing color by a factor that depends on the casting angle of the spot light. The function of this factor is just

f(x) = 360/x; 

This means that the color will be multiplied by 4 when the spot light casts its light in a 90 degree angle. This function makes the assumption that the energy received by the lit area of a 180 degree spot light is twice as much as the energy received by the lit area of a 360 degree spot light.

Is this assumption correct? If not, how does the energy distribution change with the width of the spot light? Are there maybe other ways to account for this more effectively?

share|improve this question

1 Answer 1

up vote 3 down vote accepted

If you want to maintain the total amount of light power generated by the spotlight, then its brightness should be scaled inversely by the amount of solid angle it can emit into. With a little math you can calculate this: if the spotlight angle is a then the fraction of solid angle (i.e. fraction of area on the sphere of directions) is

0.5 * (1.0 - cos(0.5 * a))

So if you want to maintain the same total amount of light power generated by the spotlight, you should divide the brightness by this value.

Here's the derivation if you're curious: I'm going to calculate the area of the circular cap where a unit sphere intersects the spotlight cone, in spherical coordinates. The cap ranges from θ = 0 to θ = a/2 in spherical coordinates (taking the polar axis of the sphere to be aligned with the spotlight axis). The area is then

(integral from 0 to 2π) dφ (integral from 0 to a/2) sin θ dθ

Doing this integral gives 2π (1 - cos a/2). The total area of the sphere is , so divide by that to get the area fraction, and you have the above result.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.