Add EXPOSURE built in to spatial shaders #71364
Merged
+9
−1
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This allows users to restore light values to pre-prebaked-exposure amounts
Fixes: #69847
Supersedes: #71304
When using Physical Light Units or
exposure_multiplier
in aCameraAttributes***
resource all light sources are pre-baked by the exposure amounts in theCameraAttributes
. This ensures that the screen texture values stay within a manageable range.A side-effect of this pre-baking is that SCREEN_TEXTURE returns the post-pre-baked exposure amount. I.e. the final brightness after applying exposure from CameraAttributes, but before applying exposure from the tonemapper. If this value is fed back in as an ALBEDO, everything works fine because ALBEDO expects a non exposed color. However, if you feed the SCREEN_TEXTURE result in EMISSION, it appears black because EMISSION is in physical light units, so it expects un-pre-baked exposed values (it will apply the pre-baked exposure internally after the user shader has ended). The end result is that we can either have SCREEN_TEXTURE properly exposed for ALBEDO (including baked exposure) or for EMISSION (including baked exposure).
#71304 falls short as all it does is revert the default so that SCREEN_TEXTURE works for EMISSION, but not for ALBEDO (i.e. it returns the un-pre-baked exposure value).
This PR exposes an
EXPOSURE
(open to alternative naming suggestions) builtin to spatial shaders that allows us to account for the pre-baked exposure. Simply multiplyingEXPOSURE
by values that already have the exposure baked in will undo the pre-baked exposure and return the original value. For example, multiplying this by a light's energy will give the original energy before pre-baking the CameraAttributes exposure. Or alternatively, multiplying by the result of SCREEN_TEXTURE will give you what the screen texture pixel would have been if the pre-baking had not been applied.Tagging as 4.x as there is no rush on this. It is a pain for people using Physical Light units, but this is an addition to the shader API so I would also like more time for this to be tested and discussed, accordingly, I would prefer to merge after 4.0 stable release.