Determine brighness/light level at location
I'm currently working on a system that determines whether the player is in the shadows or lit (and how much), as seen in the old Thief games. Getting the lights that affect the player is easy, but I'm having trouble calculating how much light actually reaches the player at a given distance.
A solution was posted in this post: How do I get the light levels at the player's position? However, it is at the very least incomplete as it does not take into account the intensity of the light and whether inverse squared falloff is used or not. Both, and especially the former, are big deals.
I've been digging through the source of the engine and found some useful information. In particularly the file "Shaders/DynamicLightingCommon.ush" has proven useful. However, parsing through it, I still don't see where the intensity comes into play. There are also variables for which I couldn't find out how they relate to the settings of the light components (e.g. DeferredLightUniforms.LightInvRadius - what is it and where is it set?).
In the PointLightComponent.cpp I found out how the intensity and units relate to one another (line 198).
Help would be greatly appreciated, as I'm currently diving into the depths of the engine's source code and it's quite the ride. It's not easy to find what you're looking for, if there is this much code. I need this to work reliably for point- and spotlight components. Directional and skylight aren't relevant (although, admittedly, they're the most trivial).
asked May 17 '18 at 11:21 AM in C++ Programming
Follow this question
Once you sign in you will be able to subscribe for any updates here