Skip to content

Commit cdacadd

Browse files
committed
only invert z value when not in opengl
only invert z value when not in opengl
1 parent cc9c63a commit cdacadd

File tree

2 files changed

+20
-4
lines changed

2 files changed

+20
-4
lines changed

Assets/ScriptableRenderLoop/HDRenderLoop/Lighting/TilePass/ShaderBase.hlsl

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,12 +19,20 @@
1919

2020
float FetchDepth(Texture2D depthTexture, uint2 pixCoord)
2121
{
22-
return 1.0 - LOAD_TEXTURE2D(depthTexture, pixCoord.xy).x;
22+
float zdpth = LOAD_TEXTURE2D(depthTexture, pixCoord.xy).x;
23+
#if !defined(SHADER_API_GLES3) && !defined(SHADER_API_GLCORE)
24+
zdpth = 1.0 - zdpth;
25+
#endif
26+
return zdpth;
2327
}
2428

2529
float FetchDepthMSAA(Texture2DMS<float> depthTexture, uint2 pixCoord, uint sampleIdx)
2630
{
27-
return 1.0 - LOAD_TEXTURE2D_MSAA(depthTexture, pixCoord.xy, sampleIdx).x;
31+
float zdpth = LOAD_TEXTURE2D_MSAA(depthTexture, pixCoord.xy, sampleIdx).x;
32+
#if !defined(SHADER_API_GLES3) && !defined(SHADER_API_GLCORE)
33+
zdpth = 1.0 - zdpth;
34+
#endif
35+
return zdpth;
2836
}
2937

3038
#endif

Assets/ScriptableRenderLoop/common/ShaderBase.h

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,12 +31,20 @@
3131

3232
float FetchDepth(Texture2D depthTexture, uint2 pixCoord)
3333
{
34-
return 1 - depthTexture.Load(uint3(pixCoord.xy, 0)).x;
34+
float zdpth = depthTexture.Load(uint3(pixCoord.xy, 0)).x;
35+
#if !defined(SHADER_API_GLES3) && !defined(SHADER_API_GLCORE)
36+
zdpth = 1.0 - zdpth;
37+
#endif
38+
return zdpth;
3539
}
3640

3741
float FetchDepthMSAA(Texture2DMS<float> depthTexture, uint2 pixCoord, uint sampleIdx)
3842
{
39-
return 1 - depthTexture.Load(uint3(pixCoord.xy, 0), sampleIdx).x;
43+
float zdpth = depthTexture.Load(uint3(pixCoord.xy, 0), sampleIdx).x;
44+
#if !defined(SHADER_API_GLES3) && !defined(SHADER_API_GLCORE)
45+
zdpth = 1.0 - zdpth;
46+
#endif
47+
return zdpth;
4048
}
4149

4250
#endif

0 commit comments

Comments
 (0)