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

Commit 7f1301a

Browse files
committed
Fixed VR support
1 parent 67de290 commit 7f1301a

2 files changed

Lines changed: 15 additions & 5 deletions

File tree

PostProcessing/Runtime/PostProcessLayer.cs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -352,7 +352,6 @@ void OnPreCull()
352352
// tiled GPUs
353353
int tempRt = m_TargetPool.Get();
354354
m_LegacyCmdBuffer.GetTemporaryRT(tempRt, context.width, context.height, 24, FilterMode.Bilinear, sourceFormat);
355-
m_LegacyCmdBuffer.SetGlobalTexture(ShaderIDs.MainTex, cameraTarget);
356355
m_LegacyCmdBuffer.Blit(cameraTarget, tempRt, RuntimeUtilities.copyMaterial, stopNaNPropagation ? 3 : 2);
357356
m_NaNKilled = stopNaNPropagation;
358357

PostProcessing/Shaders/Builtins/Copy.shader

Lines changed: 15 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,10 @@
11
Shader "Hidden/PostProcessing/Copy"
22
{
3+
Properties
4+
{
5+
_MainTex ("", 2D) = "white" {}
6+
}
7+
38
HLSLINCLUDE
49

510
#include "../StdLib.hlsl"
@@ -10,16 +15,22 @@ Shader "Hidden/PostProcessing/Copy"
1015
float2 texcoord : TEXCOORD0;
1116
};
1217

18+
TEXTURE2D_SAMPLER2D(_MainTex, sampler_MainTex);
19+
float4 _MainTex_ST;
20+
1321
VaryingsDefault VertClassic(AttributesClassic v)
1422
{
1523
VaryingsDefault o;
16-
o.vertex = mul(unity_MatrixVP, mul(unity_ObjectToWorld, float4(v.vertex.xyz, 1.0)));
17-
o.texcoord = v.texcoord;
24+
o.vertex = float4(v.vertex.xy * 2.0 - 1.0, 0.0, 1.0);
25+
o.texcoord = v.texcoord * _MainTex_ST.xy + _MainTex_ST.zw; // We need this for VR
26+
27+
#if UNITY_UV_STARTS_AT_TOP
28+
o.texcoord = o.texcoord * float2(1.0, -1.0) + float2(0.0, 1.0);
29+
#endif
30+
1831
return o;
1932
}
2033

21-
TEXTURE2D_SAMPLER2D(_MainTex, sampler_MainTex);
22-
2334
float4 Frag(VaryingsDefault i) : SV_Target
2435
{
2536
float4 color = SAMPLE_TEXTURE2D(_MainTex, sampler_MainTex, i.texcoord);

0 commit comments

Comments
 (0)