NVlabs / nvdiffrast

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

How to improve the efficiency of antialiasing? #84

Closed raywzy closed 1 year ago

raywzy commented 2 years ago

Thanks for the great work!

After testing, I found that current antialiasing step is slower than the rasterization (pytorch framework). Do we have any methods to further improve its efficiency?

s-laine commented 2 years ago

It's difficult to answer this without knowing about the use case you have. However, the performance of the op depends heavily on the number of silhouette pixels in the image, and one possible cause for low performance is that nvdiffrast thinks there are more silhouette pixels than there actually are.

If the antialiasing op seems slower than it should be, make sure that each logical vertex is referred to using the same vertex id in your triangle buffer. This lets nvdiffrast see which edges are joining two triangles and which are connected to just one triangle. If you duplicate the vertices so that each triangle uses unique vertex ids, every edge in the mesh will look like a silhouette edge to nvdiffrast, and there will be a lot of bogus silhouette pixels which decreases the performance.

s-laine commented 1 year ago

I added this information to the documentation of antialias() op. Thanks for bringing this up -- in hindsight this is an obvious pitfall and needs to be documented.