Command Palette

Search for a command to run...

Hectal
Back to the lesson: Topic 12.3 — Fragment Patterns
3D Web · Example 1 of 2

Stripes, a circle and a gradient, as text and as pixels

The three squares on screen use the same expressions as the text pictures.

With a UV coordinate and five functions (step, smoothstep, mix, fract, mod) you can draw stripes, circles and gradients without any image. The edge case to know is banding, and dithering fixes it.

Change the code and press Run (Ctrl+Enter). Predict what will happen first, then break it on purpose and read what changes. Your edits are saved and match the lesson page.

Ready for more? This phase has 5 hands-on exercises with automatic checks.

Practice questions

Write the code in the editor, run it, then open the model answer to compare.

01

Draw 8 horizontal stripes using uv.y.

02

Make a ring (a circle outline) with smoothstep.

Explain it without notes

01

Why is a smoothstep rim better than a step rim?

02

What causes banding and why does dithering hide it?

Stripes, a circle and a gradient, as text and as pixels
Press Run to see the page.
idle

Console

Nothing logged yet.

Expected console output

stripes:
     ###   ###   ###   ###
     ###   ###   ###   ###
     ###   ###   ###   ###
     ###   ###   ###   ###
     ###   ###   ###   ###
     ###   ###   ###   ###
     ###   ###   ###   ###
     ###   ###   ###   ###
     ###   ###   ###   ###
     ###   ###   ###   ###
circle:
                          
                          
         .########.       
       :############:     
       ##############     
       ##############     
       :############:     
         .########.       
                          
                          
gradient:
          ...::***########
          ...::***########
          ...::***########
          ...::***########
          ...::***########
          ...::***########
          ...::***########
          ...::***########
          ...::***########
          ...::***########