Brian Osman | 647c7a9 | 2019-10-07 09:38:30 -0400 | [diff] [blame] | 1 | { |
| 2 | "MaxCount": 200, |
| 3 | "Drawable": { |
| 4 | "Type": "SkCircleDrawable", |
| 5 | "Radius": 8 |
| 6 | }, |
| 7 | "EffectCode": [ |
| 8 | "void effectSpawn(inout Effect effect) {", |
| 9 | " effect.lifetime = 2;", |
| 10 | "}", |
| 11 | "", |
| 12 | "void effectUpdate(inout Effect effect) {", |
| 13 | " if (effect.age < 0.25 || effect.age > 0.75) { effect.rate = 0; }", |
| 14 | " else { effect.rate = 200; }", |
| 15 | "}", |
| 16 | "" |
| 17 | ], |
| 18 | "Code": [ |
| 19 | "void spawn(inout Particle p) {", |
| 20 | " float3 colors[4];", |
| 21 | " colors[0] = float3(0.87, 0.24, 0.11);", |
| 22 | " colors[1] = float3(1, 0.9, 0.2);", |
| 23 | " colors[2] = float3(0.44, 0.73, 0.24);", |
| 24 | " colors[3] = float3(0.38, 0.54, 0.95);", |
Brian Osman | 95c26ef | 2020-02-10 13:45:22 -0500 | [diff] [blame] | 25 | " int idx = int(rand(p.seed) * 4);", |
Brian Osman | 647c7a9 | 2019-10-07 09:38:30 -0400 | [diff] [blame] | 26 | " p.color.rgb = colors[idx];", |
| 27 | "", |
| 28 | " p.lifetime = (1 - effect.age) * effect.lifetime;", |
Brian Osman | 95c26ef | 2020-02-10 13:45:22 -0500 | [diff] [blame] | 29 | " p.scale = mix(0.6, 1, rand(p.seed));", |
Brian Osman | 647c7a9 | 2019-10-07 09:38:30 -0400 | [diff] [blame] | 30 | "}", |
| 31 | "", |
| 32 | "void update(inout Particle p) {", |
| 33 | " p.color.a = 1 - p.age;", |
| 34 | "", |
Brian Osman | 95c26ef | 2020-02-10 13:45:22 -0500 | [diff] [blame] | 35 | " float a = radians(rand(p.seed) * 360);", |
Brian Osman | 647c7a9 | 2019-10-07 09:38:30 -0400 | [diff] [blame] | 36 | " float invAge = 1 - p.age;", |
Brian Osman | 95c26ef | 2020-02-10 13:45:22 -0500 | [diff] [blame] | 37 | " p.vel = float2(cos(a), sin(a)) * mix(250, 550, rand(p.seed)) * invAge * invAge;", |
Brian Osman | 647c7a9 | 2019-10-07 09:38:30 -0400 | [diff] [blame] | 38 | "}", |
| 39 | "" |
| 40 | ], |
| 41 | "Bindings": [] |
| 42 | } |