Skip to content
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

per-prim depth bias ? #1548

Open
xum-adsk opened this issue Jun 28, 2021 · 3 comments
Open

per-prim depth bias ? #1548

xum-adsk opened this issue Jun 28, 2021 · 3 comments

Comments

@xum-adsk
Copy link

Description of Issue

USD allows depth bias in a single pass. Is there any chance to apply depth bias to a single prim?
A use case is to apply mesh decals to surfaces. The decal and the surface are co-planar. The decal needs to win depth test if both are drawn together in a single pass.
Unity allows to add "Offset Factor, Units" to a shader. Unreal allows to apply a custom offset along camera direction. Any chance in USD to support similar feature?
Unity: https://docs.unity3d.com/2021.2/Documentation/Manual/SL-Offset.html
Unreal: https://docs.unrealengine.com/4.26/en-US/WorkingWithContent/MeshDecals/

Steps to Reproduce

  1. Create 2 coplanar meshes.
  2. z-fighting.

System Information (OS, Hardware)

Windows 10, MSVC 2019

Package Versions

v21.05

Build Flags

N/A (default)

@xum-adsk
Copy link
Author

Actually, Storm already adds an epsilon to Peye.z to the selection. It's a little different from the second "units" parameter of glPolygonOffset. glPolygonOffset adds after projection. But they are similar.
Is there any chance to extend this to each prim? For example, a bulitin primvar similar to displayColor and displayOpacity. Or get it from the material if there is one. Then, modify gl_Position.z in the vertex shader.
https://github.com/PixarAnimationStudios/USD/blob/090ef0d849ced875b3b99a15e454b69148ccd8e1/pxr/imaging/hdx/shaders/selection.glslfx#L401-L408

@jilliene
Copy link

jilliene commented Jul 7, 2021

Filed as internal issue #USD-6775

@xum-adsk
Copy link
Author

xum-adsk commented Jul 8, 2021

Thank you! I am applying CLA. Hopefully I can contribute later.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants