92 lines
2.6 KiB
JSON
92 lines
2.6 KiB
JSON
{
|
|
"MaxCount": 2000,
|
|
"Drawable": {
|
|
"Type": "SkCircleDrawable",
|
|
"Radius": 4
|
|
},
|
|
"Code": [
|
|
"void effectSpawn(inout Effect effect) {",
|
|
" effect.lifetime = 2;",
|
|
" effect.rate = 200;",
|
|
"}",
|
|
"",
|
|
"void spawn(inout Particle p) {",
|
|
" p.lifetime = 10;",
|
|
"}",
|
|
"",
|
|
"float4x4 rx(float rad) {",
|
|
" float c = cos(rad);",
|
|
" float s = sin(rad);",
|
|
" return float4x4(1, 0, 0, 0,",
|
|
" 0, c, -s, 0,",
|
|
" 0, s, c, 0,",
|
|
" 0, 0, 0, 1);",
|
|
"}",
|
|
"",
|
|
"float4x4 ry(float rad) {",
|
|
" float c = cos(rad);",
|
|
" float s = sin(rad);",
|
|
" return float4x4(c, 0, -s, 0,",
|
|
" 0, 1, 0, 0,",
|
|
" s, 0, c, 0,",
|
|
" 0, 0, 0, 1);",
|
|
"}",
|
|
"",
|
|
"float4x4 rz(float rad) {",
|
|
" float c = cos(rad);",
|
|
" float s = sin(rad);",
|
|
" return float4x4( c, s, 0, 0,",
|
|
" -s, c, 0, 0,",
|
|
" 0, 0, 1, 0,",
|
|
" 0, 0, 0, 1);",
|
|
"}",
|
|
"",
|
|
"void update(inout Particle p) {",
|
|
" float3 pos = float3(rand(p.seed), rand(p.seed), rand(p.seed));",
|
|
" if (rand(p.seed) < 0.33) {",
|
|
" if (pos.x > 0.5) {",
|
|
" pos.x = 1;",
|
|
" p.color.rgb = float3(1, 0.2, 0.2);",
|
|
" } else {",
|
|
" pos.x = 0;",
|
|
" p.color.rgb = float3(0.2, 1, 1);",
|
|
" }",
|
|
" } else if (rand(p.seed) < 0.5) {",
|
|
" if (pos.y > 0.5) {",
|
|
" pos.y = 1;",
|
|
" p.color.rgb = float3(0.2, 0.2, 1);",
|
|
" } else {",
|
|
" pos.y = 0;",
|
|
" p.color.rgb = float3(1, 1, 0.2);",
|
|
" }",
|
|
" } else {",
|
|
" if (pos.z > 0.5) {",
|
|
" pos.z = 1;",
|
|
" p.color.rgb = float3(0.2, 1, 0.2);",
|
|
" } else {",
|
|
" pos.z = 0;",
|
|
" p.color.rgb = float3(1, 0.2, 1);",
|
|
" }",
|
|
" }",
|
|
"",
|
|
" float s = effect.age * 2 - 1;",
|
|
" s = s < 0 ? -s : s;",
|
|
"",
|
|
" pos = pos * 2 - 1;",
|
|
" pos = mix(pos, normalize(pos), s);",
|
|
" pos = pos * 100;",
|
|
"",
|
|
" float age = float(effect.loop) + effect.age;",
|
|
" float4x4 mat = rx(age * radians(60))",
|
|
" * ry(age * radians(70))",
|
|
" * rz(age * radians(80));",
|
|
" pos = (mat * float4(pos, 1)).xyz;",
|
|
"",
|
|
" p.pos.x = pos.x;",
|
|
" p.pos.y = pos.y;",
|
|
" p.scale = ((pos.z + 50) / 100 + 0.5) / 2;",
|
|
"}",
|
|
""
|
|
],
|
|
"Bindings": []
|
|
} |