Hello, I’ve been studying the Parallax Occlusion Mapping Material from the Content Examples project. I’ve managed to understand most of it, but the Pixel Depth Offset calculation is still very mysterious to me. I’m pasting a screenshot of the part of the Material Graph which I’m referencing here. I have cleaned up the original Graph a little, for more readability.
I do understand that the POM result refers to the UV offset which is supposed to be applied to the pixel, and the B component is the depth in tangent space. What I don’t understand is all that math involving DDX and DDY of World Position and UV and its connection to the POM result. Why are the “Divide” nodes there?
Any help on this would be greatly appreciated!
DDX and DDY are “screen space derivatives”. Derivatives referring to the calculus definition, which is a measure of instantaneous rate of change. DDX measures the rate of change in a value on screen in the X axis and DDY does the same in the screens Y axis.
When applied to a coordinate system, such as UVs or World coordinates, you can figure out things like how far away it is and its slope. For this reason, it’s most commonly used for mipmapping.
They are dividing them because they need this expresses as a ratio. As to why they want this ratio, I haven’t really looked into the innards of the POM, so I’m not sure exactly what part it plays. But…
I think PDO expects the depth to be in view space not tangent space, so this is probably some way of modulating the parallax amount into a view relative depth.
The camera vector stuff is to fix distortion created by FoV.