Skip to content

Commit 104f114

Browse files
committed
Add linear color space support
1 parent 5b94a62 commit 104f114

File tree

1 file changed

+9
-1
lines changed

1 file changed

+9
-1
lines changed

Assets/Klak/Hap/Resources/HapY.shader

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,9 +14,16 @@ Shader "Klak/HAP Q"
1414

1515
half3 CoCgSY2RGB(half4 i)
1616
{
17+
#if !defined(UNITY_COLORSPACE_GAMMA)
18+
i.xyz = LinearToGammaSpace(i.xyz);
19+
#endif
1720
i.xy -= half2(0.50196078431373, 0.50196078431373);
1821
half s = 1 / ((i.z * (255.0 / 8)) + 1);
19-
return half3(i.x - i.y, i.y, -i.x - i.y) * s + i.w;
22+
half3 rgb = half3(i.x - i.y, i.y, -i.x - i.y) * s + i.w;
23+
#if !defined(UNITY_COLORSPACE_GAMMA)
24+
rgb = GammaToLinearSpace(rgb);
25+
#endif
26+
return rgb;
2027
}
2128

2229
float4 Vertex(
@@ -45,6 +52,7 @@ Shader "Klak/HAP Q"
4552
Pass
4653
{
4754
CGPROGRAM
55+
#pragma multi_compile _ UNITY_COLORSPACE_GAMMA
4856
#pragma vertex Vertex
4957
#pragma fragment Fragment
5058
ENDCG

0 commit comments

Comments
 (0)