Hacker News new | ask | show | jobs
by Flux159 499 days ago
This is super cool & I'm impressed that it's working with WebGL.

From reading the code & seeing the examples in the sandbox, it looks like the sprite layer is defined one time (initialization) with specific sprite & animation properties that are exposed to JS via the SpriteGPULayer config https://github.com/phaserjs/phaser/blob/v4.0.0-beta.5/src/ga... , then that class passes the info over to the vertex shader which has ifdefs to determine which animation, other features are enabled for a given SpriteGPULayer - https://github.com/phaserjs/phaser/blob/v4.0.0-beta.5/src/re...

This way you don't end up having to do any updates per frame on the CPU and it remains one draw call for the entire layer right?

Are there other use cases besides from large scale sprite/animated backgrounds that you've thought of?

1 comments

Yes, this is correct! You _can_ update the GPU Layer data, the API allows it, but you pay the upload cost each time, which is why we framed it as for 'backgrounds' - but in reality, it could be used for anything animated. I mean, you don't HAVE to create 1m sprites! You could just do 100 and it'd still be significantly less overhead than 100 actual sprites. Going to be interesting to see what devs come up with here.