2023-05-08 15:56:10 +03:00

73 lines
1.9 KiB
Plaintext

Shader "XR/PortalShader"
{
Properties
{
_Color ("Color", Color) = (1,1,1,1)
_MainTex ("Texture", 2D) = "white" {}
_TexL("LeftEyeTexture", 2D) = "white" {}
_TexR("RightEyeTexture", 2D) = "white" {}
}
SubShader
{
Tags{ "RenderType" = "Opaque" "Queue" = "Transparent" }
Pass
{
Name "Mask"
CGPROGRAM
#include "UnityCG.cginc"
#pragma vertex vert
#pragma fragment frag
#pragma target 3.0
sampler2D _MainTex;
float4 _MainTex_ST;
float4 _Color;
sampler2D _TexL;
sampler2D _TexR;
struct appdata
{
float4 vertex : POSITION;
UNITY_VERTEX_INPUT_INSTANCE_ID
};
struct v2f
{
float4 position : SV_POSITION;
float4 screenPosition : TEXCOORD0;
UNITY_VERTEX_INPUT_INSTANCE_ID
UNITY_VERTEX_OUTPUT_STEREO
};
v2f vert(appdata v)
{
v2f o;
UNITY_SETUP_INSTANCE_ID(v);
UNITY_INITIALIZE_OUTPUT(v2f, o);
UNITY_INITIALIZE_VERTEX_OUTPUT_STEREO(o);
o.position = UnityObjectToClipPos(v.vertex);
o.screenPosition = ComputeScreenPos(o.position);
return o;
}
half4 frag(v2f i) : SV_Target
{
UNITY_SETUP_STEREO_EYE_INDEX_POST_VERTEX(i);
float2 textureCoordinate = i.screenPosition.xy / i.screenPosition.w;
return unity_StereoEyeIndex == 0 ?
tex2D(_TexL, textureCoordinate) :
tex2D(_TexR, textureCoordinate);
}
ENDCG
}
}
}