Detect how lit a mesh is with ray tracing?

Since ray tracing is now finally a plausible thing (even though support and usage might still be limited and all of that), is it now possible to piggyback onto the pre-built modules to determine how lit or not lit / partially shaded etc. A mesh skeletal or otherwise is?

Is there a better way to detect this other then line/box/sphere tracing to the light sources?

Particularly, for my application, I would like to either get a variable exposed that tells me an approximation of the overall surface area of the item basic shape that is being lit:
1 spot light in front is approximately 50% of the area.
2 spot lights front and right would be 75%. Etc.

As well as an approximate factor of intensity to distance.
if I’m a mile away from a spotlight the intensity is close to 0, if I’m a meter away the intensity is 100%.

What puzzles me most is that obviously to shade a material properly the engine is already doing all of the needed calculations for us, yet I cannot find a way to determine how lit or unlit the mesh is even if the engine does know this with near 100% accuracy.

does anyone have or know any way to just read the values? I’m not opposed to recompiling the editor if its needed. It’s just superfluous overhead to calculate the same thing multiple times…

bumping this, though maybe I should post it into the UE4 questions…

There is a LOT of complexity here to consider.

In general you are correct, the GPU does know how much light a given pixel fragment is receiving from a given light source. It is creating a large number of rays and tracing them through an acceleration structure that represents the scene. As a side note, afaik, the default lighting is still done by rasterization, only shadows, reflection, and GI are done via rays.

But you need that information on the CPU, which is a whole different ballgame.

As you already probably guessed, your best approach is probably some kind of CPU-based light probe, where you simply query each light source by sending a a ray through the collision scene.

The magic of the gpu is it’s ability to do things in a massively parallel manner. It is not really any faster at tracing a single ray.

If your lights dont move, you could create a kind of light map volume built ahead of time that contains the information - kind of like the baked lighting lightmass does. You could then query that for coverage.

Thanks for the idea and explanation.
Generally speaking I rather come up with a lightweight hack rather then not utilize the calculation that many folks have put years upon years of effort into to make near perfect.

Based on what you said, the way to go here is to create a custom shader or hook into that portion in order to return the pre-computed values. Thanks for pointing it out, I’ll look into just how much I can get from doing that - honestly surprised someone hasn’t already created a plugin or something similar though.