skia2/resources/particles/uniforms.json
Brian Osman 4d76f63e45 Fix particle bug where uniforms are allocated too late
Also adds an example particle system that uses uniforms, and an instance
of the particles GM that draws it.

Change-Id: I64e2514fd17c8ce615b4e13b9f82424f80b8424e
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/356840
Commit-Queue: Brian Osman <brianosman@google.com>
Reviewed-by: John Stiles <johnstiles@google.com>
2021-02-03 22:50:28 +00:00

32 lines
725 B
JSON

{
"MaxCount": 800,
"Drawable": {
"Type": "SkCircleDrawable",
"Radius": 2
},
"Code": [
"uniform float rate;",
"uniform float spin;",
"uniform float3 color;",
"",
"void effectSpawn(inout Effect effect) {",
" effect.lifetime = 4;",
"}",
"",
"void effectUpdate(inout Effect effect) {",
" effect.rate = 100 * rate;",
" effect.spin = spin;",
"}",
"",
"void spawn(inout Particle p) {",
" p.lifetime = 2 + rand(p.seed);",
" p.vel = p.dir * mix(50, 60, rand(p.seed));",
"}",
"",
"void update(inout Particle p) {",
" p.color.rgb = color;",
"}",
""
],
"Bindings": []
}