Unity-UI-Rounded-Corners icon indicating copy to clipboard operation
Unity-UI-Rounded-Corners copied to clipboard

undeclared identifier 'UIGammaToLinear'

Open Niaxor opened this issue 11 months ago • 2 comments

Shader error in 'UI/RoundedCorners/RoundedCorners': undeclared identifier 'UIGammaToLinear' After import - I'm assuming this is a minimum Unity version requirement that I'm not meeting, I'm currently using Unity 2019.4.

According to this forum post - Re similar issues in TMP https://discussions.unity.com/t/3-2-0-pre-6-undeclared-identifier-uigammatolinear/931099/8 This in-built shader function requires at minimum Unity 2021.3.34f1 or later.

Just logging in-case I'm wrong, or if you wanted to add a Minimum Unity Version to the readme, if there's a particular version in released that I should be aware of that doesn't require this function please let me know :)

Niaxor avatar Feb 13 '25 05:02 Niaxor

I'm seeing this error too. I'm on 2022.2.5f1

GiuseppePiscopo avatar Jun 04 '25 16:06 GiuseppePiscopo

I had this error on Unity 2019.4, and even swapping to old releases of this repo still had it. So far after tinkering I got the error to go away by putting this:

#ifndef UIGammaToLinear
inline float GammaToLinear(float value)
{
    return (value <= 0.04045) ? value / 12.92 : pow((value + 0.055) / 1.055, 2.4);
}

inline float3 UIGammaToLinear(float3 color)
{
    return float3(GammaToLinear(color.r), GammaToLinear(color.g), GammaToLinear(color.b));
}

inline float4 UIGammaToLinear(float4 color)
{
    return float4(GammaToLinear(color.r), GammaToLinear(color.g), GammaToLinear(color.b), color.a);
}
#endif

(right above #include "UnityCG.cginc" in both shaders) Haven't tested if it's actually fully fixed qualitatively though, but that's where I am at with it.

cclogg avatar Aug 03 '25 08:08 cclogg