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

45 lines
1.2 KiB
JSON

{
"MaxCount": 800,
"Duration": 4,
"Rate": 120,
"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;",
"};",
"",
"void spawn(inout Particle p) {",
" p.lifetime = 2 + rand;",
" float a = radians(effectAge * 1080);",
" float s = 50 + rand * 10;",
" p.vel.x = cos(a) * s;",
" p.vel.y = sin(a) * s;",
"}",
"",
"void update(inout Particle p) {",
" p.scale = 0.5 + 1.5 * p.age;",
" float3 a0 = float3(0.098, 0.141, 0.784);",
" float3 a1 = float3(0.525, 0.886, 0.980);",
" float3 b0 = float3(0.376, 0.121, 0.705);",
" float3 b1 = float3(0.933, 0.227, 0.953);",
" p.color.rgb = mix(mix(a0, a1, p.age), mix(b0, b1, p.age), rand);",
"}",
""
],
"Bindings": []
}