Hi,
I’m trying to know if a mesh is currently in the light or in the dark. Besides casting a ray to the light (to check if it’s occluded by geometry), I need to know if the mesh is in the light radius.
How do I check this?
I have been using this formula :
var Lightp = light.range * (light.intensity / 10.0f);
Being inside the light’s radius is just checking distance against the range.
The catch is that at “range” the brightness is 0, and the effective brightness changes based on a few different things.
How bright the light is
Light falloff curve (determined by render pipeline, I believe)
Material of the object being lit
I would guess that the inconsistency of results stems from those things. The first two are perhaps the more likely culprits, and are solvable with math.
I used this asset for a hobby project and to learn it myself. It works well, also for point lights! Solution actually is easy when you know how to do it but i feel it’s not fair sharing it cause i didn’t come up with it myself. But you can consider getting the asset and study the script!