GPUParticleSystem integrating VAT into Vertex Shader

Hello! I’ve got a case I am trying to fulfill:

  • Scene has entities that are mesh instances and use a VAT manager. The skeleton still exists for reference. They are animating completely through VAT.
  • These entities may be holding a weapon in their hand - these are also mesh instances and was able to piggy back off the original VAT manager since mesh supports that at a high level, and by modifying the vertex buffers for MatricesIndices and MatricesWeights depending on where the weapon is placed. So I can rig an additional mesh onto an existing skeleton bone through VAT.
  • Now I want to be able to create particles emitting from a certain place (bone as a reference point) on the entity.

I’m to the point where I provide the vertex shader and things are more or less rendering correctly, but once I try to use my finalWorld values in gl_Position, nothing appears i.e. bad vertex positions. I’m in the deep end here and would ask some sage advice if I am on the right track, possibly missing some setup, or should try something totally different?

Here is a gist with the setup. Unfortunately a pretty complex setup and not sure if I can create a PG, but if needed I can give that a shot as well.

GPU Particle System hooked into VAT · GitHub

I know my answer will be a pain but without being able to run it, it is complicated to help debugging :frowning:

Unless someone can spot an obvious issue looking at the code ;(

Uneducated guess: Make sure all the uniforms are set, send and recognize by the gpu particle shaders for everything related to VAT (as you are patching it manually)

Spector.js would be super useful for that

Ha! I knew it was coming :slight_smile: Thanks for the tip with Spector, hadn’t gotten into that yet, that will be super helpful in the future debugging GL stuff.

I ended up going down a different route besides shader surgery and proved it out to be performant in a tight loop… Basically I can sample the VAT directly knowing the bone index and apply transformations to the emitter which is just a Vector3, and also interpolate between different bones or units along a line. I am going to create a playground sometime soon for a minimal showcase since it turned out to be pretty neat.

1 Like