Fragment Shader Piece
You'll write a program that runs once per pixel and draws a whole piece at once, with your own noise, a palette you wrote and ten stills you'd print.
About
A fragment shader runs your code once per pixel, all at the same time, which is why a full-screen piece that would take a sketch minutes runs at sixty frames a second on a phone. The cost is a different way of thinking: no loops over shapes, only a function from a pixel's position to a color. If you've never written one, the first chapters of The Book of Shaders (free online) get you from a gradient to a circle in an evening, and this badge starts after that. The trick that makes shader art look like shader art is domain warping, where you feed noise into the coordinates of more noise, and you'll write the hash and noise functions yourself this time so you know what they cost. Distance-field shapes, ray tracers and lit 3D scenes are over in Graphics Programming; this is 2D pattern as a medium.
At a glance
- Per requirement
- 35 XP
- Completion bonus
- 300 XP
- Requirements
- 6
- Takes
- Three weeks
- Skill level
- Advanced (years of practice)
- Cost
- Free
- Supplies
- Nothing special
- Where
- At home
- Other people
- On your own
Requirements
-
1
Split the screen into cells and give each cell its own random mark. Multiply the normalized coordinates by 10, use fract() for the position inside each cell and floor() for the cell's id, and hash the id into a number that picks a rotation or a shape for that cell. It's Truchet again, except every cell draws at once, so 100 cells or 100,000 cost the same. Run it in p5.js with createShader, in Processing, or in glslViewer. Post a screenshot with the shader code. Photo
-
2
Write your own hash and value noise, then stack octaves into fbm. No copying the noise function this time. Sum four to six octaves, each at double the frequency and half the amplitude of the last. Post the plain noise next to the fbm. Photo
-
3
Warp the domain and animate it. Compute q = fbm(p), then r = fbm(p + 4 * q), then color by fbm(p + 4 * r), with time nudging one of the offsets. Film ten seconds of it moving. Video
-
4
Write a palette function and tune it to three moods. A cosine palette, a + b * cos(2 pi (c * t + d)) with four vectors, is enough. Post three stills of the same shader with three palettes and the vectors under each. Photo
-
5
Keep it under 16 milliseconds a frame on a phone. Open it in a phone's browser and check the frame rate. If it drops, cut octaves or resolution until it holds. Film it running on the phone with the frame counter visible. Video
-
6
Add a seed uniform and post ten stills you'd print. Pass a seed into the shader to offset the noise space, render ten seeds at 3000 pixels, and post them as a grid. Write which one goes on the wall. Photo