Stash work
This commit is contained in:
91
Assets/Shaders/TrashMaze/ObjectVisibility.shader
Normal file
91
Assets/Shaders/TrashMaze/ObjectVisibility.shader
Normal file
@@ -0,0 +1,91 @@
|
||||
Shader "TrashMaze/ObjectVisibility"
|
||||
{
|
||||
Properties
|
||||
{
|
||||
_MainTex ("Normal Texture (Color)", 2D) = "white" {}
|
||||
_OutlineTex ("Outline Texture (White)", 2D) = "white" {}
|
||||
[PerRendererData] _IsRevealed ("Is Revealed", Float) = 0
|
||||
[PerRendererData] _IsInVision ("Is In Vision", Float) = 0
|
||||
}
|
||||
|
||||
SubShader
|
||||
{
|
||||
Tags
|
||||
{
|
||||
"Queue"="Transparent"
|
||||
"RenderType"="Transparent"
|
||||
"IgnoreProjector"="True"
|
||||
}
|
||||
|
||||
Blend SrcAlpha OneMinusSrcAlpha
|
||||
ZWrite Off
|
||||
Cull Off
|
||||
|
||||
Pass
|
||||
{
|
||||
HLSLPROGRAM
|
||||
#pragma vertex vert
|
||||
#pragma fragment frag
|
||||
#include "Packages/com.unity.render-pipelines.universal/ShaderLibrary/Core.hlsl"
|
||||
|
||||
struct Attributes
|
||||
{
|
||||
float4 positionOS : POSITION;
|
||||
float2 uv : TEXCOORD0;
|
||||
};
|
||||
|
||||
struct Varyings
|
||||
{
|
||||
float2 uv : TEXCOORD0;
|
||||
float4 positionCS : SV_POSITION;
|
||||
};
|
||||
|
||||
TEXTURE2D(_MainTex);
|
||||
SAMPLER(sampler_MainTex);
|
||||
TEXTURE2D(_OutlineTex);
|
||||
SAMPLER(sampler_OutlineTex);
|
||||
float4 _MainTex_ST;
|
||||
|
||||
// Per-instance properties (set by RevealableObject component)
|
||||
float _IsRevealed;
|
||||
float _IsInVision;
|
||||
|
||||
Varyings vert(Attributes input)
|
||||
{
|
||||
Varyings output;
|
||||
VertexPositionInputs vertexInput = GetVertexPositionInputs(input.positionOS.xyz);
|
||||
output.positionCS = vertexInput.positionCS;
|
||||
output.uv = TRANSFORM_TEX(input.uv, _MainTex);
|
||||
return output;
|
||||
}
|
||||
|
||||
half4 frag(Varyings input) : SV_Target
|
||||
{
|
||||
// Three-state logic:
|
||||
// 1. In vision radius -> show normal texture (color)
|
||||
// 2. Revealed but outside vision -> show outline texture (white)
|
||||
// 3. Never revealed -> transparent (hidden)
|
||||
|
||||
if (_IsInVision > 0.5)
|
||||
{
|
||||
// Inside vision radius - show color
|
||||
return SAMPLE_TEXTURE2D(_MainTex, sampler_MainTex, input.uv);
|
||||
}
|
||||
else if (_IsRevealed > 0.5)
|
||||
{
|
||||
// Revealed but outside vision - show outline
|
||||
return SAMPLE_TEXTURE2D(_OutlineTex, sampler_OutlineTex, input.uv);
|
||||
}
|
||||
else
|
||||
{
|
||||
// Never revealed - transparent (hidden)
|
||||
return half4(0, 0, 0, 0);
|
||||
}
|
||||
}
|
||||
ENDHLSL
|
||||
}
|
||||
}
|
||||
|
||||
FallBack "Transparent/Diffuse"
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user