How can I measure the amount of light hitting a mesh?

I want to create a variable that shows the amount of light hitting a mesh (e.g. a small cube that is partitally shadowed) Is there any measurement, how much light hits the mesh? Or, is there a not too complicated way to get create one?
Thank you for any answer!

How accurate do you have to be? What usage is this for? What are you trying to achieve by calculating this?

There are several methods that might be good enough or give you the result you want, but we need more information.

If you need it for gameplay purposes, I suggest doing a trace from the object to the light, checking if anything interrupts visibility. For better approximation, you could do this from several points( all corners of the cube), and average the results. This is doable in blueprints. Obviously you can only afford to implement this for 1 object only, for performance reasons.

Rendering side of things looks different. It is possible to approximate this in post process material, but no way nearly accurate. You should inform what are you intending to achieve, since in most cases when such questions arise there already is an elegant solution

I intend to do a stealth game, top down view. Right now I try to figure out what technical options I have. The main purpose is to calculate the visibility of the main character by other (enemy) actors, but other possibilities like hidden traps would be nice (you’d need light to see them, but this light could show the characters position).
I’ve a lot of c++ practice but i’m completely new to graphics.

I intend to do a stealth game, top down view. Right now I try to figure out what technical options I have. The main purpose is to calculate the visibility of the main character by other (enemy) actors, but other possibilities like hidden traps would be nice (you’d need light to see them, but this light could show the characters position). I’ve a lot of c++ practice but i’m completely new to graphics.

From what I understand you have a few options:

The easiest is simply to do a line trace from the object to all lights and see if you are visible. This will not be very flexible, but it is cheap and easy to implement. This is just a visible, not visible system. You can not be partially visible. However, what you can do is to use distance between the object and the light to indicate how visible you are. 5 meters away or closer and you are completely visible, 10 meters away or farther and you are invisible.

You can also use a distance based method where all you do is check if the object is close enough to the light. Let us say that you have an object in the world and your light has a range of 5 meters around you. Then you can have a hitbox around the light that triggers on overlap. You can filter the overlap events to only continue if the class of the other object is of a certain type. That way you can select what is being affected and what is not. This can also be combined with a trace.

Another option that will give you more accuracy and more flexibility is to have several locations on the object that all check if they are visible IF they are within range to be effected. That if is needed to not waste resources. You can then have a simple calculation to find out how visible you are by adding the light values of each point by doing an independent line trace for each.

Finally you can write a custom material that goes though all vertices or fragments and calculate how much is actually visible to the lights. This is very expensive and is not easy to do properly. For 99% of all situations where you might want it some version or combination of the methods I outlined above will be preferable.

I hope this helps.

It helps a lot, thank you very much!
Define sample points, check visibility - if visible calculate lighting impact from all light sources in reach.
Again: thank you!