Looking at DIB-R: https://research.nvidia.com/labs/toronto-ai/DIB-R/files/diff_shader.pdf, which this library seems to have a similar implementation, when calculating the derivative of pixel color with respect to vertex position, the derivatives of barycentric coordinates are computed to get smooth gradients (for foreground pixels). This library appears to be doing something similar, but does not do this for the depth calculation.
In the case that I'm optimizing only a depth map (I don't care about texture, and shading), I saw that the HardDepthShader just takes the zbuffer from OpenGL (essentially from the shader). It does not compute the depth from the barycentric coordinates of a face (it could because the depth of each vertex can be known from the camera parameters).
This means that the gradient of the image color with respect to vertex position seems incorrect, or at least computed differently. I expected the derivative dDepth/dVertexPos to always be 0. However, I have to admit that I am not getting this in my code, which is unexpected. I would like to know whether or not the depthmap gradient is computed like I understand.
Unexpected behavior
Looking at DIB-R: https://research.nvidia.com/labs/toronto-ai/DIB-R/files/diff_shader.pdf, which this library seems to have a similar implementation, when calculating the derivative of pixel color with respect to vertex position, the derivatives of barycentric coordinates are computed to get smooth gradients (for foreground pixels). This library appears to be doing something similar, but does not do this for the depth calculation.
In the case that I'm optimizing only a depth map (I don't care about texture, and shading), I saw that the HardDepthShader just takes the zbuffer from OpenGL (essentially from the shader). It does not compute the depth from the barycentric coordinates of a face (it could because the depth of each vertex can be known from the camera parameters).
This means that the gradient of the image color with respect to vertex position seems incorrect, or at least computed differently. I expected the derivative dDepth/dVertexPos to always be 0. However, I have to admit that I am not getting this in my code, which is unexpected. I would like to know whether or not the depthmap gradient is computed like I understand.