Skip to content

Fixed XR errors in URP unit tests. #23

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 5 commits into from
Apr 21, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
float4 vertex : POSITION;
float4 uv : TEXCOORD0;
float3 uv2 : TEXCOORD1;
UNITY_VERTEX_INPUT_INSTANCE_ID
};

struct v2f
Expand All @@ -35,11 +36,14 @@

UNITY_FOG_COORDS(1)
float4 vertex : SV_POSITION;
UNITY_VERTEX_OUTPUT_STEREO
};

v2f vert (appdata v)
{
v2f o;
UNITY_SETUP_INSTANCE_ID(v);
UNITY_INITIALIZE_VERTEX_OUTPUT_STEREO(o);
o.vertex = UnityObjectToClipPos(v.vertex);
o.uv = v.uv;
o.uv2 = v.uv2;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,26 +20,28 @@
#pragma multi_compile_fog

#include "Packages/com.unity.render-pipelines.universal/ShaderLibrary/Core.hlsl"
#include "Packages/com.unity.render-pipelines.universal/ShaderLibrary/DeclareOpaqueTexture.hlsl"

struct appdata
{
float4 vertex : POSITION;
float2 uv : TEXCOORD0;
UNITY_VERTEX_INPUT_INSTANCE_ID
};

struct v2f
{
float2 uv : TEXCOORD0;
float4 vertex : SV_POSITION;
float4 screenUV : TEXCOORD1;
UNITY_VERTEX_OUTPUT_STEREO
};

TEXTURE2D(_CameraOpaqueTexture);
SAMPLER(sampler_CameraOpaqueTexture_linear_clamp);

v2f vert (appdata v)
{
v2f o;
UNITY_SETUP_INSTANCE_ID(v);
UNITY_INITIALIZE_VERTEX_OUTPUT_STEREO(o);
o.vertex = TransformObjectToHClip(v.vertex);
o.uv = v.uv;
o.screenUV = ComputeScreenPos(o.vertex);
Expand All @@ -48,14 +50,15 @@

half4 frag (v2f i) : SV_Target
{
UNITY_SETUP_STEREO_EYE_INDEX_POST_VERTEX(i);
// sample the texture
half2 screenUV = i.screenUV.xy / i.screenUV.w;
half v = 0.05;
screenUV += (frac(screenUV * 80) * v) - v * 0.5;
half4 col = half4(-0.05, 0, -0.05, 1);
col.r += SAMPLE_TEXTURE2D(_CameraOpaqueTexture, sampler_CameraOpaqueTexture_linear_clamp, ((screenUV - 0.5) * 1.1) + 0.5).r;
col.g += SAMPLE_TEXTURE2D(_CameraOpaqueTexture, sampler_CameraOpaqueTexture_linear_clamp, screenUV).g;
col.b += SAMPLE_TEXTURE2D(_CameraOpaqueTexture, sampler_CameraOpaqueTexture_linear_clamp, ((screenUV - 0.5) * 0.9) + 0.5).b;
col.r += SampleSceneColor(((screenUV - 0.5) * 1.1) + 0.5).r;
col.g += SampleSceneColor(screenUV).g;
col.b += SampleSceneColor(((screenUV - 0.5) * 0.9) + 0.5).b;
return col;
}
ENDHLSL
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ Shader "Universal Render Pipeline/2D/Sprite-Lit-Default"
float3 positionOS : POSITION;
float4 color : COLOR;
float2 uv : TEXCOORD0;
UNITY_VERTEX_INPUT_INSTANCE_ID
};

struct Varyings
Expand All @@ -51,6 +52,7 @@ Shader "Universal Render Pipeline/2D/Sprite-Lit-Default"
float4 color : COLOR;
float2 uv : TEXCOORD0;
float2 lightingUV : TEXCOORD1;
UNITY_VERTEX_OUTPUT_STEREO
};

#include "Packages/com.unity.render-pipelines.universal/Shaders/2D/Include/LightingUtility.hlsl"
Expand Down Expand Up @@ -83,6 +85,8 @@ Shader "Universal Render Pipeline/2D/Sprite-Lit-Default"
Varyings CombinedShapeLightVertex(Attributes v)
{
Varyings o = (Varyings)0;
UNITY_SETUP_INSTANCE_ID(v);
UNITY_INITIALIZE_VERTEX_OUTPUT_STEREO(o);

o.positionCS = TransformObjectToHClip(v.positionOS);
o.uv = TRANSFORM_TEX(v.uv, _MainTex);
Expand Down Expand Up @@ -118,6 +122,7 @@ Shader "Universal Render Pipeline/2D/Sprite-Lit-Default"
float4 color : COLOR;
float2 uv : TEXCOORD0;
float4 tangent : TANGENT;
UNITY_VERTEX_INPUT_INSTANCE_ID
};

struct Varyings
Expand All @@ -128,6 +133,7 @@ Shader "Universal Render Pipeline/2D/Sprite-Lit-Default"
float3 normalWS : TEXCOORD1;
float3 tangentWS : TEXCOORD2;
float3 bitangentWS : TEXCOORD3;
UNITY_VERTEX_OUTPUT_STEREO
};

TEXTURE2D(_MainTex);
Expand All @@ -139,6 +145,8 @@ Shader "Universal Render Pipeline/2D/Sprite-Lit-Default"
Varyings NormalsRenderingVertex(Attributes attributes)
{
Varyings o = (Varyings)0;
UNITY_SETUP_INSTANCE_ID(attributes);
UNITY_INITIALIZE_VERTEX_OUTPUT_STEREO(o);

o.positionCS = TransformObjectToHClip(attributes.positionOS);
o.uv = TRANSFORM_TEX(attributes.uv, _NormalMap);
Expand Down Expand Up @@ -174,13 +182,15 @@ Shader "Universal Render Pipeline/2D/Sprite-Lit-Default"
float3 positionOS : POSITION;
float4 color : COLOR;
float2 uv : TEXCOORD0;
UNITY_VERTEX_INPUT_INSTANCE_ID
};

struct Varyings
{
float4 positionCS : SV_POSITION;
float4 color : COLOR;
float2 uv : TEXCOORD0;
UNITY_VERTEX_OUTPUT_STEREO
};

TEXTURE2D(_MainTex);
Expand All @@ -190,6 +200,8 @@ Shader "Universal Render Pipeline/2D/Sprite-Lit-Default"
Varyings UnlitVertex(Attributes attributes)
{
Varyings o = (Varyings)0;
UNITY_SETUP_INSTANCE_ID(attributes);
UNITY_INITIALIZE_VERTEX_OUTPUT_STEREO(o);

o.positionCS = TransformObjectToHClip(attributes.positionOS);
o.uv = TRANSFORM_TEX(attributes.uv, _MainTex);
Expand Down