Calculate the face/vertex light irradiance

Hello, I plan to use threejs for a plant growing simulation, and I need a way to estimate the light that hits a leaf and visualize the information when the mouse is hover that leaf, taking into accounts the shades produced by the other leafs.
The light source, ideally, should be dynamic (no bake beforehand)
If can’t get it to be dynamic I’m still interested to know If I can get the information of the baked light of the face/vertex hovered by the mouse
I don’t know if this can be accomplished with threejs… the closest example that I found here for GI but no much explanations
and webgl_shadowmap_progressive where is almost what I want if I can get the info hovering with the mouse

You can simply raycast from the light source (either static or dynamic, both will work fine) - something like this (original thread, change SHOW_SUNRAYS to true to display the rays.) The precision will be just as good, if not better, compared to using shaders / screenspace calculations.

For shapes more complex than a plane, you could either interpolate linearly between vertices, pick random points on the mesh, or just cast an arbitrarily-dense spherical cone of rays in the direction of the measured target and see what % of rays hits the target.

2 Likes

Does this method make the light bounce more then one time ?
How can I get a light value of the area under the mouse?
thanks!