Splinter Cell like light meter

What are the best options for getting the amount of light that is being cast onto the player character.

I’ve been thinking about it for a while but there are multiple issues with every solution I’ve come up with.

I faced the same needs and i did like this:

OnBeginPlay: store all Level lights in GameMode with a TArray (to prevent getting lights in tick)

Then i added a special component to my Character that checks these lights during tick according to their type :

  • distance then LineTraceTest for PointsLights
  • distance then angle then LineTraceTest for SpotLights
  • LineTraceTest for DirectionalLights

When the character is computed “visible” from a light i then apply an empiric formula using the light color, intensity and the character position within the light influence (Sphere, Cone).

It is not fantastic but it’s good enough for my need.

The sad part is that in UE3 there was the DynamicLightEnvironmentComponent that did the exact job we’re looking for but it has not been kept in UE4 :’(

Yeah, this was along the lines of what I had planned. The issue is that it you can’t get away with multiple traces for each light source to check if some parts are lit, and others are not.

But it’s certainly better than nothing. Thanks for letting me know.

We could improve precision by pushing multiple asynchronous line trace and postpone light influence update by 1 or 2 frame, it really depends on how many lights you’ve got in your level. (check out WorldCollisionAsync.cpp)

So I tried out your solution and worked really well. Want to submit as an answer, so you can get the credit?

Yes you can accept it, i may update this post later when i’ll come back to optimize/improve this feature :wink: