Bug: When PolylinePath contains (0,0,0) thickness and caps don't render correctly

Avatar
  • updated
  • Under Review

Code that reproduces (I added to main camera):


using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using Shapes;

[ExecuteAlways]
public class MyLines : MonoBehaviour {
    List<polylinepath> paths;
    int numLines = 5;

    void OnEnable() {
        if (paths == null) {
            paths = new List<polylinepath>();
            for (int i = 0; i < numLines; ++i) {
                float x = i * 1.5f;
                PolylinePath p = new PolylinePath();
                paths.Add(p);
                p.AddPoint(x, 0, 0, new Color(1, 0, 0));
                p.AddPoint(x, 2, 20, new Color(0, 1, 0));
                p.AddPoint(x, 4, 0, new Color(0, 0, 1));
            }
            
        }
    }

    void OnPostRender() {
        if (!enabled) return;

        // Drawing happens here
        Draw.BlendMode = ShapesBlendMode.Opaque;
        foreach (PolylinePath p in paths) {
            Draw.Polyline( p, closed:true, thickness:0.5f ); 
        }
    }

    // Disposing of mesh data happens here
    void OnDestroy() {
        foreach (PolylinePath p in paths) {
            p.Dispose();
        }
    }
}

Sample images

Here just the first polyline has a (0,0,0) point.

Image 29

Here I made the first point always (0,0,0)

Image 28

Reporting a bug? please specify Unity version:
2019.4.0f1
Reporting a bug? please specify Shapes version:
1.1.1
Reporting a bug? please specify Render Pipeline:
Avatar
Freya Holmér creator
  • Under Review

As far as I know, this is not so much about having points at (0,0,0), but rather about billboarded polylines that are edge-on in screen space generally have some degenerate cases, especially with large thickness values

it's a pretty hard problem to solve, so unfortunately this will take a while as it's both low prio and a difficult one I'm afraid :c