Advanced POC - portals, dialogue system + floating words, room loading
This commit is contained in:
@@ -0,0 +1,78 @@
|
||||
Shader "Custom/Portal_URP"
|
||||
{
|
||||
Properties
|
||||
{
|
||||
_InactiveColour ("Inactive Colour", Color) = (1,1,1,1)
|
||||
_MainTex ("Texture", 2D) = "white" {}
|
||||
_DisplayMask ("Display Mask", Float) = 1
|
||||
}
|
||||
|
||||
SubShader
|
||||
{
|
||||
Tags
|
||||
{
|
||||
"RenderPipeline"="UniversalPipeline"
|
||||
"RenderType"="Opaque"
|
||||
"Queue"="Geometry+500"
|
||||
}
|
||||
|
||||
Cull Off
|
||||
ZWrite On
|
||||
ZTest LEqual
|
||||
|
||||
Pass
|
||||
{
|
||||
Name "Unlit"
|
||||
Tags { "LightMode"="SRPDefaultUnlit" }
|
||||
|
||||
HLSLPROGRAM
|
||||
#pragma vertex vert
|
||||
#pragma fragment frag
|
||||
|
||||
#include "Packages/com.unity.render-pipelines.universal/ShaderLibrary/Core.hlsl"
|
||||
|
||||
TEXTURE2D(_MainTex);
|
||||
SAMPLER(sampler_MainTex);
|
||||
|
||||
CBUFFER_START(UnityPerMaterial)
|
||||
float4 _InactiveColour;
|
||||
float _DisplayMask;
|
||||
CBUFFER_END
|
||||
|
||||
struct Attributes
|
||||
{
|
||||
float3 positionOS : POSITION;
|
||||
};
|
||||
|
||||
struct Varyings
|
||||
{
|
||||
float4 positionHCS : SV_POSITION;
|
||||
float4 screenPos : TEXCOORD0;
|
||||
};
|
||||
|
||||
Varyings vert (Attributes v)
|
||||
{
|
||||
Varyings o;
|
||||
o.positionHCS = TransformObjectToHClip(v.positionOS);
|
||||
o.screenPos = ComputeScreenPos(o.positionHCS);
|
||||
return o;
|
||||
}
|
||||
|
||||
half4 frag (Varyings i) : SV_Target
|
||||
{
|
||||
float2 uv = i.screenPos.xy / max(i.screenPos.w, 1e-5);
|
||||
|
||||
half4 portalCol = SAMPLE_TEXTURE2D(_MainTex, sampler_MainTex, uv);
|
||||
|
||||
half displayMask = saturate(_DisplayMask);
|
||||
half4 finalCol = lerp(_InactiveColour, portalCol, displayMask);
|
||||
|
||||
if (displayMask > 0.5h && portalCol.a < 0.1h)
|
||||
return _InactiveColour;
|
||||
|
||||
return finalCol;
|
||||
}
|
||||
ENDHLSL
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user