-
-
Notifications
You must be signed in to change notification settings - Fork 35.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add penumbra angle to spotLight #5080
Conversation
Add an additional option to `THREE.SpotLight` called `penumbraAngle`. This angle will be added to the angle of the spotlight to create a "falloff" cone. The area within both cones is lit as normal. The area outside of the falloff code is not lit. The area between the inner and falloff cones is smoothly faded away as it approaches the edge of the falloff cone.
@WestLangley continuing...
Can you elaborate a bit? I'm not sure I understand your meaning there.
The TL;DR version is that the exponent parameter is capable of modeling this: which is not how light from a spot light spreads. The penumbra falloff is capable of representing something closer to this:
Added a general "spotlights" example with sliders. |
OK, this looks pretty good to me, and I like it better than what we have now. @sgrif Your 2nd demo with the sliders is much more useful than your first demo, IMHO. On my end, I hacked it to add Would you be willing to expand your 2nd demo, add a camera controller, and add more light params and light and shadow helpers to the GUI so @mrdoob and others can easily experiment with your proposal? Also, the light helper and shadow map helper need to be consistent with any changes made here... I wonder if the penumbra should be on the "inside" rather than the "outside"... Maybe it is OK as proposed... |
@WestLangley Yes, I will add that.
I think the best solution is adding support for negative angles as well, which would be inside. |
What is the physical model that justifies negative penumbra angles? |
There isn't it's a convenience. The effect is equivalent to subtracting the penumbra angle from the light angle. (e.g. swapping the two cones). Makes it easier to tweak the exact way that you're looking for the light to display. |
I would not be in favor of negative penumbra angles, per se. I would be in favor of declaring the that The effect would be to simply replace the exponential decay ( After thinking about it a bit, I think this is the best approach. |
I see that your same model has been implemented elsewhere (http://www.ozone3d.net/tutorials/glsl_lighting_phong_p3.php). By keeping the penumbra on the inside, no shadows are cast outside the cone, and you can implement your penumbra model by changing only the falloff function ( i.e., the You can define the falloff function via a parameter that replaces |
I would personally expect the parameter to be an angle in radians, not a percentage. |
That is an option. However, having parameters that are co-dependent can be problematic. You are simply specifying a function that defines the intensity as a function of angle. That function has one parameter in your proposed model. You can parameterize it any way you want to, but having that parameter independent of the other model parameters is best, IMO. |
How is a percentage independent? It is by definition dependent on the value of angle. |
The percentage can go from 0 to 1 independently of the value of the spotlight angle. Your proposal to use an angle for both parameters has merit. I just personally think that having two angles, with one required to be less than the other, is not a good model parameterization. Your call, though. I am just telling you what I think. : - ) |
I think 2 angles is fine. It allows people to experiment with incorrect values if they want (one can find interesting styles like that). |
@sgrif Is this PR ready to be merged? I wasn't sure if you were planning to do anything else with it. |
Yes, I haven't had a chance to update with @WestLangley's feedback. Should get a chance today or tomorrow. |
Er yes, I am planning on doing more with it. No it is not ready to be merged. |
Ended up implementing this but with @WestLangley percentage suggestion. Looks really good! Thanks guys! |
Add an additional option to
THREE.SpotLight
calledpenumbraAngle
.This angle will be added to the angle of the spotlight to create a
"falloff" cone. The area within both cones is lit as normal. The area
outside of the falloff code is not lit. The area between the inner and
falloff cones is smoothly faded away as it approaches the edge of the
falloff cone.
Before:
After (10 degree penumbra):