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

Commit 88b15d8

Browse files
committed
Fixed 'Depth' & 'Normals' debug views being different in Linear & Gamma spaces
1 parent 839b431 commit 88b15d8

1 file changed

Lines changed: 12 additions & 1 deletion

File tree

PostProcessing/Resources/Shaders/BuiltinDebugViews.shader

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,13 @@ Shader "Hidden/Post FX/Builtin Debug Views"
2929
{
3030
float depth = SAMPLE_DEPTH_TEXTURE(_CameraDepthTexture, UnityStereoScreenSpaceUVAdjust(i.uv, _CameraDepthTexture_ST));
3131
depth = Linear01Depth(depth) * _DepthScale;
32-
return float4(depth.xxx, 1.0);
32+
float3 d = depth.xxx;
33+
34+
#if !UNITY_COLORSPACE_GAMMA
35+
d = GammaToLinearSpace(d);
36+
#endif
37+
38+
return float4(d, 1.0);
3339
}
3440

3541
// -----------------------------------------------------------------------------
@@ -49,6 +55,11 @@ Shader "Hidden/Post FX/Builtin Debug Views"
4955
float4 FragNormals(VaryingsDefault i) : SV_Target
5056
{
5157
float3 n = SampleNormal(UnityStereoScreenSpaceUVAdjust(i.uv, _CameraDepthNormalsTexture_ST));
58+
59+
#if UNITY_COLORSPACE_GAMMA
60+
n = LinearToGammaSpace(n);
61+
#endif
62+
5263
return float4(n, 1.0);
5364
}
5465

0 commit comments

Comments
 (0)