diff options
| author | Matt Kosarek <matt.kosarek@canonical.com> | 2026-02-03 08:13:30 -0500 |
|---|---|---|
| committer | Matt Kosarek <matt.kosarek@canonical.com> | 2026-02-03 08:13:30 -0500 |
| commit | b4e8ae9731eca175cd4e6e75a20da87ff86eb91f (patch) | |
| tree | 95b1156031ed70e6bb91f5c58a03c75ad3722593 /themes/src/_shaders/snowflake.vert | |
| parent | 1b0fbb1818d6a9cd721366909275aaefb7de4c64 (diff) | |
Diffstat (limited to 'themes/src/_shaders/snowflake.vert')
| -rw-r--r-- | themes/src/_shaders/snowflake.vert | 30 |
1 files changed, 30 insertions, 0 deletions
diff --git a/themes/src/_shaders/snowflake.vert b/themes/src/_shaders/snowflake.vert new file mode 100644 index 0000000..7cbfb99 --- /dev/null +++ b/themes/src/_shaders/snowflake.vert @@ -0,0 +1,30 @@ +// Instanced snowflake vertex shader +attribute vec2 position; // Base quad vertex position +attribute vec2 instancePos; // Per-instance: snowflake center position +attribute float instanceRot; // Per-instance: rotation angle +attribute float instanceScale; // Per-instance: size scale +attribute float instanceSeed; // Per-instance: random seed for variation + +uniform mat4 projection; +uniform mat4 model; + +varying lowp vec2 vUV; // UV coordinates for fragment shader +varying lowp float vSeed; // Pass seed to fragment shader +varying lowp float vScale; // Pass scale to fragment shader + +void main() { + // Rotate and scale the base quad + float c = cos(instanceRot); + float s = sin(instanceRot); + mat2 rotation = mat2(c, s, -s, c); + + vec2 rotatedPos = rotation * (position * instanceScale); + vec2 worldPos = instancePos + rotatedPos; + + gl_Position = projection * model * vec4(worldPos, 0.0, 1.0); + + // Pass UV in range [-1, 1] for procedural generation + vUV = position; + vSeed = instanceSeed; + vScale = instanceScale; +} |
