skia2/resources/particles/penguin_cannon.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

43 lines
1.0 KiB
JSON

{
"MaxCount": 32,
"Duration": 1,
"Rate": 0.5,
"Drawable": {
"Type": "SkImageDrawable",
"Path": "resources/images/baby_tux.png",
"Columns": 1,
"Rows": 1
},
"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;",
"};",
"",
"void spawn(inout Particle p) {",
" p.lifetime = 20;",
" float a = radians(10 + 60 * rand);",
" float s = 140 + rand * 60;",
" p.vel.x = cos(a) * s;",
" p.vel.y = -sin(a) * s;",
"}",
"",
"void update(inout Particle p) {",
" p.vel.y += 50 * dt;",
" p.dir = normalize(p.vel);",
"}",
""
],
"Bindings": []
}