// WL_VividGrass — 섬 풀잎 · 꽃 「선명 룩」 셰이더(2026-11-25 #1136 PD 「원신 같은 밝고 화사한 색감」) // · 그리기 = 3DPixelArtEnvironment 인스턴서(DrawMeshInstancedIndirect · _InstanceData · _LocalToWorld)와 같은 입력 — 원본 InstancedBillboardToon 대체 // · 색 = 뿌리 → 끝 그라데이션 + 큰 얼룩(노란 무리) + 포기마다 작은 흔들림 · 그늘은 검지 않고 청록 // · 빛 = 지면 법선(인스턴스) · 해 그림자 1회 샘플 · 부드러운 2단 램프(원신식) · 모바일: 텍스처 0장 · 색 계산은 정점에서 Shader "WL/VividGrass" { Properties { _GrassRoot ("Root", Color) = (0.25, 0.55, 0.30, 1) _GrassTip ("Tip", Color) = (0.86, 0.95, 0.42, 1) _GrassShadowRoot ("Shadow Root", Color) = (0.13, 0.36, 0.33, 1) _GrassShadowTip ("Shadow Tip", Color) = (0.36, 0.62, 0.42, 1) _TipPower ("Tip Power", Float) = 1.4 _BladeHeight ("Blade Height (object)", Float) = 1.14 _PatchTint ("Patch Tint (warm)", Color) = (1.18, 1.06, 0.70, 1) _PatchCoolTint ("Patch Tint (cool)", Color) = (0.85, 0.95, 1.0, 1) _AltTip ("Alt Tip (per clump)", Color) = (1, 0.85, 0.3, 1) _AltChance ("Alt Tip Chance", Float) = 0 _PatchScale ("Patch Scale", Float) = 0.18 _PatchStrength ("Patch Strength", Float) = 0.7 _Jitter ("Per-clump Jitter", Float) = 0.18 _RampThreshold ("Ramp Threshold", Float) = 0.45 _RampSoftness ("Ramp Softness", Float) = 0.12 _AmbientStrength ("Ambient", Float) = 0.25 _WindStrength ("Wind Strength", Float) = 0.3 _WindDensity ("Wind Density", Float) = 0.2 _WindMovement ("Wind Movement", Vector) = (6, 0, 0, 0) } SubShader { Tags { "RenderType" = "Opaque" "RenderPipeline" = "UniversalPipeline" "Queue" = "Geometry" } HLSLINCLUDE #include "Packages/com.unity.render-pipelines.universal/ShaderLibrary/Core.hlsl" #include "WLVividCommon.hlsl" struct WLInstanceData { float4x4 TRS; float3 normal; }; StructuredBuffer _InstanceData; float4x4 _LocalToWorld; void WLGrassSetup() { } CBUFFER_START(UnityPerMaterial) half4 _GrassRoot, _GrassTip, _GrassShadowRoot, _GrassShadowTip, _PatchTint, _PatchCoolTint, _AltTip; float _TipPower, _BladeHeight, _PatchScale, _PatchStrength, _Jitter, _AltChance; float _RampThreshold, _RampSoftness, _AmbientStrength; float _WindStrength, _WindDensity; float4 _WindMovement; CBUFFER_END struct Attributes { float4 positionOS : POSITION; UNITY_VERTEX_INPUT_INSTANCE_ID }; // 인스턴스 → 월드(원본 셋업과 같은 식: 오브젝트 행렬 × _LocalToWorld × TRS) · 빌보드 · 바람 void WLGrassPlace(Attributes v, out float3 positionWS, out float3 originWS, out float3 groundN, out float h) { uint id = 0; #if UNITY_ANY_INSTANCING_ENABLED id = unity_InstanceID; #endif WLInstanceData d = _InstanceData[id]; float4x4 m = mul(GetObjectToWorldMatrix(), mul(_LocalToWorld, d.TRS)); originWS = float3(m._m03, m._m13, m._m23); float scale = length(float3(m._m00, m._m10, m._m20)); groundN = normalize(mul((float3x3)_LocalToWorld, d.normal) + float3(0, 1e-4, 0)); h = saturate(v.positionOS.y / max(_BladeHeight, 1e-3)); float2 offs = v.positionOS.xy * scale; float wn = WLValueNoise(originWS.xz * _WindDensity + _Time.y * _WindMovement.xy * 0.1) * 2.0 - 1.0; float s, c; sincos(wn * _WindStrength * h, s, c); offs = float2(offs.x * c - offs.y * s, offs.x * s + offs.y * c); float3 right = float3(UNITY_MATRIX_I_V._m00, UNITY_MATRIX_I_V._m10, UNITY_MATRIX_I_V._m20); float3 up = float3(UNITY_MATRIX_I_V._m01, UNITY_MATRIX_I_V._m11, UNITY_MATRIX_I_V._m21); positionWS = originWS + right * offs.x + up * offs.y; } ENDHLSL Pass { Name "Forward" Tags { "LightMode" = "UniversalForward" } Cull Off ZWrite On HLSLPROGRAM #pragma target 4.5 #pragma vertex vert #pragma fragment frag #pragma multi_compile_instancing #pragma instancing_options procedural:WLGrassSetup #pragma multi_compile _ _MAIN_LIGHT_SHADOWS _MAIN_LIGHT_SHADOWS_CASCADE _MAIN_LIGHT_SHADOWS_SCREEN #pragma multi_compile_fragment _ _SHADOWS_SOFT #include "Packages/com.unity.render-pipelines.universal/ShaderLibrary/Lighting.hlsl" struct Varyings { float4 positionCS : SV_POSITION; float3 positionWS : TEXCOORD0; half3 litColor : TEXCOORD1; half3 shadowColor : TEXCOORD2; half ndl : TEXCOORD3; }; Varyings vert(Attributes v) { Varyings o = (Varyings)0; UNITY_SETUP_INSTANCE_ID(v); float3 posWS, originWS, n; float h; WLGrassPlace(v, posWS, originWS, n, h); o.positionWS = posWS; o.positionCS = TransformWorldToHClip(posWS); float t = pow(h, _TipPower); float hc = WLHash21(floor(originWS.xz * 7.0)); // 포기 하나의 고정 난수 half3 tipCol = (WLHash21(floor(originWS.xz * 7.0) + 13.7) < _AltChance) ? _AltTip.rgb : _GrassTip.rgb; half3 lit = lerp(_GrassRoot.rgb, tipCol, t); half3 shd = lerp(_GrassShadowRoot.rgb, _GrassShadowTip.rgb, t); // 큰 얼룩 — 월드 좌표 잡음: 높은 곳 = 따뜻한 노란 무리 · 낮은 곳 = 서늘한 청록 무리 · 끝 쪽일수록 세게 float pn = WLFbm2(originWS.xz * _PatchScale); float warm = smoothstep(0.5, 0.75, pn); float cool = smoothstep(0.5, 0.25, pn); float k = _PatchStrength * (0.35 + 0.65 * t); half3 tint = half3(1, 1, 1) + (_PatchTint.rgb - 1.0) * warm * k + (_PatchCoolTint.rgb - 1.0) * cool * k; // 포기마다 작은 밝기 흔들림 half jit = 1.0 + (hc - 0.5) * _Jitter; lit *= tint * jit; shd *= lerp(half3(1, 1, 1), tint, 0.5) * jit; // 그늘 쪽 하늘빛(SH) 조금 shd += SampleSH(n) * _AmbientStrength; o.litColor = lit; o.shadowColor = shd; o.ndl = saturate(dot(n, GetMainLight().direction)); return o; } half4 frag(Varyings i) : SV_Target { Light L = GetMainLight(TransformWorldToShadowCoord(i.positionWS)); half lit = i.ndl * L.shadowAttenuation; half ramp = smoothstep(_RampThreshold - _RampSoftness, _RampThreshold + _RampSoftness, lit); return half4(lerp(i.shadowColor, i.litColor, ramp), 1); } ENDHLSL } Pass { Name "DepthOnly" Tags { "LightMode" = "DepthOnly" } Cull Off ZWrite On ColorMask R HLSLPROGRAM #pragma target 4.5 #pragma vertex vertDepth #pragma fragment fragDepth #pragma multi_compile_instancing #pragma instancing_options procedural:WLGrassSetup float4 vertDepth(Attributes v) : SV_POSITION { UNITY_SETUP_INSTANCE_ID(v); float3 posWS, originWS, n; float h; WLGrassPlace(v, posWS, originWS, n, h); return TransformWorldToHClip(posWS); } half4 fragDepth() : SV_Target { return 0; } ENDHLSL } } FallBack Off }