-
Notifications
You must be signed in to change notification settings - Fork 1.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add per-prim depth bias #1590
base: dev
Are you sure you want to change the base?
Add per-prim depth bias #1590
Conversation
The depth bias is useful to address z-fighting between 2 overlapping gprims. A common example is mesh decal. In a CAD sketch, there can be a lot of co-planar and overlapping objects. The depth bias is specified in different ways in different renderers. Unity exposes 2 glPolygonOffset parameters in shader. https://docs.unity3d.com/2021.2/Documentation/Manual/SL-Offset.html Unreal allows to add a world offset towards camera. https://docs.unrealengine.com/4.26/en-US/WorkingWithContent/MeshDecals/ USD allows to set the glPolygonOffset parameters in a render pass. It could be more flexible to specify a bias for each prim. Just like displayColor and displayOpacity, propose to add a new builtin primvar "primvars:depthPriority". The value is not real bias so the name is "priority" instead of "bias". e.g. A gprim with primvars:depthPriority=[1] will win the same gprim with primvars:depthPriority=[0] in depth test in GL renderer. The depth priority is passed to renderer in the same way as other builtin primvars. Then, Storm biases the vertex toward the camera. Similar to the "units" parameter in glPolygonOffset function. The bias is small and only meaningful for perfectly overlapping gprims.
Filed as internal issue #USD-6830 |
Thank you, @xum-adsk . We are still gathering our thoughts on how to guide you, here, but one thing that might help is if you can explain in more detail the expected situations (and intentions of the process and data) arising from CAD sketches? Is there any similarity to Blender's "grease pencil drawings" , or is it a more general modeling pattern that needs to be handled more gracefully? Cheers, |
Thank you @spiffmon . This is expected to address the z-fighting artifacts caused by overlapping meshes. It's a little different from grease pencil, the sketch consists of meshes.
|
Thank you, @xum-adsk . I understand the mesh decal problem. The questions I have about the cad sketch are:
|
That's great, @xum-adsk, and provides more confidence for the following suggestions. Firstly, with regards to the current PR as-is, we generally try not to canonize in the core properties or behaviors that are specific to a particular renderer or class of renderers, and we don't think that the depth bias, as specced, would be useful for path-tracers. But more importantly, you have called attention to two constructs (mesh decals and 2D, layered drawings) that seem ripe for describing in USD for interchange. Mesh decals are supported in at least three packages. I am unsure exactly how similar or feature-overlapping Blender's grease pencil tool is with CAD sketches, but they surely share the same basic property of using 2D projections of 3D primitives (I state it that way as a challenge to see if it could safely be formulated that way to leverage USD's existing 3D primitives, rather than encoded in terms of 2D primitives) that are ordered to create a layered drawing. A depth bias, even if sufficient for some renderers to draw these constructs successfully, would not allow them to interchange, or even round-trip, since the semantics is not represented. So I think what we'd encourage is to figure out how to encode these concepts as USD schemas (which may involve discussions with interested parties from other toolmakers), along with usdImaging adapters, and rendering for at least Storm. That may be more than you were planning on biting off here, but it also has a much bigger payoff. |
Thanks @spiffmon we are reviewing our options internally, and will get back to you asap. |
Description of Change(s)
This change is a proposal for issue #1548
The depth bias is useful to address z-fighting between 2 overlapping
gprims. A common example is mesh decal. In a CAD sketch, there can be
a lot of co-planar and overlapping objects.
The depth bias is specified in different ways in different renderers.
Unity exposes 2 glPolygonOffset parameters in shader.
https://docs.unity3d.com/2021.2/Documentation/Manual/SL-Offset.html
Unreal allows to add a world offset towards camera.
https://docs.unrealengine.com/4.26/en-US/WorkingWithContent/MeshDecals/
USD allows to set the glPolygonOffset parameters in a render pass. It
could be more flexible to specify a bias for each prim.
Just like displayColor and displayOpacity, propose to add a new builtin
primvar "primvars:depthPriority". The value is not real bias so the
name is "priority" instead of "bias".
e.g.
A gprim with primvars:depthPriority=[1] will win the same gprim with
primvars:depthPriority=[0] in depth test in GL renderer.
The depth priority is passed to renderer in the same way as other builtin
primvars. Then, Storm biases the vertex toward the camera. Similar to
the "units" parameter in glPolygonOffset function. The bias is small and
only meaningful for perfectly overlapping gprims.
Fixes Issue(s)