Looking-Glass/Assets/playerstuff/glass shader/Portal.shader

56 lines
1.4 KiB
Plaintext
Raw Permalink Normal View History

2024-02-02 12:54:47 +01:00
Shader "Custom/Portal"
{
2024-02-07 20:26:35 +01:00
// shader for the portals, suprisingly straightforward so nothing should go wrong here
2024-02-02 12:54:47 +01:00
Properties
{
_InactiveColour ("Inactive Colour", Color) = (1, 1, 1, 1)
}
SubShader
{
Tags { "RenderType"="Opaque" }
LOD 100
Cull Off
Pass
{
CGPROGRAM
#pragma vertex vert
#pragma fragment frag
#include "UnityCG.cginc"
struct appdata
{
float4 vertex : POSITION;
};
struct v2f
{
float4 vertex : SV_POSITION;
float4 screenPos : TEXCOORD0;
};
sampler2D _MainTex;
float4 _InactiveColour;
int displayMask; // set to 1 to display texture, otherwise will draw test colour
v2f vert (appdata v)
{
v2f o;
o.vertex = UnityObjectToClipPos(v.vertex);
o.screenPos = ComputeScreenPos(o.vertex);
return o;
}
fixed4 frag (v2f i) : SV_Target
{
float2 uv = i.screenPos.xy / i.screenPos.w;
fixed4 portalCol = tex2D(_MainTex, uv);
return portalCol * displayMask + _InactiveColour * (1-displayMask);
}
ENDCG
}
}
Fallback "Standard" // for shadows
}