-
Notifications
You must be signed in to change notification settings - Fork 855
Better bias option for mesh decals #2690
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
Conversation
…al-mesh-view-bias
…al-mesh-view-bias # Conflicts: # com.unity.render-pipelines.high-definition/Editor/Material/UIBlocks/DecalSortingInputsUIBlock.cs # com.unity.render-pipelines.high-definition/Runtime/Material/Decal/Decal.shader # com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/ShaderPass/ShaderPassDecal.hlsl
| **Property** | **Description** | | ||
| -------------------------- | ------------------------------------------------------------ | | ||
| **Draw Order** | Controls the order in which HDRP draws decals in the Scene. HDRP draws decals with lower values first, so it draws decals with a higher draw order value on top of those with lower values. This feature works for decals projected on opaque and transparent surfaces.<br />**Note**: This property only applies to decals the [Decal Projector](Decal-Projector.md) creates and has no effect on Mesh decals. Additionally, if you have multiple Decal Materials with the same **Draw Order**, the order HDRP renders them in depends on the order you create the Materials. HDRP renders Decal Materials you create first before those you create later with the same **Draw Order**. | | ||
| **Mesh Decal Bias Type** | Determines the type of bias that HDRP applies to the decal’s Mesh to stop it from overlapping with other Meshes. Depth Bias applies a bias to the final depth value, while View bias applies a world space bias (in meters) alongside the view vector. | |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Determines the type of bias that HDRP applies to the decal’s Mesh to stop it from overlapping with other Meshes. The options are:<br/>• **Depth Bias**: Applies a bias to the final depth value, <br/>• **View Bias**: Applies a world-space bias (in meters) alongside the view vector.
| -------------------------- | ------------------------------------------------------------ | | ||
| **Draw Order** | Controls the order in which HDRP draws decals in the Scene. HDRP draws decals with lower values first, so it draws decals with a higher draw order value on top of those with lower values. This feature works for decals projected on opaque and transparent surfaces.<br />**Note**: This property only applies to decals the [Decal Projector](Decal-Projector.md) creates and has no effect on Mesh decals. Additionally, if you have multiple Decal Materials with the same **Draw Order**, the order HDRP renders them in depends on the order you create the Materials. HDRP renders Decal Materials you create first before those you create later with the same **Draw Order**. | | ||
| **Mesh Decal Bias Type** | Determines the type of bias that HDRP applies to the decal’s Mesh to stop it from overlapping with other Meshes. Depth Bias applies a bias to the final depth value, while View bias applies a world space bias (in meters) alongside the view vector. | | ||
| **- Mesh Decal View Bias** | A world-space bias (in meters) that HDRP applies to the decal’s Mesh to stop it from overlapping with other Meshes along the view vector. A positive value draws the decal in front of any overlapping Mesh, while a negative value offsets the decal and draw it behind. This property only affects decal Materials directly attached to GameObjects with a Mesh Renderer, so Decal Projectors do not use this property. This property is only visible if **Mesh Decal Bias Type** is set to **View Bias**. | |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
draw -> draws
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
A couple of minor changes. Nice!
| **Draw Order** | Controls the order in which HDRP draws decals in the Scene. HDRP draws decals with lower values first, so it draws decals with a higher draw order value on top of those with lower values. This feature works for decals projected on opaque and transparent surfaces.<br />**Note**: This property only applies to decals the [Decal Projector](Decal-Projector.md) creates and has no effect on Mesh decals. Additionally, if you have multiple Decal Materials with the same **Draw Order**, the order HDRP renders them in depends on the order you create the Materials. HDRP renders Decal Materials you create first before those you create later with the same **Draw Order**. | | ||
| **Mesh Decal Bias Type** | Determines the type of bias that HDRP applies to the decal’s Mesh to stop it from overlapping with other Meshes. Depth Bias applies a bias to the final depth value, while View bias applies a world space bias (in meters) alongside the view vector. | | ||
| **- Mesh Decal View Bias** | A world-space bias (in meters) that HDRP applies to the decal’s Mesh to stop it from overlapping with other Meshes along the view vector. A positive value draws the decal in front of any overlapping Mesh, while a negative value offsets the decal and draw it behind. This property only affects decal Materials directly attached to GameObjects with a Mesh Renderer, so Decal Projectors do not use this property. This property is only visible if **Mesh Decal Bias Type** is set to **View Bias**. | | ||
| **Mesh Decal Depth Bias** | A depth bias that HDRP applies to the decal’s Mesh to stop it from overlapping with other Meshes. A negative value draws the decal in front of any overlapping Mesh, while a positive value offsets the decal and draw it behind. This property only affects decal Materials directly attached to GameObjects with a Mesh Renderer, so Decal Projectors do not use this property. This property is only visible if **Mesh Decal Bias Type** is set to **Depth Bias**. | |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is this indented under mesh decal bias type too? If so put a '-' in front of the property like the one above. If not, ignore!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nope, no indentation on that
Great PR description ! |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hello!
I've tried cases depicted in Francesco gif's on different platforms DX11, DX12, Vulkan, PS4, Metal. Playing with Camera Near/Far planes, FOV, bias values, resizing windows didn't break decals. Also tried building the player, everything renders correctly. ✔
Tried view biased decals inside LookDev window, no issues too ✔
As Remy mentioned updating current automated tests would be important ❕
@JMargevics as a sanity check, have you try to upgrade an existing project and see how it behave? want to be sure that upgrading don't break thing :) |
So i've tested upgrading from 10.2.0, a simple decal with bias set to 0.001. Upgraded to this PR with no issues. Switched to view mode and tried to downgrade back to 10.2.0 and went fine too, it returned to depth mode with no errors. All good ✔ |
# Conflicts: # TestProjects/HDRP_Tests/ProjectSettings/EditorBuildSettings.asset # com.unity.render-pipelines.high-definition/CHANGELOG.md # com.unity.render-pipelines.high-definition/Editor/Material/UIBlocks/DecalSortingInputsUIBlock.cs
This PR introduces a View Bias alongside the old Depth bias (left there for legacy reasons and for avoiding to break existing assets).
The depth bias has several issues being tied to the depth buffer, so its behaviour with the same value changes depending on FOV changes, aspect ratio and distance to the object. Moreover the values to enter are really not artist friendly nor clear.
Here a couple of gif showing the issues (note the decal mesh is overlapping the receiver precisely and the plane behind it is exactly 1cm away from the receiver)
The view bias is expressed in world space unit and pushes the mesh along the view vector. This is first of all more clear on what it does as the unit is simply meters, also is not tied to depth distribution like the other option.
Here gifs of the same issues "fixed" with the new bias (value of 0.005 cm)
Martin K tried it and couldn't break it :-)
UI now

What did I test Can be seen in the gifs. Tried both shadergraph and non-SG materials.