TheRealMJP / DeferredTexturing

A rendering sample that demonstrates bindless deferred texturing using D3D12
MIT License
503 stars 46 forks source link

Question about PositionFromDepth #18

Closed omd24 closed 8 months ago

omd24 commented 8 months ago

Would you please explain why we need to linearize depth when reconstructing the world position from depth value? Isn't the depth value after homogenous divide (and consequently the value stored in and read from depth buffer) nonlinear and therefore, shouldn't the reverse operation (i.e., going from NDC to world space) use that nonlinear depth value?

For the context, I'm asking about PositionFromDepth in Deferred.hlsl.

TheRealMJP commented 8 months ago

Hey there! That line to calculate linearDepth actually looks like it's just a leftover from some earlier code that I neglected to delete. If you look you'll see it's not actually used in that function, only zw is in the way that you described. Sorry about that!

omd24 commented 8 months ago

Oops! 😅 Sorry for overlooking that, but thanks for clarifying!