Line Color varies between Component and Immediate mode even though they use the same color

Avatar
  • updated
  • Fixed

I found that when drawing with immediate mode the color is different/incorrect compared to the line component color.

In this image the top line was drawn via component and the bottom line is drawn via immediate. Both use the same color values.

In immediate mode the line appears much lighter when using certain colors.

Image 332

Reporting a bug? please specify Unity version:
2020.1.17
Reporting a bug? please specify Shapes version:
3.1.1
Reporting a bug? please specify Render Pipeline:
URP
Pinned replies
Avatar
Freya Holmér creator
  • Answer
  • Fixed

this has now been fixed in 3.2.0

Avatar
Freya Holmér creator
  • Under Review

Does this behavior change when toggling linear/gamma space in your graphics settings?

Avatar
Raincoat

Seems to be the same behavior even in Gamma color space.

Avatar
Freya Holmér creator

how do you pass the color values into each of these, and what color is it more specifically? (I'm pretty sure this is a linear vs gamma issue, and Unity does some weird shenanigans in where it compensates for it vs not)

Avatar
Raincoat

The first one is a line component:

The second one is drawn via immediate mode like this:

[ExecuteAlways]
public class TestLineColor : ImmediateModeShapeDrawer
{
    public Color TestColor;

    public Line LineComponent;

    private void Update()
    {
        //Set color of line component
        LineComponent.Color = TestColor;
    }

    public override void DrawShapes(Camera cam)
    {
        using (Draw.Command(cam))
        {
            Draw.LineGeometry = LineGeometry.Volumetric3D;
            Draw.LineThicknessSpace = ThicknessSpace.Noots;
            Draw.LineThickness = 10;
            
            Draw.Line(transform.position, transform.position + Vector3.right, TestColor);
        }
    }
}

Both colors are set with the same test color value in the above script.

The here are some colors that I have been testing:
RGB(67, 212, 41)
RGB(255,  0, 122)
RGB(65, 197, 154)
etc

This pretty much happens with all colors.


Additionally any color that is essentially completely yellow, red, blue, green, etc makes both lines the same color.
RGB (0, 0, 255)

RGB (0, 255, 255)
RGB (255, 0, 255)
etc

Avatar
Freya Holmér creator
  • Answer
  • Fixed

this has now been fixed in 3.2.0