NVlabs / nvdiffrast

Nvdiffrast - Modular Primitives for High-Performance Differentiable Rendering
Other
1.31k stars 139 forks source link

NDC Convention #44

Closed wpalfi closed 2 years ago

wpalfi commented 2 years ago

In https://nvlabs.github.io/nvdiffrast/#coordinate-systems, you say that you follow OpenGL conventions.

I am confused.

s-laine commented 2 years ago

Thanks for pointing this out - the documentation is indeed confusing view space, clip space and NDC.

Conventional OpenGL perspective projection matrix, as implemented in glFrustum(), expects that view-space z increases towards the viewer, which is what the documentation is trying to say. But after multiplication by projection matrix, z/w increases away from the viewer, and thus NDC z points into the screen, as you say. I'll have to update the documentation to fix this. The implementation follows OpenGL conventions, though, so that part is correct.

Regarding the y axis flip in the examples' projection matrices, I guess the goal was to make it so that when writing the rendered images on disk we don't have to flip them vertically. I'll go ahead and tidy that up too in the next release, as there's no reason for the examples to take ugly shortcuts like that.

s-laine commented 2 years ago

Both issues are addressed in v0.2.7, closing.