-
-
Notifications
You must be signed in to change notification settings - Fork 21.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Implement shadowmask for DirectionalLight in BakedLightmap #51330
Conversation
ada2e20
to
6e32334
Compare
I've tried to get the denoiser working again, but I didn't succeed yet. Feel free to take a look at the diff and point out at anything that may be wrong 🙂 The goal is to preserve the final image's alpha channel. To do so, we split the RGBA image into a RGB image that is denoised by OpenImageDenoise and an alpha-only image that is kept as-is (stored as a L8 image internally). This is required as OpenImageDenoise does not support denoising images with an alpha channel – it will be stripped upon denoising. Alternatively, we could modify the OpenImageDenoise integration to keep the alpha channel as-is in denoised images. This would make things easier if we need to denoise RGBA images elsewhere. Denoiser disabled (working)Denoiser enabled (broken) |
Not sure if you saw it but according to the docs you can make it so OIDN ignores extra channels like alpha. "Images support only the OIDN_FORMAT_FLOAT3 pixel format. Custom image layouts with extra channels (e.g. alpha channel) or other data are supported as well by specifying a non-zero pixel stride. This way, expensive image layout conversion and copying can be avoided but the extra data will be ignored by the filter." You can find the above text by searching for the word alpha. |
@NHodgesVFX Thanks a lot for the pointers! I've tried to specify various stride sizes such as |
6e32334
to
2165798
Compare
I have an idea how Alpha channel could be used to store both environment and Shadowmask data. since colors aren't clamped to 2 choices, you could have 4 different states, representing 00, 01, 10, 11 (one represents env, other shadowmask) |
2165798
to
4f1b342
Compare
Rebased and tested again (including support for asynchronous shader compilation in GLES3). |
This can be used to fade distant real-time DirectionalLight shadows with baked shadows (stored in the lightmap's alpha channel). TODO: - Restore support for baking lightmaps with HDR. - Fix the resulting lightmap when denoising is enabled.
4f1b342
to
92258eb
Compare
I have been unable to get Shadow masks to work with the artifact created today. Nevermind, Had to change Directional light Bake mode from all. |
71cb8d3
to
c58391c
Compare
This comment was marked as off-topic.
This comment was marked as off-topic.
@NHodgesVFX Please don't bump issues (or pull requests) without contributing significant new information. Use the 👍 reaction button on the first post instead. |
|
This can be used to fade distant real-time DirectionalLight shadows with baked shadows (stored in the lightmap's alpha channel).
See godotengine/godot-proposals#2354 (comment) for an explanation of why I went with shadowmasking instead of subtractive shadowmapping. This implementation allows changing the DirectionalLight's color and shadow color at run-time, and does not require manual work from the user to define a hand-picked shadow color that looks good.
This closes godotengine/godot-proposals#2354.
Testing project: test_shadowmask_3.x.zip
August 2021 patch
Usage
This feature is enabled by default. It only supports 1 DirectionalLight at once. Point lights are outside the scope of shadowmasking, since the shadowmask is stored in the lightmap's alpha channel for now (and point lights' shadows don't disappear in the distance either).
If you don't want to store an alpha channel in the lightmap to decrease its file size, disable Use Shadowmask in the BakedLightmap's properties before baking. Bake times remain identical regardless of whether shadowmasking is enabled or not.
There are 3 ways to use it, depending on the target hardware:
Preview
No shadowmask (current)
without_shadowmask.mp4
With shadowmask (default for newly baked lightmaps)
with_shadowmask.mp4
TODO