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

Improve Directional Shadow Auto LOD #4479

Closed
mrjustaguy opened this issue May 2, 2022 · 7 comments
Closed

Improve Directional Shadow Auto LOD #4479

mrjustaguy opened this issue May 2, 2022 · 7 comments

Comments

@mrjustaguy
Copy link

mrjustaguy commented May 2, 2022

Describe the project you are working on

Open World Game

Describe the problem or limitation you are having in your project

Directional Shadows currently Use the same Auto LOD level as the Player Camera, even for Meshes set to Shadows Only

This has Two Problems:

  1. If the Shadow Caster is Very far from the Camera, but the Camera is Very Close to it's Shadow, the Shadow LOD will be very low, Resulting in horrible Shadows, and Shadow Popping as you move to/away from the Shadow Caster
  2. If the Shadow Caster is Very close to the Camera, the Shadow will use High Quality LODs, even if the resolution of the Shadow map is relatively low, thus wasting a ton of performance

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

Directional Shadows Render in Orthogonal Perspective, as such, using the LOD quality as determined by the Directional Shadow's Orthogonal View are going to be the best suited to Minimize Shadow Processing required and Maximize Shadow Quality and Consistency

  1. LODs are set to their ideal values for a given Split, and thus, this scenario cannot exist any longer
  2. LODs are set to their ideal values for a given Split, meaning it's using LODs based on the actual Resolution of the Shadow map, which often means significantly lower LODs required for the same result, as Shadow Resolution generally isn't really that high, and Meshes only occupy a tiny portion of the Shadow map.

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

Treat Directional Shadows as Orthogonal Cameras in ALOD logic.
For Each Split Determine ALOD Shadow LOD (same logic as Orthogonal Cameras use)

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

No, as ALOD is not exposed to the user.

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

ALOD and Directional Shadows are core.

@Calinou
Copy link
Member

Calinou commented May 2, 2022

Related to #2600.

@mrjustaguy
Copy link
Author

Simplified Proposal, as the Added logic would both add complexity, and would not be very useful, as it'd partly keep a part of the issue this Proposal is aiming at dealing with, due to still partially tying the Shadow LOD with the Player Camera

@clayjohn
Copy link
Member

There are two things to consider when choosing LODs for shadows:

  1. The resolution of the shadow map (as you point out here). This is important so you aren't wasting time on detailed meshes when the underlying resolution is low
  2. You want the mesh to line up with the mesh being rendered. Using a different LOD is a recipe for shadow acne on the mesh itself.

Using a different LOD between the shadow mesh and the rendered mesh can lead to bad shadow acne issues. I beleive our LODs are designed to never have a larger outline than the base mesh, so as long as shadow LOD's are kept equal to or higher than the mesh being rendered, we should be able to tweak them.

Adjusting automatically based on the resolution of the shadow map makes sense to me. So does having a shadow_lod_bias parameter so users can choose to sacrifice some quality if they want.

@mrjustaguy
Copy link
Author

#4517 deals really, REALLY well with low LODs, so changing the default pipeline to this method of rendering (which you can actually do right now, it's just not default)

I've been able to go super aggressive on cutting Polygon counts for the Shadow Meshes, and with Manually created LODs I've managed to cut 90% of the Triangles in the Shadow Rendering Pipeline for virtually the exact same shadow..

Now ALOD isn't as efficient as the Method I've used and of worse quality, but with the inverted shadow rendering, it's much less likely to glitch shadows in any way.

@mrjustaguy
Copy link
Author

mrjustaguy commented May 13, 2022

Potentially we could actually make an option of how ALOD works for Shadows, based on camera distance or based on what the Shadows detect (aka this proposal) and have that be a Project Setting..

It'd have the side benefit of allowing for easy side by side comparisons of the two methods, and would allow for a fall back to the old ways should there be an edge case with this method, much like there are edge cases with the current method.

@mrjustaguy
Copy link
Author

Was this implemented in beta 6? it seems like Directional Shadow LODs now do follow the splits in their LOD choices...

@mrjustaguy
Copy link
Author

Closing as this seems to be in effect already, not to mention godotengine/godot#76291 significantly improves shadow performance by only rendering 2 splits at a time, making the impact of wasteful shadow geometry much less significant, especially should the triangle processing regression (godotengine/godot#68959) be successfully resolved.

@Calinou Calinou closed this as not planned Won't fix, can't repro, duplicate, stale Apr 28, 2023
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

3 participants