-
Notifications
You must be signed in to change notification settings - Fork 858
Shadow Performance Improvements #3830
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
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good overall
| float lightRadiusSq = light.boundingSphere.radius * light.boundingSphere.radius; | ||
| float projectedRadiusSq = m_ProjectedBoundingSphere.radius * m_ProjectedBoundingSphere.radius; | ||
|
|
||
| return distanceSq <= (lightRadiusSq + projectedRadiusSq); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is this correct? I guess a^2 <= b^2 + c^2 is not the same as a <= b+c
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good catch
|
|
||
| private static Material GetProjectedShadowMaterial(this Renderer2DData rendererData, int colorMask) | ||
| { | ||
| //if (rendererData.projectedShadowMaterial == null || rendererData.projectedShadowShader != rendererData.projectedShadowMaterial.shader) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just double checking, do we want to create a new one every time the method is called? If so, maybe renaming to CreateProjectedShadowMaterial could make sense?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed
| private static Material GetStencilOnlyShadowMaterial(this Renderer2DData rendererData, int colorMask) | ||
| { | ||
| //if (rendererData.stencilOnlyShadowMaterial == null || rendererData.projectedShadowShader != rendererData.stencilOnlyShadowMaterial.shader) | ||
| { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
See GetProjectedShadowMaterial comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed
| private static Material GetSpriteSelfShadowMaterial(this Renderer2DData rendererData, int colorMask) | ||
| { | ||
| //if (rendererData.spriteSelfShadowMaterial == null || rendererData.spriteShadowShader != rendererData.spriteSelfShadowMaterial.shader) | ||
| { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
See GetProjectedShadowMaterial comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed
| private static Material GetSpriteUnshadowMaterial(this Renderer2DData rendererData, int colorMask) | ||
| { | ||
| //if (rendererData.spriteUnshadowMaterial == null || rendererData.spriteUnshadowShader != rendererData.spriteUnshadowMaterial.shader) | ||
| { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
See GetProjectedShadowMaterial comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed
|
Folks, why static meshes with baked shadows must also render to shadowmaps in order to receive shadows? Isn't this a bit pointless? What about "let any mesh receive shadows", no matter if they cast shadows or not? Could improve performance as you don't need to render all geometry reciving shadows. I have a custom renderer that sit on top of built-in that ouperforms URP by a large marge (2x - 3x easily) when there's many lights casting shadows cause none of my static geometry renders to depthmaps. |
Checklist for PR maker
CHANGELOG.mdfile.Purpose of this PR
Refactor of shadow code.
Now renders shadows to a single channel.
Prerendering of shadows can render to different channels in addition to different textures.
Added versioning
Added per light shadow culling
Made shader naming more consistent