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

Shaders: Perform equivalent frustum test in getPointShadow() like in getShadow(). #27922

Merged
merged 1 commit into from
Mar 15, 2024

Conversation

Mugen87
Copy link
Collaborator

@Mugen87 Mugen87 commented Mar 15, 2024

Fixed #27916.

Description

This PR makes the shadow mask computed by getPointShadow() more consistent to getShadow() by performing a similar frustum test based on the near/far value of the shadow camera and the fragment's distance to the shadow's camera position.

Copy link

📦 Bundle size

Full ESM build, minified and gzipped.

Filesize dev Filesize PR Diff
669.8 kB (166.1 kB) 670 kB (166.2 kB) +272 B

🌳 Bundle size after tree-shaking

Minimal build including a renderer, camera, empty scene, and dependencies.

Filesize dev Filesize PR Diff
450 kB (108.8 kB) 450.3 kB (108.8 kB) +272 B
@Mugen87 Mugen87 marked this pull request as ready for review March 15, 2024 09:48
@Mugen87 Mugen87 added this to the r163 milestone Mar 15, 2024
// dp = normalized distance from light to fragment position
float dp = ( length( lightToPosition ) - shadowCameraNear ) / ( shadowCameraFar - shadowCameraNear ); // need to clamp?
dp += shadowBias;
if ( lightToPositionLength - shadowCameraFar <= 0.0 && lightToPositionLength - shadowCameraNear >= 0.0 ) {
Copy link
Contributor

@LeviPesin LeviPesin Mar 15, 2024

Choose a reason for hiding this comment

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

Wouldn't it be simpler to just check whether dp >= 0.0 && dp <= 1.0?

@Mugen87 Mugen87 merged commit 91bfd82 into mrdoob:dev Mar 15, 2024
12 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
2 participants