non-VR portal rendering

This commit is contained in:
2022-10-07 20:29:23 +02:00
parent 59abc4b6f7
commit c561d617af
11 changed files with 468 additions and 159 deletions

View File

@@ -0,0 +1,55 @@
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
}
}
}