ssbucarlos / smash-ultimate-blender

Blender Plugin containing utilities for Smash Ultimate Models and Animations.
45 stars 9 forks source link

Low Animation Playback FPS due to drivers in shader graph #206

Open ssbucarlos opened 10 months ago

ssbucarlos commented 10 months ago

In blender, using a driver to update a value node or a default_value in a socket causes a performance hit, most likely due to the shaders needing to be recompiled due to the changing value. image

This can be tested by driving any one of these nodes with any value that changes and a performance hit is observed even if the value doesnt actually get used by the shader. Driving more values doesnt incur an additional FPS hit. However whenever another material has one value driven, then another sizeable fps hit occurs as another shader has to be constantly recompiled per-frame.

The workaround is to use a custom property on the mesh itself, and access the value with an 'Attribute' node and drive that value on the mesh data block instead. image

ssbucarlos commented 10 months ago

The workaround would be too hacky and only work with meshes with only one material. A better solution would be for the "Attribute" node to be able to access the Material's custom properties, rather than copying the data to the Object's custom properties (and running into the aforementioned one-material-per-mesh issue). But that would require changes to blenders source code, so for the meantime the low fps issue will remain.