55 lines
1.3 KiB
Plaintext
55 lines
1.3 KiB
Plaintext
Shader "Escape Room Engine/Portal"
|
|
{
|
|
Properties
|
|
{
|
|
_MainTex("Portal Texture", 2D) = "" {}
|
|
}
|
|
|
|
SubShader
|
|
{
|
|
Tags { "RenderType" = "Opaque" "RenderPipeline" = "UniversalPipeline" "Queue" = "Geometry" }
|
|
|
|
Pass
|
|
{
|
|
// stencil the portal surface to cut it out from the portal frame
|
|
Stencil
|
|
{
|
|
Ref 1
|
|
Pass replace
|
|
}
|
|
|
|
HLSLPROGRAM
|
|
#pragma vertex vert
|
|
#pragma fragment frag
|
|
|
|
#include "Packages/com.unity.render-pipelines.universal/ShaderLibrary/Core.hlsl"
|
|
|
|
uniform sampler2D _MainTex;
|
|
|
|
struct Attributes
|
|
{
|
|
float4 vertex : POSITION;
|
|
};
|
|
|
|
struct Varyings
|
|
{
|
|
float4 vertex : SV_POSITION;
|
|
float4 screen : TEXCOORD0;
|
|
};
|
|
|
|
Varyings vert(Attributes IN)
|
|
{
|
|
Varyings OUT;
|
|
OUT.vertex = TransformObjectToHClip(IN.vertex.xyz);
|
|
OUT.screen = ComputeScreenPos(OUT.vertex);
|
|
return OUT;
|
|
}
|
|
|
|
half4 frag(Varyings IN) : SV_Target
|
|
{
|
|
return tex2D(_MainTex, IN.screen.xy / IN.screen.w);
|
|
}
|
|
ENDHLSL
|
|
}
|
|
}
|
|
} |