facebookresearch / pytorch3d

PyTorch3D is FAIR's library of reusable components for deep learning with 3D data
https://pytorch3d.org/
Other
8.68k stars 1.3k forks source link

Unintended Grid-Like Shadows with SoftPhongShader #1599

Open wrk226 opened 1 year ago

wrk226 commented 1 year ago

I am currently trying to render a mesh model that does not have a texture. For rendering, I have simply set a gray color for texturesVertex by texture = TexturesVertex(verts_features=torch.ones(1, vertices.shape[0], 3, device='cuda')/2). However, I have encountered an issue that is causing me some confusion. When I use SoftPhongShader for rendering, I find that the result has a noticeable grid-like shadow pattern. However, this issue does not occur when I use HardPhongShader.

I would like to understand if this is an expected outcome or if there's something I might be doing wrong. Personally, I believe the SoftPhongShader should not produce such distinct grid boundaries. I've attached an illustrative image below for your reference.

In order to help diagnose this issue, I am also attaching my code at the end of this post.

Thank you for your time and I look forward to your response.

code.zip

bottler commented 1 year ago

I think this might be a correct effect: the rendering with SoftPhongShader is a bit transparent and there may be faces behind. Can you try with different values of sigma and gamma in the BlendParams, and with different values or faces_per_pixel in the RasterizationSettings?