JavaScript Javascript - optimizing node hierarchy updates for 3D animations

I am using WebGL to do hardware skinning, however updating my model node hierarchies is causing a huge hit for performance.

Every node needs to query its current location/rotation/scale keyframes, construct a local matrix with them, and multiply it with its parent's world matrix if it has a parent.

The matrix math itself is as optimized as it gets (special variants of matrix construction based on gl-matrix).

Still, if I update many models, with tens of nodes each (some even with hundreds, sadly), this hogs all of the execution time of the browser.

I have tried using a dirty state for when nodes don't actually need updating, but simply checking if their local data changed (mostly just checking if the location or rotation changed) actually causes the same amount of processing as just calculating the matrices.

WebCL would have been ideal, but that seems to go nowhere since 2014.

I am starting to think of running it all in a shader, but I can't quite wrap my head on how to design it (e.g. storing the keyframes, which are a map of frame->data, or how to write the data back).

Another way is to cache all of the animation transformations in a texture, but this doesn't scale well. For models with a low enough amount of keyframes, this is ok, but for ones with long animations, this turns to hundreds of megabytes very fast. This is mostly because I can't think of any way to store sparse data. If that were possible, then I could store the same amount of transformations as there are keyframes, which would not take a lot of memory (right now, I store the transformations for every single frame). Granted, this would require to do matrix interpolation, and I am not sure how reliable that is.

Does anyone have any ideas?

Answer:1

I have a small issue with conditional rendering of some part of html in jade, doing my best not to duplicate code. I have the following jade bit if(loggedIn && !search) form(action="/list/...

I have a small issue with conditional rendering of some part of html in jade, doing my best not to duplicate code. I have the following jade bit if(loggedIn && !search) form(action="/list/...

So here is what I have for a toggle switch I'm using off of https://metroui.org.ua/inputs.html What Im trying to do is change the label thats before the switch/checkbox to say checked or not checked. ...

So here is what I have for a toggle switch I'm using off of https://metroui.org.ua/inputs.html What Im trying to do is change the label thats before the switch/checkbox to say checked or not checked. ...

  1. html toggle switch status

Can anyone tell me about dynamic pages in wagtail? My use case is as following: I have a number of objects (images) on the main page When I click on image I'd like to be redirected to a page about ...

Can anyone tell me about dynamic pages in wagtail? My use case is as following: I have a number of objects (images) on the main page When I click on image I'd like to be redirected to a page about ...

  1. wagtail dynamic pages

At the begining of launching my app I am getting variables through django templates variables like so: var my_variable = '{{ variable }}'; But sometimes it takes more than one line and provide a ...

At the begining of launching my app I am getting variables through django templates variables like so: var my_variable = '{{ variable }}'; But sometimes it takes more than one line and provide a ...

  1. django template tags
  2. django template language
  3. django templateview
  4. django template does not exist
  5. django template comment
  6. django template if statement
  7. django template set variable
  8. django template example
  9. django template engine
  10. django template context
  11. django template extends
  12. django template dictionary
  13. django template if not
  14. django template for loop index
  15. django templates directory
  16. django template tutorial
  17. django template format date
  18. django template if and
  19. django templates free
  20. django template split