GameCrew AIEarly access
Sign in
Unity 6VFXRevision 1 · Compile-verified pattern

Hex Forcefields, Emissive Noise Dissolve & Stylized Slash VFX in Unity 6 URP

Textureless URP 17 HLSL combat and sci-fi VFX trio: depth-intersecting hexagonal forcefield with impact ripples, shadow-aware HDR emissive dissolve, stylized melee slash arcs, and a zero-allocation MaterialPropertyBlock driver.

  • forcefield
  • shield
  • hex
  • dissolve
  • slash
  • vfx
  • impact
  • ripple
  • shader
  • urp
  • bloom

No demo.

When to Use & Field Best Practices

Combat, sci-fi defense, and boss encounters feel flat when enemies vanish instantaneously or shields look like plain translucent spheres. Three lightweight, zero-texture URP 17 HLSL shaders give crisp visual feedback that triggers URP Bloom naturally and runs smoothly on WebGL 2 and Quest VR:

  1. Procedural Hex Forcefield (Custom/HexForcefield): Computes a crisp procedural hexagon distance field in object/UV space (no tiling PNG needed), adds Fresnel silhouette energy + _CameraDepthTexture floor/wall intersection glow, and animates a world-space expanding hit ripple (_HitPos, _HitTime) whenever a projectile lands.
  2. Shadow-Aware Emissive Dissolve (Custom/EmissiveNoiseDissolve): Combines procedural 3D value noise with an optional world-height wipe and a bright HDR burn rim (_EdgeColor at intensity 2.5–4.0 so URP Bloom picks it up). Includes a matching ShadowCaster pass with the exact same clip(...) so dissolving enemies stop casting solid boxy shadows mid-disintegration.
  3. UV-Scrolled Stylized Slash Arc (Custom/StylizedSlashArc): Drives a curved ribbon/crescent mesh with a single 0 -> 1 progress parameter (_SlashProgress) so sword swipes and boss telegraphs sweep smoothly across an arc with jagged eroded tails and a hot leading edge.
  4. Zero-Allocation MaterialPropertyBlock Driver: Never access renderer.material per hit (which instantiates leaked material copies); push _Dissolve, _HitPos, and _SlashProgress through a shared MaterialPropertyBlock.

Mathematical & Algorithmic Core

  • Hexagonal Grid Edge Distance: Fold planar coordinates onto two offset rectangular lattices a = mod(p, r) - tfrac12r, b = mod(p - tfrac12r, r) - tfrac12r where r = (1, √3), choose the closer center g, and evaluate edge distance d_edge = 0.5 - max(g·(0.5, tfrac√32),\, |g_x|).
  • Expanding Impact Ring: For hit center h and elapsed age τ: $r(p, τ) = exp\!(-(frac|p - h| - vτw)^2)· (1 - τ)^2$

Engine Implementation

1. Procedural Hex Forcefield Shader (Assets/Game/Resources/Shaders/HexForcefield.shader)

Shader "Custom/HexForcefield"
{
    Properties
    {
        [HDR] _ShieldColor ("Shield Color (HDR)", Color) = (0.18, 0.85, 1.5, 0.55)
        [HDR] _HitColor ("Impact Ripple Color (HDR)", Color) = (1.8, 0.95, 0.35, 1.0)
        _HexParams ("HexScale, LineWidth, FresnelPow, IntersectDepth", Vector) = (10.0, 0.06, 2.8, 0.55)
        _HitPos ("Hit World Pos (xyz) & Age 0..1 (w)", Vector) = (0.0, 0.0, 0.0, 1.0)
    }
    SubShader
    {
        Tags { "RenderPipeline" = "UniversalPipeline" "Queue" = "Transparent" "RenderType" = "Transparent" }
        Pass
        {
            Name "HexForcefieldForward"
            Tags { "LightMode" = "UniversalForward" }
            Blend SrcAlpha One
            ZWrite Off
            Cull Off

            HLSLPROGRAM
            #pragma vertex vert
            #pragma fragment frag
            #pragma multi_compile_instancing

            #include "Packages/com.unity.render-pipelines.universal/ShaderLibrary/Core.hlsl"
            #include "Packages/com.unity.render-pipelines.universal/ShaderLibrary/DeclareDepthTexture.hlsl"

            CBUFFER_START(UnityPerMaterial)
                half4 _ShieldColor;
                half4 _HitColor;
                float4 _HexParams;
                float4 _HitPos;
            CBUFFER_END

            struct Attributes
            {
                float4 positionOS : POSITION;
                float3 normalOS : NORMAL;
                float2 uv : TEXCOORD0;
                UNITY_VERTEX_INPUT_INSTANCE_ID
            };

            struct Varyings
            {
                float4 positionCS : SV_POSITION;
                float3 positionWS : TEXCOORD0;
                float3 normalWS : TEXCOORD1;
                float2 uv : TEXCOORD2;
                float4 screenPos : TEXCOORD3;
                UNITY_VERTEX_INPUT_INSTANCE_ID
            };

            float HexEdgeDist(float2 p)
            {
                const float2 r = float2(1.0, 1.7320508);
                const float2 h = r * 0.5;
                float2 a = p - r * floor(p / r) - h;
                float2 b = (p - h) - r * floor((p - h) / r) - h;
                float2 g = dot(a, a) < dot(b, b) ? a : b;
                float2 ag = abs(g);
                float d = max(dot(ag, normalize(float2(1.0, 1.7320508))), ag.x);
                return 0.5 - d;
            }

            Varyings vert(Attributes input)
            {
                Varyings o;
                UNITY_SETUP_INSTANCE_ID(input);
                UNITY_TRANSFER_INSTANCE_ID(input, o);
                VertexPositionInputs pos = GetVertexPositionInputs(input.positionOS.xyz);
                o.positionCS = pos.positionCS;
                o.positionWS = pos.positionWS;
                o.normalWS = TransformObjectToWorldNormal(input.normalOS);
                o.uv = input.uv;
                o.screenPos = ComputeScreenPos(pos.positionCS);
                return o;
            }

            half4 frag(Varyings input) : SV_Target
            {
                UNITY_SETUP_INSTANCE_ID(input);
                float3 N = normalize(input.normalWS);
                float3 V = normalize(GetCameraPositionWS() - input.positionWS);
                float fresnel = pow(1.0 - saturate(abs(dot(N, V))), _HexParams.z);

                float edge = HexEdgeDist(input.uv * _HexParams.x);
                float hexLine = 1.0 - smoothstep(_HexParams.y * 0.5, _HexParams.y, edge);
                float pulse = 0.72 + 0.28 * sin(_Time.y * 3.0 + input.positionWS.y * 2.5);

                float2 screenUV = input.screenPos.xy / max(1e-4, input.screenPos.w);
                float sceneEye = LinearEyeDepth(SampleSceneDepth(screenUV), _ZBufferParams);
                float fragEye = LinearEyeDepth(input.positionCS.z, _ZBufferParams);
                float intersect = 1.0 - saturate((sceneEye - fragEye) / max(0.05, _HexParams.w));

                float age = saturate(_HitPos.w);
                float hitDist = length(input.positionWS - _HitPos.xyz);
                float ring = exp(-pow((hitDist - age * 2.6) / 0.22, 2.0)) * (1.0 - age) * (1.0 - age);

                float energy = saturate(fresnel * 0.85 + hexLine * (0.28 + 0.55 * fresnel) * pulse + intersect * 0.9);
                float3 col = _ShieldColor.rgb * energy + _HitColor.rgb * ring * (0.5 + hexLine);
                float alpha = saturate((energy + ring) * _ShieldColor.a);
                return half4(col, alpha);
            }
            ENDHLSL
        }
    }
}

2. Shadow-Aware Emissive Noise Dissolve (Assets/Game/Resources/Shaders/EmissiveNoiseDissolve.shader)

Shader "Custom/EmissiveNoiseDissolve"
{
    Properties
    {
        _BaseColor ("Base Color", Color) = (0.72, 0.76, 0.82, 1.0)
        [HDR] _EdgeColor ("Burn Edge (HDR)", Color) = (2.8, 0.95, 0.22, 1.0)
        _Dissolve ("Dissolve Amount", Range(0.0, 1.0)) = 0.0
        _EdgeWidth ("Burn Edge Width", Range(0.01, 0.25)) = 0.08
        _NoiseScale ("Noise Scale", Float) = 3.5
    }
    SubShader
    {
        Tags { "RenderPipeline" = "UniversalPipeline" "RenderType" = "Opaque" "Queue" = "AlphaTest" }

        Pass
        {
            Name "DissolveForward"
            Tags { "LightMode" = "UniversalForward" }
            Cull Off

            HLSLPROGRAM
            #pragma vertex vert
            #pragma fragment frag
            #pragma multi_compile _ _MAIN_LIGHT_SHADOWS _MAIN_LIGHT_SHADOWS_CASCADE
            #pragma multi_compile_instancing

            #include "Packages/com.unity.render-pipelines.universal/ShaderLibrary/Core.hlsl"
            #include "Packages/com.unity.render-pipelines.universal/ShaderLibrary/Lighting.hlsl"

            CBUFFER_START(UnityPerMaterial)
                half4 _BaseColor;
                half4 _EdgeColor;
                float _Dissolve;
                float _EdgeWidth;
                float _NoiseScale;
            CBUFFER_END

            struct Attributes
            {
                float4 positionOS : POSITION;
                float3 normalOS : NORMAL;
                UNITY_VERTEX_INPUT_INSTANCE_ID
            };

            struct Varyings
            {
                float4 positionCS : SV_POSITION;
                float3 positionWS : TEXCOORD0;
                float3 positionOS : TEXCOORD1;
                float3 normalWS : TEXCOORD2;
                UNITY_VERTEX_INPUT_INSTANCE_ID
            };

            float Hash31(float3 p)
            {
                p = frac(p * 0.1031);
                p += dot(p, p.yzx + 33.33);
                return frac((p.x + p.y) * p.z);
            }

            float ValueNoise3D(float3 p)
            {
                float3 i = floor(p);
                float3 f = frac(p);
                f = f * f * (3.0 - 2.0 * f);
                float n000 = Hash31(i + float3(0, 0, 0));
                float n100 = Hash31(i + float3(1, 0, 0));
                float n010 = Hash31(i + float3(0, 1, 0));
                float n110 = Hash31(i + float3(1, 1, 0));
                float n001 = Hash31(i + float3(0, 0, 1));
                float n101 = Hash31(i + float3(1, 0, 1));
                float n011 = Hash31(i + float3(0, 1, 1));
                float n111 = Hash31(i + float3(1, 1, 1));
                float nx00 = lerp(n000, n100, f.x);
                float nx10 = lerp(n010, n110, f.x);
                float nx01 = lerp(n001, n101, f.x);
                float nx11 = lerp(n011, n111, f.x);
                return lerp(lerp(nx00, nx10, f.y), lerp(nx01, nx11, f.y), f.z);
            }

            Varyings vert(Attributes input)
            {
                Varyings o;
                UNITY_SETUP_INSTANCE_ID(input);
                UNITY_TRANSFER_INSTANCE_ID(input, o);
                VertexPositionInputs pos = GetVertexPositionInputs(input.positionOS.xyz);
                o.positionCS = pos.positionCS;
                o.positionWS = pos.positionWS;
                o.positionOS = input.positionOS.xyz;
                o.normalWS = TransformObjectToWorldNormal(input.normalOS);
                return o;
            }

            half4 frag(Varyings input) : SV_Target
            {
                UNITY_SETUP_INSTANCE_ID(input);
                float n = ValueNoise3D(input.positionOS * _NoiseScale) * 0.72 +
                          ValueNoise3D(input.positionOS * _NoiseScale * 2.1) * 0.28;
                float cutoff = _Dissolve * 1.02 - 0.01;
                float diff = n - cutoff;
                clip(diff);

                float edge = 1.0 - smoothstep(0.0, max(0.005, _EdgeWidth), diff);
                edge *= step(0.002, _Dissolve);

                float3 N = normalize(input.normalWS);
                Light mainLight = GetMainLight(TransformWorldToShadowCoord(input.positionWS));
                float ndl = saturate(dot(N, mainLight.direction)) * mainLight.shadowAttenuation;
                float3 lit = _BaseColor.rgb * (SampleSH(N) + mainLight.color * ndl);
                return half4(lit + _EdgeColor.rgb * edge, 1.0);
            }
            ENDHLSL
        }

        Pass
        {
            Name "ShadowCaster"
            Tags { "LightMode" = "ShadowCaster" }
            ZWrite On
            ZTest LEqual
            ColorMask 0
            Cull Off

            HLSLPROGRAM
            #pragma vertex vertShadow
            #pragma fragment fragShadow
            #pragma multi_compile_instancing

            #include "Packages/com.unity.render-pipelines.universal/ShaderLibrary/Core.hlsl"

            CBUFFER_START(UnityPerMaterial)
                half4 _BaseColor;
                half4 _EdgeColor;
                float _Dissolve;
                float _EdgeWidth;
                float _NoiseScale;
            CBUFFER_END

            struct Attributes
            {
                float4 positionOS : POSITION;
                UNITY_VERTEX_INPUT_INSTANCE_ID
            };

            struct Varyings
            {
                float4 positionCS : SV_POSITION;
                float3 positionOS : TEXCOORD0;
                UNITY_VERTEX_INPUT_INSTANCE_ID
            };

            float Hash31(float3 p)
            {
                p = frac(p * 0.1031);
                p += dot(p, p.yzx + 33.33);
                return frac((p.x + p.y) * p.z);
            }

            float ValueNoise3D(float3 p)
            {
                float3 i = floor(p);
                float3 f = frac(p);
                f = f * f * (3.0 - 2.0 * f);
                float n000 = Hash31(i + float3(0, 0, 0));
                float n100 = Hash31(i + float3(1, 0, 0));
                float n010 = Hash31(i + float3(0, 1, 0));
                float n110 = Hash31(i + float3(1, 1, 0));
                float n001 = Hash31(i + float3(0, 0, 1));
                float n101 = Hash31(i + float3(1, 0, 1));
                float n011 = Hash31(i + float3(0, 1, 1));
                float n111 = Hash31(i + float3(1, 1, 1));
                return lerp(lerp(lerp(n000, n100, f.x), lerp(n010, n110, f.x), f.y),
                            lerp(lerp(n001, n101, f.x), lerp(n011, n111, f.x), f.y), f.z);
            }

            Varyings vertShadow(Attributes input)
            {
                Varyings o;
                UNITY_SETUP_INSTANCE_ID(input);
                UNITY_TRANSFER_INSTANCE_ID(input, o);
                o.positionCS = TransformObjectToHClip(input.positionOS.xyz);
                o.positionOS = input.positionOS.xyz;
                return o;
            }

            half4 fragShadow(Varyings input) : SV_Target
            {
                UNITY_SETUP_INSTANCE_ID(input);
                float n = ValueNoise3D(input.positionOS * _NoiseScale) * 0.72 +
                          ValueNoise3D(input.positionOS * _NoiseScale * 2.1) * 0.28;
                clip(n - (_Dissolve * 1.02 - 0.01));
                return 0;
            }
            ENDHLSL
        }
    }
}

3. UV-Scrolled Stylized Slash Arc Shader (Assets/Game/Resources/Shaders/StylizedSlashArc.shader)

Shader "Custom/StylizedSlashArc"
{
    Properties
    {
        [HDR] _LeadColor ("Leading Edge (HDR)", Color) = (2.6, 1.9, 0.75, 1.0)
        [HDR] _TrailColor ("Trail Color (HDR)", Color) = (0.35, 0.85, 1.6, 0.85)
        _SlashProgress ("Slash Progress 0..1", Range(0.0, 1.0)) = 0.5
        _ArcLength ("Arc Span", Range(0.15, 0.85)) = 0.42
    }
    SubShader
    {
        Tags { "RenderPipeline" = "UniversalPipeline" "Queue" = "Transparent" "RenderType" = "Transparent" }
        Pass
        {
            Name "StylizedSlashForward"
            Tags { "LightMode" = "UniversalForward" }
            Blend SrcAlpha One
            ZWrite Off
            Cull Off

            HLSLPROGRAM
            #pragma vertex vert
            #pragma fragment frag
            #pragma multi_compile_instancing

            #include "Packages/com.unity.render-pipelines.universal/ShaderLibrary/Core.hlsl"

            CBUFFER_START(UnityPerMaterial)
                half4 _LeadColor;
                half4 _TrailColor;
                float _SlashProgress;
                float _ArcLength;
            CBUFFER_END

            struct Attributes
            {
                float4 positionOS : POSITION;
                float2 uv : TEXCOORD0;
                UNITY_VERTEX_INPUT_INSTANCE_ID
            };

            struct Varyings
            {
                float4 positionCS : SV_POSITION;
                float2 uv : TEXCOORD0;
                UNITY_VERTEX_INPUT_INSTANCE_ID
            };

            Varyings vert(Attributes input)
            {
                Varyings o;
                UNITY_SETUP_INSTANCE_ID(input);
                UNITY_TRANSFER_INSTANCE_ID(input, o);
                o.positionCS = TransformObjectToHClip(input.positionOS.xyz);
                o.uv = input.uv;
                return o;
            }

            half4 frag(Varyings input) : SV_Target
            {
                UNITY_SETUP_INSTANCE_ID(input);
                float head = lerp(-0.1, 1.1 + _ArcLength, _SlashProgress);
                float along = (head - input.uv.x) / max(0.05, _ArcLength);
                float inArc = step(0.0, along) * (1.0 - step(1.0, along));

                float jag = sin(input.uv.y * 28.0 + input.uv.x * 16.0) * 0.14;
                float widthMask = smoothstep(0.0, 0.25, input.uv.y) * smoothstep(1.0, 0.55, input.uv.y + along * 0.35 + jag);
                float tailFade = pow(saturate(1.0 - along), 1.6);
                float leadBand = exp(-pow(along / 0.16, 2.0));

                float alpha = inArc * widthMask * tailFade;
                float3 col = lerp(_TrailColor.rgb, _LeadColor.rgb, leadBand);
                return half4(col * alpha, alpha);
            }
            ENDHLSL
        }
    }
}

4. Zero-Allocation VFX Driver (Assets/Game/Runtime/Rendering/VfxShaderDriver.cs)

using UnityEngine;

namespace __NS__
{
    /// <summary>
    /// Drives forcefield impact ripples, noise dissolve transitions, and slash arc progress
    /// via MaterialPropertyBlock (zero runtime material clones, TestClock-safe scaled deltaTime).
    /// </summary>
    public sealed class VfxShaderDriver : MonoBehaviour
    {
        static readonly int DissolveId = Shader.PropertyToID("_Dissolve");
        static readonly int HitPosId = Shader.PropertyToID("_HitPos");
        static readonly int SlashProgressId = Shader.PropertyToID("_SlashProgress");

        Renderer targetRenderer;
        MaterialPropertyBlock mpb;
        Vector3 hitWorldPos;
        float hitAge = 1f;
        float hitDuration = 0.45f;
        float dissolve;
        float dissolveSpeed;
        float slashProgress = 1f;
        float slashSpeed;

        void Awake()
        {
            targetRenderer = GetComponent<Renderer>();
            mpb = new MaterialPropertyBlock();
        }

        public void TriggerShieldHit(Vector3 worldPoint, float durationSeconds = 0.45f)
        {
            hitWorldPos = worldPoint;
            hitAge = 0f;
            hitDuration = Mathf.Max(0.05f, durationSeconds);
            PushProperties();
        }

        public void StartDissolve(float durationSeconds = 0.75f)
        {
            dissolve = 0.01f;
            dissolveSpeed = 1f / Mathf.Max(0.05f, durationSeconds);
            PushProperties();
        }

        public void PlaySlash(float durationSeconds = 0.22f)
        {
            slashProgress = 0f;
            slashSpeed = 1f / Mathf.Max(0.04f, durationSeconds);
            PushProperties();
        }

        void Update()
        {
            bool dirty = false;
            if (hitAge < 1f)
            {
                hitAge = Mathf.Min(1f, hitAge + Time.deltaTime / hitDuration);
                dirty = true;
            }
            if (dissolveSpeed > 0f && dissolve < 1f)
            {
                dissolve = Mathf.Min(1f, dissolve + Time.deltaTime * dissolveSpeed);
                dirty = true;
            }
            if (slashSpeed > 0f && slashProgress < 1f)
            {
                slashProgress = Mathf.Min(1f, slashProgress + Time.deltaTime * slashSpeed);
                dirty = true;
            }
            if (dirty) PushProperties();
        }

        void PushProperties()
        {
            if (targetRenderer == null || mpb == null) return;
            targetRenderer.GetPropertyBlock(mpb);
            mpb.SetFloat(DissolveId, dissolve);
            mpb.SetVector(HitPosId, new Vector4(hitWorldPos.x, hitWorldPos.y, hitWorldPos.z, hitAge));
            mpb.SetFloat(SlashProgressId, slashProgress);
            targetRenderer.SetPropertyBlock(mpb);
        }
    }
}

Browser, Mobile & Software-Renderer Budgets

  • Zero Texture Memory: Both shaders are 100% procedural math (< 0.1 ms per shield/enemy on WebGL 2 & Quest VR) with full SRP Batcher compatibility (CBUFFER_START(UnityPerMaterial)).
  • HDR Bloom Coupling: Keep _EdgeColor and _HitColor HDR values at 2.0–3.5 so URP Bloom fires cleanly without blowing out nearby surfaces.
  • TestClock Determinism: VfxShaderDriver steps on Time.deltaTime so PlayMode tests running at 3x TestClock speed observe accurate impact and dissolve completions.

Verification Checklist

  1. Run compile to verify both URP HLSL shaders and VfxShaderDriver.cs compile cleanly with zero warnings.
  2. Trigger StartDissolve(0.6f) on a test prop and confirm the glowing burn rim appears and its cast shadow dissolves in sync.
  3. Trigger TriggerShieldHit(point) on a sphere using Custom/HexForcefield and verify the glowing ground intersection ring and expanding ripple in Captures/*.png.

Official references

  • AdultLink — HoloShield (MIT)
  • Daniel Ilett — dissolve-urp (MIT)
  • KwNetzwelt — unity3d-dissolve-shader (MIT)
  • reeboolabs — Stylized Slash VFX Reference (MIT)

Open-source sources

Games built with this guide carry these credits, and the licence notices they ask for, in their third-party notices.

More Unity 6 games

Games made with GameCrew on the same engine. No game has been built with this guide yet: these show what Unity 6 games here look like.

Thin Air Errands — Three hundred metres up, with a storm on the way, you carry your own plank between rooftops, lay it across the gap, and walk it with your arms out.
Plays in VR

Thin Air Errands

Three hundred metres up, with a storm on the way, you carry your own plank between rooftops, lay it across the gap, and walk it with your arms out.

Fjordline — Leap from a granite wall under the midnight sun and carve one unbroken wingsuit line through Norway's most dramatic landscapes, from summit to sea, skimming close enough to touch the rock.

Fjordline

Leap from a granite wall under the midnight sun and carve one unbroken wingsuit line through Norway's most dramatic landscapes, from summit to sea, skimming close enough to touch the rock.

More Unity 6 techniques

ai

Context Steering, Telegraphed Combat & Attack-Token Encounters in Unity 6 →

Readable enemy and companion AI in Unity 6 using 8-ray context steering maps, FOV + line-of-sight hysteresis, telegraph/active/recovery state machines, and an encounter attack-token director.

rendering

Seamless Non-Euclidean Portals & Oblique Near-Plane Clipping in Unity 6 URP →

Seamless paired 3D portals in Unity 6 URP 17 using screen-space UV projection, relative camera transform mirroring, exact Camera.CalculateObliqueMatrix near-plane clipping, and software-GPU target scaling.

gameplay

Frame-Rate-Independent Procedural Springs, Squash-Stretch & Trauma Feel in Unity 6 →

Exact dt-invariant second-order critically/under-damped spring dampers, Squirrel Eiserloh T^2 rotational Perlin camera trauma, volume-preserving squash-and-stretch, and TestClock-safe hit-stop.

rendering

Khronos PBR Neutral Tone Mapping & 2D Radiance Cascades GI in Unity 6 URP →

Hue-preserving Khronos PBR Neutral display transform via Unity 6 URP 17.6 RenderGraph (preventing ACES red/blue hue shifts on stylized palettes) paired with a WebGL-2-safe fragment Radiance Cascades 2D GI shader.

Use verified techniques inside a real game

Describe your game idea for free or connect an MCP assistant to search and contribute techniques.

Learn about collaboration