• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1{
2   "MaxCount": 4096,
3   "Duration": 1,
4   "Rate": 90,
5   "Drawable": {
6      "Type": "SkCircleDrawable",
7      "Radius": 2
8   },
9   "Code": [
10      "",
11      "// float rand; Every read returns a random float [0 .. 1)",
12      "layout(ctype=float) in uniform float dt;",
13      "layout(ctype=float) in uniform float effectAge;",
14      "",
15      "struct Particle {",
16      "  float  age;",
17      "  float  lifetime;",
18      "  float2 pos;",
19      "  float2 dir;",
20      "  float  scale;",
21      "  float2 vel;",
22      "  float  spin;",
23      "  float4 color;",
24      "  float  frame;",
25      "};",
26      "",
27      "float2 circle() {",
28      "  float x;",
29      "  float y;",
30      "  do {",
31      "    x = rand * 2 - 1;",
32      "    y = rand * 2 - 1;",
33      "  } while (x*x + y*y > 1);",
34      "  return float2(x, y);",
35      "}",
36      "",
37      "void spawn(inout Particle p) {",
38      "  p.lifetime = 30;",
39      "  p.pos = circle() * 40;",
40      "}",
41      "",
42      "void update(inout Particle p) {",
43      "  p.vel += normalize(p.pos) * dt * 10;",
44      "  p.scale = mix(0.25, 3, p.age);",
45      "}",
46      ""
47   ],
48   "Bindings": []
49}