Horizontal Stripes
6 / 15
📝 Exercise Goal
Create horizontal stripes using fract() and step().
💡 💡 Tutorial Content
Create horizontal stripes using fract() and step().
Overview
- Create repeating stripes using
fractandstep.
Learning Objectives
- Build repeating patterns
Prerequisites
- uv-coordinates
Key Concepts
- Stripes come from repeating coordinates with
fractand converting them to a 0/1 mask.
float count = 12.0;
float v = fract(vUv.y * count);
float mask = step(0.5, v);
- Use
mixto select between two colors.
vec3 color = mix(colorA, colorB, mask);
How To Implement (Step-by-step)
- Repeat with
fract(vUv.y * count). - Convert to mask with
step(0.5, v). - Use
mixto switch colors by mask.
Self-check
- Does it compile without errors?
- Does the output match the goal?
- Are key values kept in
[0,1]?
Common Mistakes
- Clamp
tinto[0,1]when needed. - Change frequency by scaling before fract().