← COURSE LIBRARY
Shader Code · 25 min

Smoothstep, Masks and Readable Edges

BeginnerNeeds: LERP
Sign in to record mastery, quiz results and reviews for this course.Sign in

You will be able to

  • Use smoothstep to convert any scalar field into a controllable mask.
  • Choose edge widths that stay stable across resolutions.
  • Explain the difference between step, smoothstep and a linear ramp.

The concept

smoothstep(a, b, x) remaps x into 0..1 with a Hermite ease at both ends. It is the workhorse of masking: dissolve edges, cone falloffs, height blends, wear masks. A hard step aliases; a linear ramp looks mechanical; smoothstep gives a C1-continuous edge whose width you can drive from an artist parameter.

In your engine

Smoothstep node, or `smoothstep(edge0, edge1, x)` in HLSL.

Practice (4)

Tune the value
smoothstep(0, 1, 0.5) returns what value?
Predict the result
smoothstep(0.4, 0.6, x) with x = 0.2 returns:
Complete the code
Write the expression that produces a mask which is 1 inside radius r and fades out over width w, given distance d.
Concept check
A dissolve edge shimmers on thin geometry at distance. Best first fix?

Knowledge check

01smoothstep is continuous in:
02step() aliases because:
03fwidth(x) approximates:
04To invert a mask you:

Build challenge

Make a mask that stays exactly one pixel soft at any camera distance using fwidth-derived edge width. Compare it against a fixed-width smoothstep in a fly-through and capture both.

SELF-CHECK RUBRIC

Your mastery state

Apply it in a guided project