NVlabs / nvdiffrast

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

Support for conservative rasterization? #106

Closed Jerrypiglet closed 1 year ago

Jerrypiglet commented 1 year ago

Hi there, thanks for the great work! Just checking to see if conservative rasterization is supported by the current APIs? Seeing something related in the C files but I am not sure whether there is a Python API for this end.

Thanks!

s-laine commented 1 year ago

There is no support for conservative rasterization, and I'm not sure the concept would even be compatible with differentiable rendering. The function is a leftover from an earlier version of the rasterizer that supported supersampling, and not currently utilized in any way.

Jerrypiglet commented 1 year ago

hey @s-laine thanks a lot for the explanation! I was bringing this up because I was observing some issues when I use the nvdiffrast.rasterize function to generate uv maps from a mesh with uv indices. I posted a comment here regarding the issue, which I thought will be resolved with conservative rasterization. I wonder if you have any ideas about this? Not sure if the issue was with the way I was using the function, or an inherent limitation with the current implementation of it.

s-laine commented 1 year ago

Ah, this is a common issue in all kinds of texturing applications where you have the logical edge of a texture coincide with edge of your geometry. Searching for texture seams or texture atlas seams etc. gives you a lot of information on the topic.

A common solution is to somehow dilate or "pad" the texture colors into the empty areas of the texture (see example here). You need to make sure you produce a wide enough border to cover the width of the prefilter that is used when fetching from the texture, i.e., that your mipmaps have enough border as well.

In practice, I think you need at least one pixel worth of extra border at every mip level you use during rendering. Conservative rasterization would not be enough even for the base texture.