Trash maze MVP (#79)
Co-authored-by: Michal Pikulski <michal@foolhardyhorizons.com> Co-authored-by: Michal Pikulski <michal.a.pikulski@gmail.com> Reviewed-on: #79
This commit is contained in:
64
Assets/Shaders/TrashMaze/RevealStamp.shader
Normal file
64
Assets/Shaders/TrashMaze/RevealStamp.shader
Normal file
@@ -0,0 +1,64 @@
|
||||
Shader "Hidden/TrashMaze/RevealStamp"
|
||||
{
|
||||
Properties
|
||||
{
|
||||
_StampPos ("Stamp Position", Vector) = (0.5, 0.5, 0, 0)
|
||||
_StampRadius ("Stamp Radius", Float) = 0.2
|
||||
}
|
||||
|
||||
SubShader
|
||||
{
|
||||
Tags { "Queue"="Overlay" "RenderType"="Opaque" }
|
||||
|
||||
// Additive blend to accumulate stamps
|
||||
Blend One One
|
||||
ZTest Always
|
||||
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
|
||||
{
|
||||
float4 positionCS : SV_POSITION;
|
||||
float2 uv : TEXCOORD0;
|
||||
};
|
||||
|
||||
float4 _StampPos;
|
||||
float _StampRadius;
|
||||
|
||||
Varyings vert(Attributes input)
|
||||
{
|
||||
Varyings output;
|
||||
output.positionCS = TransformObjectToHClip(input.positionOS.xyz);
|
||||
output.uv = input.uv;
|
||||
return output;
|
||||
}
|
||||
|
||||
half4 frag(Varyings input) : SV_Target
|
||||
{
|
||||
// Calculate distance from stamp center
|
||||
float dist = distance(input.uv, _StampPos.xy);
|
||||
|
||||
// Binary circle: 1.0 inside radius, 0.0 outside
|
||||
float alpha = dist < _StampRadius ? 1.0 : 0.0;
|
||||
|
||||
// Return white with calculated alpha (additive blend accumulates)
|
||||
return half4(alpha, alpha, alpha, alpha);
|
||||
}
|
||||
ENDHLSL
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user