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

Maths in parallax occlusion mapping shader. #369

Open
JasonPhone opened this issue Aug 15, 2023 · 0 comments
Open

Maths in parallax occlusion mapping shader. #369

JasonPhone opened this issue Aug 15, 2023 · 0 comments

Comments

@JasonPhone
Copy link

If I'm doing this right, the linear interpolation should be this:

fig

Where the blue dots represent layer depth and red dots are depth sampled from depth map. Then the interpolation is based on the similarity of these two triangles, and the maths goes to:

float weight = abs(afterDepth) / (abs(afterDepth) + abs(beforeDepth)); 

The abs is for negative lengths. But in the fragment shader it is:

float weight = afterDepth / (afterDepth - beforeDepth);

And the difference is visible:

compare

Found the same formula here. It uses the sum first and then the subtracted form as a "boiling down". I wonder if this is a simplification or error.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant