taniwha / io_object_mu

Python .mu reader/writer and blender import/export addon
GNU General Public License v2.0
120 stars 51 forks source link

Material property animations are applied to the entire material instead of per gameobject #60

Open JonnyOThan opened 2 years ago

JonnyOThan commented 2 years ago

I was working with SwitchWCover.mu from ASET Props and it uses a material animation to change the SwitchIndicator game object's emissive color between red and green. The animation curves are applied ONLY to this gameobject. After importing in blender, the animation curves are stored on the material itself - which means that when exporting, all gameobjects that use this material are affected by the animation. cfgs.zip

SwitchWCover.zip

taniwha commented 2 years ago

After some googling and experimenting, it turns out this isn't anywhere the nightmare I thought it would be: https://blender.stackexchange.com/questions/176235/per-object-custom-properties-in-shaders provides the info I need for implementing per-object data affecting a shared material, as shown below in my PoC test. The hard part will be designing a reasonable UI/UX for presenting and animating the properties on the object rather than the material.

image image

taniwha commented 2 years ago

I've been thinking about the internal (non-UI) design a bit and ran into the problem of how to allow the property to be specified in the material (eg, _EmissiveColor), but overridden by an object animation property. I've come up with the idea of using two attribute inputs for each property: one to indicate whether the property has a per-object override, and the second for the actual property override. I just tested the idea with a property that does not exist and blender seems to have defaulted the input to 0, which makes that idea feasible.

This is for the in-blender display, of course (otherwise, life would be easy: just have all the material properties on the object and be done with it (but no preview)).

StoneBlue commented 2 years ago

Would be awesome if you could solve this. I have come across several cases, of parts that need animations (usually emissives :P ) of mat. properties on certain objects only, but i havent been able to get anything working... it seems there are at least two stock MODULEs that can/should be able to do this...but of course...BOTH are broken :(