Does anyone know if there is a way to get the rendered light level (including the effects of both sector light level, weapon flash, any dynamic lights, etc.), either at arbitrary coordinates or at specific texture coordinates of a wall/flat/sprite?
I can't find anything, but want to at least ask before requesting as a feature...
Get effective light level at arbitrary position?
Moderator: GZDoom Developers
Forum rules
Before asking on how to use a ZDoom feature, read the ZDoom wiki first. If you still don't understand how to use a feature, then ask here.
Please bear in mind that the people helping you do not automatically know how much you know. You may be asked to upload your project file to look at. Don't be afraid to ask questions about what things mean, but also please be patient with the people trying to help you. (And helpers, please be patient with the person you're trying to help!)
Before asking on how to use a ZDoom feature, read the ZDoom wiki first. If you still don't understand how to use a feature, then ask here.
Please bear in mind that the people helping you do not automatically know how much you know. You may be asked to upload your project file to look at. Don't be afraid to ask questions about what things mean, but also please be patient with the people trying to help you. (And helpers, please be patient with the person you're trying to help!)
-
- Posts: 1339
- Joined: Tue Jul 15, 2003 4:18 pm
-
- Posts: 2150
- Joined: Thu May 02, 2013 1:27 am
- Operating System Version (Optional): Windows 10
- Graphics Processor: nVidia with Vulkan support
- Location: Brazil
Re: Get effective light level at arbitrary position?
I'm pretty sure that's been suggested and [No]-ed before, because this is render-only data and should remain that way.
And with OpenGL I'm pretty sure you can't even get this, as it's all done on the GPU.
And with OpenGL I'm pretty sure you can't even get this, as it's all done on the GPU.
-
- Admin
- Posts: 6212
- Joined: Thu Feb 26, 2004 3:02 pm
- Preferred Pronouns: He/Him
Re: Get effective light level at arbitrary position?
You could approximate it by getting the sector light level, and checking the distance from any dynamic lights vs. their radius/intensity.


-
- Posts: 1339
- Joined: Tue Jul 15, 2003 4:18 pm
Re: Get effective light level at arbitrary position?
That's essentially how the stealth visibility handling works in Blade of Agony (though in reverse... the lights set a distance- based "light level" value on any player in range). This doesn't work easily for the new spotlights, though, because they actually project a cone of light... so the math is far more convoluted, especially if the spotlight is pitched and/or angled.
EDIT: And, as of today, this is how the visibility handling works for spotlights in Blade of Agony, too, using the relative pitch and angle of the player from the spotlight's centerline pitch and angle to calculate visibility instead of using straight distance, but, same concept. It's just so... annoyingly inexact, and feels like a hack when I know that the "actual" data is in the engine *somewhere*.
EDIT: And, as of today, this is how the visibility handling works for spotlights in Blade of Agony, too, using the relative pitch and angle of the player from the spotlight's centerline pitch and angle to calculate visibility instead of using straight distance, but, same concept. It's just so... annoyingly inexact, and feels like a hack when I know that the "actual" data is in the engine *somewhere*.
Last edited by AFADoomer on Fri Jan 26, 2018 9:23 pm, edited 1 time in total.
-
-
- Posts: 667
- Joined: Wed Aug 02, 2017 12:31 am
- Location: In between the Moon and you, between the buried and me.
Re: Get effective light level at arbitrary position?
Would the Exposure Texture used by the tonemap shaders have that info embedded? I've been meaning to request that access be given to it...
-
- Lead GZDoom+Raze Developer
- Posts: 49211
- Joined: Sat Jul 19, 2003 10:19 am
- Location: Germany
Re: Get effective light level at arbitrary position?
This cannot be done and you certainly cannot make any gameplay-related decisions on it.
In the worst case scenario, your game runs on a server and the display is managed by an external client, in which case the playsim has no info whatsoever about the rendering settings of that client and thus cannot make any decisions based on it.
Even if you got access to the display, you run the risk of demo desyncs when being played back on different display settings, even on the same machine.
In the worst case scenario, your game runs on a server and the display is managed by an external client, in which case the playsim has no info whatsoever about the rendering settings of that client and thus cannot make any decisions based on it.
Even if you got access to the display, you run the risk of demo desyncs when being played back on different display settings, even on the same machine.
-
- Posts: 1339
- Joined: Tue Jul 15, 2003 4:18 pm
Re: Get effective light level at arbitrary position?
That makes sense... So I guess the way that I'm doing things now is probably the best way to keep things on the playsim side and future-proof.
Thanks!
Thanks!
-
-
- Posts: 3159
- Joined: Sat May 28, 2016 1:01 pm
Re: Get effective light level at arbitrary position?
The exposure texture is a 1x1 texture holding the average luminance value. It is a texture to keep the calculations entirely on the GPU. That is, the CPU part of GZDoom doesn't even know what the current exposure is.Pixel Eater wrote:Would the Exposure Texture used by the tonemap shaders have that info embedded? I've been meaning to request that access be given to it...
I might even remove this from the tonemap shaders as I'm not even sure if scaling the light like this is correct/looks-good. I suspect it would look better if only the bloom pass used the exposure texture.
-
-
- Posts: 667
- Joined: Wed Aug 02, 2017 12:31 am
- Location: In between the Moon and you, between the buried and me.
Re: Get effective light level at arbitrary position?
Would taking it out of the tonemaps mean they no longer smoothly transition though? I started making one and it just jumped around in brightness based on the center pixel.I might even remove this from the tonemap shaders as I'm not even sure if scaling the light like this is correct/looks-good.
The reason I was interested in accessing the Exposure Texture was to bring an approximate sector lighting back into the liquid textures in Mirror Mire. Though I don't know if it would be blinded by the hidden green texture or just create a feedback loop with itself

-
-
- Posts: 3159
- Joined: Sat May 28, 2016 1:01 pm
Re: Get effective light level at arbitrary position?
Using the center pixel is way too unreliable. The exposure value is actually a smoothed value between the average brightness of the entire screen over multiple frames. I’m not too keen on giving you access to it because it would lock the GL renderer into its current exposure implementation. More or less same reason why you can’t access the depth, normal or stencil buffers.
-
-
- Posts: 667
- Joined: Wed Aug 02, 2017 12:31 am
- Location: In between the Moon and you, between the buried and me.
Re: Get effective light level at arbitrary position?
No worries, thanks dpJudas. You're as informative as ever
I think I now have a workaround that gets the effect I want by shaping the existing tonemaps and also has a nice impact on bloom. Mirror Mire however needs a lot of work anyway and I'm just not into that one right now.

I think I now have a workaround that gets the effect I want by shaping the existing tonemaps and also has a nice impact on bloom. Mirror Mire however needs a lot of work anyway and I'm just not into that one right now.