Improvements to parallax mapping code for comprehensibility and correctness#1
Merged
nicopap merged 2 commits intonicopap:pbr-parallax-mappingfrom Apr 10, 2023
Conversation
superdump
commented
Apr 10, 2023
- 'height' -> 'depth' as the texture has 0 as minimum depth and 1 as maximum depth.
- Make the Vt used in parallax mapping point from the camera to the fragment to make the algorithm easier to understand as the ray points into the surface. Adjust the UV maths as appropriate to step forward instead of backward.
- Parallax depth -> parallax depth scale to make it clearer that this scales the parallax depth effect.
…ctness 'height' -> 'depth' as the texture has 0 as minimum depth and 1 as maximum depth. Make the Vt used in parallax mapping point from the camera to the fragment to make the algorithm easier to understand as the ray points into the surface. Adjust the UV maths as appropriate to step forward instead of backward.
nicopap
reviewed
Apr 10, 2023
| let layer_height = 1.0 / layer_count; | ||
| var delta_uv = depth * V.xy / V.z / layer_count; | ||
| let layer_depth = 1.0 / layer_count; | ||
| var delta_uv = depth_scale * layer_depth * Vt.xy * vec2(1.0, -1.0) / view_steepness; |
Owner
There was a problem hiding this comment.
Multiplying this by vec2(1.0, -1.0) is very surprising. I understand it's to avoid the -B, but in this case I think it should be explained. I know it's necessary, but I don't understand why.
This file contains hidden or 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
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.