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

Overhaul of directional PCSS shadows #7258

Merged
merged 8 commits into from
Jan 10, 2025
Merged

Conversation

mvaligursky
Copy link
Contributor

@mvaligursky mvaligursky commented Jan 10, 2025

New implementation of PCSS for directional light:

  • visually much more pleasing compared to the existing implementation
  • option to skip the shadow blocker for larger constant size PCF shadow
  • variable number of samples for both blockers as well as shadow filtering

New public API

// control of the contact hardening rate
LightComponent.penumbraFalloff   // in addition to existing penumbraSize

// cost vs quality controls
LightComponent.shadowSamples   // number of samples of PCF filter, range 1 - ∞
LightComponent.shadowBlockerSamples // number of samples to determine contact hardening, 0 - ∞.
// 0 disables contact hardening and constant penumbraSize is used

GPU Performance at 4K on Apple M1 Pro:
PCF3: 5.0ms
PCSS: 6.3ms // basic quality: blocker samples 8, PCF samples 12
PCSS: 9.1ms // high quality: blocker samples 28, PCF samples 42
PCSS: 6.7ms // medium quality, no contact hardening: blocker samples 0, PCF samples 16
PCSS: 9.7ms // extreme quality: blocker samples 32, PCF samples 64

PCF3
Screenshot 2025-01-10 at 11 51 55

PCSS basic
Screenshot 2025-01-10 at 11 51 44

PCSS high
Screenshot 2025-01-10 at 11 52 47

PCSS no contact hardening
Screenshot 2025-01-10 at 11 56 05

PCSS extreme
Screenshot 2025-01-10 at 12 07 36

src/framework/components/light/component.js Outdated Show resolved Hide resolved
src/framework/components/light/component.js Outdated Show resolved Hide resolved
src/framework/components/light/component.js Outdated Show resolved Hide resolved
src/framework/components/light/component.js Outdated Show resolved Hide resolved
@willeastcott
Copy link
Contributor

I notice that when a cloud's shadow passes over a tree's shadow, the tree's shadow kinda looks like it's overwritten rather than the cloud's shadow only darkening the terrain. Is there any way around that?

@mvaligursky
Copy link
Contributor Author

I notice that when a cloud's shadow passes over a tree's shadow, the tree's shadow kinda looks like it's overwritten rather than the cloud's shadow only darkening the terrain. Is there any way around that?

Not using PCSS, similarly to VSM, it does not correctly handle overlapping casters at various distances.
Raytraced shadow is a solution.

Copy link
Contributor

@willeastcott willeastcott left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Very cool.

src/framework/components/light/component.js Show resolved Hide resolved
src/framework/components/light/component.js Show resolved Hide resolved
@mvaligursky mvaligursky merged commit d5d7cf5 into main Jan 10, 2025
7 checks passed
@mvaligursky mvaligursky deleted the mv-directional-soft-shadows branch January 10, 2025 16:57
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area: graphics Graphics related issue feature
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants