Procedural WebGL plants: point-lines, seeded randomness, shading
10 steps · about 5 h 35 min · Intermediate
- WebGL Tutorials Overview (tutorial, Adam Murray, 30 min)
It starts with the shader concept and uses no libraries, so you can read raw WebGL code like the lily sketch's.
- WebGL2 Fundamentals (tutorial, webgl2fundamentals.org, 40 min)
It covers buffers, vertex and fragment shaders, and drawing points and lines, which is how the lily is built.
- The Book of Shaders: Shaping functions (interactive, Patricio Gonzalez Vivo & Jen Lowe, 30 min)
You can edit examples live and see how smoothstep shapes values, a helper the lily code defines itself.
- The Book of Shaders: smoothstep (reference, The Book of Shaders, 5 min)
It gives the exact clamp-then-cubic formula, so you can match it to the one-line version in the lily source.
- Smoothstep (article, Wikipedia, 10 min)
It explains why the slope is zero at both edges, which is why smoothstep blends petal colours without hard seams.
- Linear congruential generator (article, Wikipedia, 15 min)
The sketch uses a tiny LCG seeded with a fixed number, so the same lily draws every time. This page explains that pattern.
- Marsaglia's theorem (article, Wikipedia, 10 min)
It shows why LCGs are fine for decorative art but weak for simulation or security, so you know their limits.
- WebGL2 Fundamentals (table of contents) (reference, webgl2fundamentals.org, 1 h)
Its directional-lighting lessons explain the light-direction vector and shading used to make the points look solid.
- The Algorithmic Beauty of Plants (reference, Prusinkiewicz & Lindenmayer, algorithmicbotany.org, 1 h 30 min)
This is the classic free book on modelling plant growth and form with code, which goes beyond hand-placed petals.
- lily/lily.html at main · Kenzamn/lily (repo, GitHub (Kenzamn), 45 min)
You can now read the whole sketch and trace how seeded randomness, an addLily function, smoothing and lighting combine into the flower.