skia2/resources/particles/warp.json
Brian Osman e59acb79b8 Particles: Merge spawn & update into one code string with two functions
Change-Id: If57fb79db8f8c5fd185fefaa202167c8082dd846
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/229921
Reviewed-by: Mike Klein <mtklein@google.com>
Commit-Queue: Brian Osman <brianosman@google.com>
2019-07-25 23:51:07 +00:00

49 lines
1.1 KiB
JSON

{
"MaxCount": 4096,
"Duration": 1,
"Rate": 90,
"Drawable": {
"Type": "SkCircleDrawable",
"Radius": 2
},
"Code": [
"",
"// float rand; Every read returns a random float [0 .. 1)",
"layout(ctype=float) in uniform float dt;",
"layout(ctype=float) in uniform float effectAge;",
"",
"struct Particle {",
" float age;",
" float lifetime;",
" float2 pos;",
" float2 dir;",
" float scale;",
" float2 vel;",
" float spin;",
" float4 color;",
" float frame;",
"};",
"",
"float2 circle() {",
" float x;",
" float y;",
" do {",
" x = rand * 2 - 1;",
" y = rand * 2 - 1;",
" } while (x*x + y*y > 1);",
" return float2(x, y);",
"}",
"",
"void spawn(inout Particle p) {",
" p.lifetime = 30;",
" p.pos = circle() * 40;",
"}",
"",
"void update(inout Particle p) {",
" p.vel += normalize(p.pos) * dt * 10;",
" p.scale = mix(0.25, 3, p.age);",
"}",
""
],
"Bindings": []
}