-
Notifications
You must be signed in to change notification settings - Fork 1.4k
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
Address PCSS softness #5483
Open
GSterbrant
wants to merge
3
commits into
main
Choose a base branch
from
gsterbrant-pcss-fixes
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Address PCSS softness #5483
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Directional lights can't really normalize the depth difference range because they have no position, so effectively this range becomes gigantic with regards to the distance between the light source and blocker. To fix this, we simply use a defined value to define the normalization value for directional lights, and saturate to avoid oversampling the shadow area.
|
||
const cameraParams = directional._shadowCameraParams; | ||
cameraParams.length = 4; | ||
cameraParams[0] = lightRenderData.depthRangeCompensation; | ||
cameraParams[0] = 3.0; // unused |
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.
@mvaligursky Need to figure out what to do here, presumably. 😄
|
||
float blockers = 0.0; | ||
float averageBlocker = 0.0; | ||
//float radius = searchSize * ( z - ) |
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.
Delete commented out code.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
After reviewing the PCSS algorithm some more, I came to the conclusion that the reason why directional lights don't get a nice hardening effect is due to the normalization factor, usually the average of the blocker distances, is too large. This makes sense for directional lights seeing as the average blocker distance essentially becomes the distance between the light origin, which for directional lights is indeed very big, and the blocker, resulting in the normalization of receiver/blocker becoming very small indeed.
To fix this, we first need to output depth in linear space, which this PR reimplements for PCSS. Then, we need a normalization factor for directional lights which is right now hard coded to be 3 meters. This factor should be provided as a parameter to the light somehow.
This is the result: