Shapes are partly rendered behind other object.

Avatar
  • updated

Hi,

I use Shapes lines and discs to visualize edges and vertices of a mesh.

My goal: the drawn shapes should be rendered in front of other objects, when even a little part of them is visible by the camera.
And they should be rendered behind objects if no part of them is visible by the camera.
Something like the pseudo-code below:

if (line or disc is partly or completely visible by the camera)
{
    --> render in front of object
}
else if (no part of the line or disc is visible by the camera)
{
    --> render behind object (or do not render this line or disc)
}

Using:

Draw.ZTest = CompareFunction.LessEqual;

Gets me close to that goal, but the lines and discs are partly behind the mesh of the object (see markings with "red crosses" in the screenshots below), which makes sense because they are physically "behind" or "in" the object.
But the downside is, that especially lines can be very thin if the largest part of them is hidden by the objects edge.

The DiscGeometry is set to "Billboard" and the LineGeometry is set to "Billboard" as well.

I assume the only way to achieve this goal is to access the Material and Shader, which are used for the drawn Shapes, right? Is that possible?

Or is there any other solution?

Best regards,

Richard

Image 718

Image 719



Reporting a bug? please specify Unity version:
Reporting a bug? please specify Shapes version:
Reporting a bug? please specify Render Pipeline:
Built-in render pipeline