KhronosGroup / glTF-Blender-IO

Blender glTF 2.0 importer and exporter
https://docs.blender.org/manual/en/latest/addons/import_export/scene_gltf2.html
Apache License 2.0
1.49k stars 317 forks source link

Export material animation #2347

Open y-khodja opened 2 months ago

y-khodja commented 2 months ago

Is your feature request related to a problem? Please describe. Hello,

I am actually trying to export animated propreties from materials with NLA into an extension. I could manage to make it work with some hooks in Blender 3.3LTS. I am trying to make it work with Blender 3.6LTS but the thing is that the code has changed a lot and i am a little bit stuck in:

Describe the solution you'd like Is there a way to manage the shape keys with and "elif" and let the else become anything else ? Or do you have any other idea to get this exported ?

Additional context The addon i'm working helps third parties to export glTF for Microsoft Flight Simulator game by adding extensions in the right places.

Thank you !

julienduroure commented 1 month ago

If you want to use KHR_animation_pointer to export these material properties, you should use Blender 4.2.x and enable the option (using Scene or NLA Track animation mode)

image

y-khodja commented 1 month ago

Actually i am trying to manage to get it work without your sampling (by sampling the material animations in 'gather_actions_hook' and 'gather_tracks_hook'. Because we already have an extension to manage those kind of animations in our engine. To give an example of what it looks like:

{
            "channels" : [
                {
                    "sampler" : 3,
                    "target" : {
                        "node" : 0,
                        "path" : "scale"
                    }
                }
            ],
            "extensions" : {
                "ASOBO_property_animation" : {
                    "channels" : [
                        {
                            "sampler" : 0,
                            "target" : "materials/0/pbrMetallicRoughness/baseColorFactor"
                        },
                        {
                            "sampler" : 1,
                            "target" : "materials/0/pbrMetallicRoughness/roughnessFactor"
                        },
                        {
                            "sampler" : 2,
                            "target" : "materials/0/pbrMetallicRoughness/metallicFactor"
                        }
                    ]
                }
            },
            "name" : "MaterialAnimation",
            "samplers" : [
                {
                    "input" : 4,
                    "interpolation" : "LINEAR",
                    "output" : 5
                },
                {
                    "input" : 4,
                    "interpolation" : "LINEAR",
                    "output" : 6
                },
                {
                    "input" : 4,
                    "interpolation" : "LINEAR",
                    "output" : 7
                },
                {
                    "input" : 8,
                    "interpolation" : "STEP",
                    "output" : 9
                }
            ]
        }

We want to support all LTS versions of Blender, so i'll have to make it work for 3.6 and 4.2 :blush:

Thank you for your response :smile: !