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

Address PCSS softness #5483

Open
wants to merge 3 commits into
base: main
Choose a base branch
from
Open

Address PCSS softness #5483

wants to merge 3 commits into from

Conversation

GSterbrant
Copy link
Contributor

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:
image

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.
@GSterbrant GSterbrant added bug area: graphics Graphics related issue labels Jul 14, 2023
@GSterbrant GSterbrant self-assigned this Jul 14, 2023

const cameraParams = directional._shadowCameraParams;
cameraParams.length = 4;
cameraParams[0] = lightRenderData.depthRangeCompensation;
cameraParams[0] = 3.0; // unused
Copy link
Contributor

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 - )
Copy link
Contributor

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
Labels
area: graphics Graphics related issue bug
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants