Skip to content
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

Jitter shadow rotation every frame when temporal antialiasing is enabled to improve shadow quality #4632

Open
mrjustaguy opened this issue Jun 7, 2022 · 1 comment

Comments

@mrjustaguy
Copy link

mrjustaguy commented Jun 7, 2022

Describe the project you are working on

Open World Game

Describe the problem or limitation you are having in your project

Directional Shadows Suffer from Pixelization (when insufficient Softness is used, by which is decreased automatically in later splits) and lack detail and stability (because of insufficient Shadow map resolution)

Describe the feature / enhancement and how it helps to overcome the problem or limitation

The Idea is simple, every frame, ever so slightly change the Directional Shadow (by doing things like rolling, which is implemented in MRP) and potentially jittering the Shadow Maps to further improve resolution.
This Rotation reduces pixelization because the rotation changes how the Pixel squares are projected onto a surface and they become circular in appearance (for the same sample of course), while also rolling the Shadow Map changes which points are sampled in the Shadow Map resulting in an increase in the effective Shadow Resolution, further reducing Pixelization.

Describe how your proposal will work, with code, pseudo-code, mock-ups, and/or diagrams

Proof of Concept Implementation to toy around with below
TAASU.zip

Further Implementation Details (Random Rotations or uniform Rotations, rotation step, and so many other factors) still have to be determined for the best results and depend heavily on the TAA implementation (godotengine/godot#61319)

If this enhancement will not be used often, can it be worked around with a few lines of script?

Yes, it can be worked around

Is there a reason why this should be core and not an add-on in the asset library?

This uses TAA to Improve Shadow Rendering Quality for free (in cases where the shadow map is updated every frame anyway, which is often the case)

@Calinou
Copy link
Member

Calinou commented Jun 7, 2022

Related to #4179.

Note that doing so will require invalidating the shadow cache every frame. This means that if you previously had opportunities to cache shadow rendering, then you will miss out on those opportunities, therefore increasing the rendering cost significantly.

However, if the shadow map was already invalidated every frame (which is common for directional shadows due to animated characters), then rotating the shadow every frame will probably not affect performance. That said, better shadow caching is something we should look into in the future (i.e. rendering static shadows and dynamic shadows on separate layers). In this case, only the dynamic layer would be re-rendered every frame if you weren't rotating the shadow every frame. This optimization is not possible if you rotate the shadow every frame though.

As a workaround, you can attach this script to any node that extends from Light3D:

extends Light3D

func _process(_delta: float) -> void:
	rotate_object_local(Vector3.FORWARD, randf_range(-PI, PI))

@Calinou Calinou changed the title Use TAA to Improve Shadow Quality Jitter shadow rotation every frame when temporal antialiasing is enabled to improve shadow quality Jun 7, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants