skia2/resources/particles/warp.json
Brian Osman e11c43804b Remove use of uint from particle random system
uint (and bitwise operations) aren't supported by our minimum spec, and
they're going to be removed from public SkSL. For now, convert the
random generator to a good-enough chaotic sequence of high-frequency
sine waves.

If/when the interpreter (and particles) are converted to the newer skvm
backend, it will be straightforward to support custom intrinsics that
emit skvm instructions directly into the builder, and re-introduce a
better integer-based PRNG, without requiring SkSL language support.

Bug: skia:11093
Change-Id: I885b15a51a9e5c12b4274b5938d8deb77219d41b
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/347036
Reviewed-by: John Stiles <johnstiles@google.com>
Reviewed-by: Kevin Lubick <kjlubick@google.com>
Commit-Queue: Brian Osman <brianosman@google.com>
2020-12-23 16:21:17 +00:00

36 lines
815 B
JSON

{
"MaxCount": 4096,
"Drawable": {
"Type": "SkCircleDrawable",
"Radius": 2
},
"EffectCode": [
"void effectSpawn(inout Effect effect) {",
" effect.rate = 90;",
"}",
""
],
"Code": [
"float2 circle(inout float seed) {",
" float x;",
" float y;",
" do {",
" x = rand(seed) * 2 - 1;",
" y = rand(seed) * 2 - 1;",
" } while (x*x + y*y > 1);",
" return float2(x, y);",
"}",
"",
"void spawn(inout Particle p) {",
" p.lifetime = 30;",
" p.pos += circle(p.seed) * 40;",
"}",
"",
"void update(inout Particle p) {",
" p.vel += normalize(p.pos - effect.pos) * dt * 10;",
" p.scale = mix(0.25, 3, p.age);",
"}",
""
],
"Bindings": []
}