Hello, Does anyone know how to calculate light level on a surface and position of a shadow and its intensity? I need this to calculate plant growth.
Welcome to the forum @Gabriel_Pislar!
I’m not too well informed on this, but is there a way to “pass back” per-pixel data to the CPU? or should all this be done via shaders?
You could render to a render target texture by using a full white material. Then you could read back the pixel color to deduce the intensity of the light.
Be careful as this my be pretty slow due to the back and forth CPU - GPU
Off-topic, or maybe on, …but let supose to increase the light you have a logic, some variables, maybe a function, why you do not use these informations which you already have to grow your plants? Sounds too complicated to me to try to get light from scene when you can create the grow system totaly independent of light, based only on time. And why not, link the light to it but not oposite. Or maybe I missunderstood
Why not take a single point on the “plant” at the very end, or the growth point.
Then iterate through the lights in the scene, and get their offset Vector and contribution. Add all the offset Vectors together scaled by their contribution. Fire a single ray toward the light and see if it hits any meshes if so the point is in shadow for that light so contribution = 0. Take the result and divide it by number of lights that contributed. Displace the growth point buy the new contribution vector rinse wash repeat?
Duplicate the process per node of the plant?