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

Commit 5937b40

Browse files
committed
MSVO fixes for VR
1 parent 25cbd15 commit 5937b40

File tree

1 file changed

+9
-24
lines changed

1 file changed

+9
-24
lines changed

PostProcessing/Shaders/Builtins/MultiScaleVO.shader

Lines changed: 9 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -9,20 +9,6 @@ Shader "Hidden/PostProcessing/MultiScaleVO"
99
TEXTURE2D_SAMPLER2D(_MSVOcclusionTexture, sampler_MSVOcclusionTexture);
1010
float3 _AOColor;
1111

12-
VaryingsDefault Vert(AttributesDefault v)
13-
{
14-
VaryingsDefault o;
15-
o.vertex = float4(v.vertex.xy, 0.0, 1.0);
16-
o.texcoord = TransformTriangleVertexToUV(v.vertex.xy);
17-
18-
#if UNITY_UV_STARTS_AT_TOP
19-
o.texcoord = o.texcoord * float2(1.0, -1.0) + float2(0.0, 1.0);
20-
#endif
21-
22-
o.texcoord = TransformStereoScreenSpaceTex(o.texcoord, 1);
23-
return o;
24-
}
25-
2612
ENDHLSL
2713

2814
SubShader
@@ -34,12 +20,12 @@ Shader "Hidden/PostProcessing/MultiScaleVO"
3420
{
3521
HLSLPROGRAM
3622

37-
#pragma vertex Vert
23+
#pragma vertex VertDefault
3824
#pragma fragment Frag
3925

4026
float4 Frag(VaryingsDefault i) : SV_Target
4127
{
42-
return SAMPLE_DEPTH_TEXTURE(_CameraDepthTexture, sampler_CameraDepthTexture, i.texcoord);
28+
return SAMPLE_DEPTH_TEXTURE(_CameraDepthTexture, sampler_CameraDepthTexture, i.texcoordStereo);
4329
}
4430

4531
ENDHLSL
@@ -52,7 +38,7 @@ Shader "Hidden/PostProcessing/MultiScaleVO"
5238

5339
HLSLPROGRAM
5440

55-
#pragma vertex Vert
41+
#pragma vertex VertDefault
5642
#pragma fragment Frag
5743

5844
struct Output
@@ -63,7 +49,7 @@ Shader "Hidden/PostProcessing/MultiScaleVO"
6349

6450
Output Frag(VaryingsDefault i)
6551
{
66-
float ao = 1.0 - SAMPLE_TEXTURE2D(_MSVOcclusionTexture, sampler_MSVOcclusionTexture, i.texcoord).r;
52+
float ao = 1.0 - SAMPLE_TEXTURE2D(_MSVOcclusionTexture, sampler_MSVOcclusionTexture, i.texcoordStereo).r;
6753
Output o;
6854
o.gbuffer0 = float4(0.0, 0.0, 0.0, ao);
6955
o.gbuffer3 = float4(ao * _AOColor, 0.0);
@@ -82,17 +68,16 @@ Shader "Hidden/PostProcessing/MultiScaleVO"
8268

8369
#pragma multi_compile _ APPLY_FORWARD_FOG
8470
#pragma multi_compile _ FOG_LINEAR FOG_EXP FOG_EXP2
85-
#pragma vertex Vert
71+
#pragma vertex VertDefault
8672
#pragma fragment Frag
8773

8874
float4 Frag(VaryingsDefault i) : SV_Target
8975
{
90-
float2 texcoord = TransformStereoScreenSpaceTex(i.texcoord, 1);
91-
half ao = 1.0 - SAMPLE_TEXTURE2D(_MSVOcclusionTexture, sampler_MSVOcclusionTexture, texcoord).r;
76+
half ao = 1.0 - SAMPLE_TEXTURE2D(_MSVOcclusionTexture, sampler_MSVOcclusionTexture, i.texcoordStereo).r;
9277

9378
// Apply fog when enabled (forward-only)
9479
#if (APPLY_FORWARD_FOG)
95-
float d = Linear01Depth(SAMPLE_DEPTH_TEXTURE(_CameraDepthTexture, sampler_CameraDepthTexture, texcoord));
80+
float d = Linear01Depth(SAMPLE_DEPTH_TEXTURE(_CameraDepthTexture, sampler_CameraDepthTexture, i.texcoordStereo));
9681
d = ComputeFogDistance(d);
9782
ao *= ComputeFog(d);
9883
#endif
@@ -108,12 +93,12 @@ Shader "Hidden/PostProcessing/MultiScaleVO"
10893
{
10994
HLSLPROGRAM
11095

111-
#pragma vertex Vert
96+
#pragma vertex VertDefault
11297
#pragma fragment Frag
11398

11499
float4 Frag(VaryingsDefault i) : SV_Target
115100
{
116-
half ao = SAMPLE_TEXTURE2D(_MSVOcclusionTexture, sampler_MSVOcclusionTexture, i.texcoord).r;
101+
half ao = SAMPLE_TEXTURE2D(_MSVOcclusionTexture, sampler_MSVOcclusionTexture, i.texcoordStereo).r;
117102
return float4(ao.rrr, 1.0);
118103
}
119104

0 commit comments

Comments
 (0)