Skip to content
This repository was archived by the owner on Nov 30, 2020. It is now read-only.

Commit ac405b9

Browse files
committed
Fixed a sRGB issue with 2D user-luts
1 parent 938d769 commit ac405b9

File tree

2 files changed

+13
-2
lines changed

2 files changed

+13
-2
lines changed

PostProcessing/Shaders/Builtins/Uber.shader

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -215,7 +215,18 @@ Shader "Hidden/PostProcessing/Uber"
215215
#elif COLOR_GRADING_LDR_2D
216216
{
217217
color = saturate(color);
218-
color.rgb = ApplyLut2D(TEXTURE2D_PARAM(_Lut2D, sampler_Lut2D), color.rgb, _Lut2D_Params);
218+
219+
#if UNITY_COLORSPACE_GAMMA
220+
{
221+
color.rgb = ApplyLut2D(TEXTURE2D_PARAM(_Lut2D, sampler_Lut2D), color.rgb, _Lut2D_Params);
222+
}
223+
#else
224+
{
225+
color.rgb = LinearToSRGB(color.rgb);
226+
color.rgb = ApplyLut2D(TEXTURE2D_PARAM(_Lut2D, sampler_Lut2D), color.rgb, _Lut2D_Params);
227+
color.rgb = SRGBToLinear(color.rgb);
228+
}
229+
#endif
219230
}
220231
#endif
221232

PostProcessing/Shaders/Colors.hlsl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -468,7 +468,7 @@ half3 ApplyLut2D(TEXTURE2D_ARGS(tex, samplerTex), float3 uvw, float3 scaleOffset
468468
{
469469
// Strip format where `height = sqrt(width)`
470470
uvw.z *= scaleOffset.z;
471-
half shift = floor(uvw.z);
471+
float shift = floor(uvw.z);
472472
uvw.xy = uvw.xy * scaleOffset.z * scaleOffset.xy + scaleOffset.xy * 0.5;
473473
uvw.x += shift * scaleOffset.y;
474474
uvw.xyz = lerp(

0 commit comments

Comments
 (0)