Shader "Unheimlich/UI/ScribbleEffect" { Properties { _Color("Scribble Color", Color) = (0.2, 0.2, 0.2, 1) _Progress("Draw Progress", Range(0, 1)) = 0 _LineThickness("Thickness", Range(0.005, 0.25)) = 0.02 _ZigzagFreq("Zigzag Frequency", Float) = 10 _ZigzagAmp("Zigzag Amplitude", Range(0, 0.3)) = 0.1 _DiagonalSlant("Diagonal Slant", Range(-1, 1)) = 0.4 _NumPasses("Number of Passes", Range(1, 4)) = 2 _Roundness("Roundness", Range(0, 1)) = 0.6 } SubShader { Tags { "Queue" = "Transparent" "RenderType" = "Transparent" } 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 { float4 positionCS : SV_POSITION; float2 uv : TEXCOORD0; }; CBUFFER_START(UnityPerMaterial) half4 _Color; half _Progress; half _LineThickness; half _ZigzagFreq; half _ZigzagAmp; half _DiagonalSlant; int _NumPasses; half _Roundness; CBUFFER_END Varyings vert(Attributes input) { Varyings output; output.positionCS = TransformObjectToHClip(input.positionOS.xyz); output.uv = input.uv; return output; } float DrawSlantedZigzag(float2 uv, float yOffset, float passProgress) { float diagonalProgress = uv.x + uv.y * _DiagonalSlant; float zigzagCenter = yOffset + sin(diagonalProgress * _ZigzagFreq * 6.28318) * _ZigzagAmp; float progressEnd = passProgress * 1.6; float progressMask = smoothstep(progressEnd + 0.15, progressEnd - 0.05, diagonalProgress); float fadeIn = smoothstep(-0.1, 0.2, diagonalProgress); float capMask = fadeIn * progressMask; float distanceToCenter = abs(uv.y - zigzagCenter); float edgeSoftness = _LineThickness * (1.0 - _Roundness * 0.7); float zigzagStrength = 1.0 - smoothstep(edgeSoftness, _LineThickness, distanceToCenter); zigzagStrength = pow(zigzagStrength, 1.0 + _Roundness * 3.5); return zigzagStrength * capMask; } half4 frag(Varyings input) : SV_Target { float totalMask = 0.0; totalMask += DrawSlantedZigzag(input.uv, 0.5, _Progress); if (_NumPasses >= 2) totalMask += DrawSlantedZigzag(input.uv, 0.52, _Progress * 0.95); if (_NumPasses >= 3) totalMask += DrawSlantedZigzag(input.uv, 0.48, _Progress * 0.9); if (_NumPasses >= 4) totalMask += DrawSlantedZigzag(input.uv, 0.54, _Progress * 0.85); totalMask = saturate(totalMask); half4 result = _Color; result.a *= totalMask; return result; } ENDHLSL } } }