Colors in Entities Graphics need to be converted to linear to render properly

So I’m using Entities Graphics with URP Unlit shader to render a solid color rectangle. I tried to set the color I want on a quad rendered on a GameObject, then compared that to a quad baked in Entities 1.2.3. I also set the exact same color I wanted on that component:

[MaterialProperty("_BaseColor")]
public struct BaseColor : IComponentData
{
    public float4 Value;
}

It ends up being paler when using DOTS. After a bit of research, I ended up fixing it by converting the color to linear for DOTS, by calling Color.linear. However, nowhere in the documentation does it say anything about the need to convert to linear for DOTS in comparison to standard URP. The same happens with custom shaders I tried to make.

Is this a bug? is there a reason why colors in DOTS need to be converted to linear, but not when setting the same color on the same shader, but not using DOTS?

1 Like

https://docs.unity3d.com/Packages/com.unity.entities.graphics@1.2/manual/creating-a-new-entities-graphics-project.html
https://docs.unity3d.com/Packages/com.unity.entities.graphics@1.2/manual/entities-graphics-versions.html

In your links it says that the package only works if the project is set to linear space, but it doesn’t state anywhere that, in a linear space project, feeding a color in the same shader will give a different result in a DOTS workflow and a GO workflow, and that you need to convert your color to linear space to get the same result in DOTS.

I presume it’s to save on computation that needs to be done in the internals.

You can report documentation issues at the bottom of the page. I consider the C# material override page a good place for this information.

MaterialColor as an example for the uninitiated - editor authoring encodes values in gamma space that needs to be converted to linear space on bake.