Skip to content
On this page

Step

step(edge, x) compares a value to a threshold and returns 0.0 or 1.0.
Great for hard masks, binary cutoffs, and stylized effects.

float step(float edge, float x);

Visual demo

This shader applies step() to the horizontal UV axis, creating a crisp vertical cutoff.

Shader Story: Function - Step

Node logic (engine-agnostic)

Shader Story: Function - Step


Try it live

The same threshold, live: drag the edge and watch the cutoff move.


Shader code
Shader "DecompiledArt/CommonFunctions/Step/Step"
{
    Properties
    {
        _Step("Step", Range(0.0 ,1.0)) = 1.0
    }

    SubShader
    {
        Tags { "RenderType"="Opaque" "RenderPipeline" = "UniversalPipeline" }

        Pass
        {
            HLSLPROGRAM
            #pragma vertex vert
            #pragma fragment frag

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

            struct Attributes
            {
                float4 positionOS : POSITION;
                half2 uvs: TEXCOORD0;
            };

            struct Varyings
            {
                float4 positionHCS : SV_POSITION;
                half2 uvs: TEXCOORD0;
            };

            CBUFFER_START(UnityPerMaterial)
            half _Step;
            CBUFFER_END

            Varyings vert (Attributes IN)
            {
                Varyings OUT;

                OUT.positionHCS = TransformObjectToHClip(IN.positionOS.xyz);
                OUT.uvs = IN.uvs;
                return OUT;
            }

            half4 frag(Varyings i) : SV_Target
            {
                half col_step = step(_Step, i.uvs.x);
                half4 col_output = half4(col_step, col_step, col_step, 1.0);
                return col_output;
            }

            ENDHLSL
        }
    }
}

Smoothstep • Remap • MinMax


❤️ Support Shader Story

If this article helped you, consider supporting the project on Patreon: you’ll get access to the related source files and reference cheat-sheets.

DecompiledArt on Patreon DecompiledArt on Buy Me a Coffee

Your support helps keep this library open and free for everyone.