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

Commit 063561d

Browse files
committed
Minor XR shader cleanup
Use TRANSFORM_TEX. Also, there is the possibility that texcoord is being transformed in frag too often. However, it makes sense for tex-coord manipulation in frag. Even so, I should check to make sure transforms are happening somewhere.
1 parent b44a621 commit 063561d

2 files changed

Lines changed: 7 additions & 1 deletion

File tree

PostProcessing/Shaders/Builtins/Copy.shader

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ Shader "Hidden/PostProcessing/Copy"
2222
{
2323
VaryingsDefault o;
2424
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
25+
o.texcoord = TRANSFORM_TEX(v.texcoord, _MainTex); // We need this for VR
2626

2727
#if UNITY_UV_STARTS_AT_TOP
2828
o.texcoord = o.texcoord * float2(1.0, -1.0) + float2(0.0, 1.0);

PostProcessing/Shaders/StdLib.hlsl

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -242,6 +242,10 @@ VaryingsDefault VertDefault(AttributesDefault v)
242242
VaryingsDefault o;
243243
o.vertex = float4(v.vertex.xy, 0.0, 1.0);
244244
o.texcoord = TransformTriangleVertexToUV(v.vertex.xy);
245+
// Most frag shaders that use texcoord do appear to use
246+
// UnityStereoTransformScreenSpaceTex, but I need to
247+
// manually inspect each shader.
248+
// Seems like they'd be better off with the transform in the vert
245249

246250
#if UNITY_UV_STARTS_AT_TOP
247251
o.texcoord = o.texcoord * float2(1.0, -1.0) + float2(0.0, 1.0);
@@ -258,4 +262,6 @@ VaryingsDefault VertDefaultNoFlip(AttributesDefault v)
258262
return o;
259263
}
260264

265+
#define TRANSFORM_TEX(tex,name) (tex.xy * name##_ST.xy + name##_ST.zw)
266+
261267
#endif // UNITY_POSTFX_STDLIB

0 commit comments

Comments
 (0)