Line thickness behaves eratically near +/-Z axis
Note: this issue may be related to https://shapes.userecho.com/en/communities/1/topics/154-. I am posting it separately because while that issue seems to be referring to pixel scaling being consistently off for a line that passes behind the camera, the specific behavior here is more extreme and in a very specific case.
I've run into an issue where pixel space thickness behaves erratically for points whose position is vaguely in the direction of +Z or -Z when drawn with Lines, while behaving as expected when drawn with Spheres.
In an ImmediateModeShapeDrawer, I am generating a set of points in a semicircle in local space of each currently rendering camera. I am drawing the points twice: once above with Draw.Sphere and once below with Draw.Line and have their respective Thickness spaces set to Pixel:
Note how in certain orientations the thickness of the lines (bottom) varies wildly, while the spheres (top) are always rock solid.
Particularly interesting is that the thickness variation of the lines appears to be most extreme around the vanishing point of the +Z/-Z axis, and is more pronounced the further towards the edges of the screen it is.
Here is the code used in this example:
using UnityEngine; using Shapes; [ExecuteAlways] public class ScreenspaceSize : ImmediateModeShapeDrawer { public int pointCount = 30; public float pointThickness = 30; public float pointDistance = 5; public float colorAlpha = 0.5f; public override void DrawShapes(Camera cam) { using (Draw.Command(cam)) { Draw.Matrix = cam.transform.localToWorldMatrix; Draw.LineGeometry = LineGeometry.Volumetric3D; Draw.SphereRadiusSpace = ThicknessSpace.Pixels; Draw.LineThicknessSpace = ThicknessSpace.Pixels; for (int i = 0; i < pointCount; ++i) { float param01 = i / (float) (pointCount - 1); Color color = Color.HSVToRGB(param01, 0.9f, 1); color.a = colorAlpha; Quaternion localRot = Quaternion.Euler(0, Mathf.Lerp(-75, 75, param01), 0); Vector3 localPos = localRot * Vector3.forward * pointDistance; Draw.Sphere(localPos + Vector3.up, pointThickness/2, color); Draw.Line(localPos - Vector3.up, localPos - Vector3.up, pointThickness, color); } } } }
For clarification, here is a visualization of where relative to the camera the points are being drawn, and what the camera itself sees:
Note that in the screencapture I am using a debug script to move both the game and the scene view together, but that is not relevant to this issue.
looks like this is specifically because of how lines behave when they are in the degenerate state of having 0 (or very near 0) length
I've cleaned up that degenerate line case now in 3.0.1 so it behaves just like the spheres, but also, why are you making degenerate lines? c: