NVlabs / nvdiffrast

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

rasterize output zero #93

Closed jiaxiangshang closed 1 year ago

jiaxiangshang commented 1 year ago

When I use the dr.rasterize, the elements in output self.rastUV_out are all zero. self.rastUV_out, self.rastUV_out_db = dr.rasterize(self.glctx, uv_pad.expand(batch_size, uv_pad.shape[1], uv_pad.shape[2]).contiguous(), uv_tri, resolution=[siez_tex, siez_tex], ranges=None)

I first carefully check the pos input, which should be the ndc vertex, it seems right. [[ 0.6557, 0.0871, 0.0000, 1.0000]

I also check the tri input, the triangle is valid

The cpp code is a little difficult for me to debug, can you give some suggestions?

Best Jiaxiang

s-laine commented 1 year ago

This could be a number of things. Are you using Windows or Linux, and are you using the most recent version of nvdiffrast? The Windows OpenGL rasterizer used to have a bug that caused the first rendered buffer to be blank sometimes (issue #59). This was fixed a while ago, but maybe the fix doesn't work properly.

You can try using the Cuda-based rasterizer (use RasterizeCudaContext instead of RasterizeGLContext) that is included in the newest release. This should tell if the problem is on the OpenGL side or in your input data.

I can take a look at the problem as well, but I would need a complete piece of code that reproduces the issue.

jiaxiangshang commented 1 year ago

Hi, Samuli ,

Thank you for your quick reply and suggestions.

I use ubuntu server. I will try the newest version, but I still put the code and data here, maybe you can help me locate the bug.

Thanks again for your kind help.

Best Jiaxiang server.zip

s-laine commented 1 year ago

The rasterizer produces valid output for me in your test case, so it looks like there is something wrong with your setup.

Note that you should not create a new rasterizer context (RasterizeGLContext or RasterizeCudaContext) at every call to the rasterizer. This is an expensive operation and you should do it only once, and then use the same context for all calls to the rasterizer.

jiaxiangshang commented 1 year ago

Hi, Samuli

Thank you very much for your help, I will re-install the nvidiffraster, and I will create the rasterizer only one time,

Best Jiaxiang