Page MenuHome

Collada Export should create <instance_controller> elements for Blender Shape Keys on nodes without armature
Open, NormalPublic

Description

System Information
macOS Sierra 10.12.3

Blender Version
Broken: 2.76, 2.78
Worked: Unknown, most likely never.

Short description of error
If there is no armature applied to a node that has shape keys, Blender's Collada export will create an <instance_geometry>. Instead we should create an <instance_controller> of the morph type for the shape keys.

For a Collada node to use a morph controller (roughly mapped to a Blender shape key) it needs to have a <instance_controller> child. Blender writes such an element for a skin controller (roughly equivalent to armature). It does not write <instance_controller> elements for shape keys.

The reason why we don't probably relates to https://developer.blender.org/T42197
When both an armature and a shape key apply to a node, Collada would like us to chain them. Blender doesn't support this, so we don't have a good way to express this situation in Collada format.

Here's what we do now:
Blender only exports <library_controller> elements for shape keys. This is all Blender needs, because Blender shape keys apply to a geometry globally, not a node. Collada morph controllers are bound to geometry, but need to be explicitly bound to nodes.

In the absence of armature, we should export an instance controller for shape keys.

Here's a collada test case sample that shows the correct format for a simple morph (aka shape key): https://github.com/KhronosGroup/COLLADA-CTS/blob/master/StandardDataSets/collada/library_controllers/controller/morph/morph_one_target_normalized/morph_one_target_normalized.dae

CON: This can be considered a partial fix. Instead of always failing to correctly export instances of morph controllers, we fail only when we have both armature and shape key. This may be more confusing than the current behavior.

PRO: These people can finally use Blender to create a simple morph and import it into Apple's SceneKit:
https://forums.developer.apple.com/thread/62426
http://stackoverflow.com/questions/37516117/how-do-i-load-scnmorpher-targets-from-a-collada-dae-files-morph-controllers-in

The issue for the Apple SceneKit users with Blender's current behavior is that their (primitive) tools don't allow them to access either library_geometries or library_controllers directly. Currently, they can't access shape key / morph controllers in Blender exported .dae at all.

Exact steps for others to reproduce the error

  1. Delete starting elements.
  1. Import "adjusted_cube_with_shapekey.dae" - It contains xml like "Expected" below.
  1. Verify that blender displays a new startup cube. - Note: Blender import has handled the fact that we have an instance controller not an instance geometry. Presumably, this is because the code for converting skin controller to armature covers the morph controller as well.
  1. Select File, export, Collada.
  1. After export inspect the <visual_scene> element in the dae file. The cube node will contain a <instance_geometry> instead of an <instance_controller>.

Current:

<visual_scene id="Scene" name="Scene">
      <node id="Cube" name="Cube" type="NODE">
        <matrix sid="transform">1 0 0 0 0 1 0 0 0 0 1 0 0 0 0 1</matrix>
        <instance_geometry url="#Cube-mesh" name="Cube">
          <bind_material>
            <technique_common>
              <instance_material symbol="Material-material" target="#Material-material"/>
            </technique_common>
          </bind_material>
        </instance_geometry>
      </node>
    </visual_scene>

Expected:

<visual_scene id="Scene" name="Scene">
      <node id="Cube" name="Cube" type="NODE">
        <matrix sid="transform">1 0 0 0 0 1 0 0 0 0 1 0 0 0 0 1</matrix>
        <instance_controller url="#Cube-morph" name="Cube-morph">
          <bind_material>
            <technique_common>
              <instance_material symbol="Material-material" target="#Material-material"/>
            </technique_common>
          </bind_material>
        </instance_controller>
      </node>
    </visual_scene>

Details

Type
Bug

Event Timeline

Bastien Montagne (mont29) triaged this task as Normal priority.

Thanks for the detailed report. :)

Not sure this is a bug or TODO or something else, though, will let @gaia decide here.

When you say:

"...Collada would like us to chain them. Blender doesn't support this, so we don't have a good way to express this situation in Collada format...."

Then i suspect that you actually mean that the Collada exporter does not support this, correct?
If that is so, then we should be able to solve this also when armatures and shape keys both are present...

Yes. We should be able to solve both. It's quite possible to remove the "on nodes without armature" from the title and intent of the bug.

Perhaps I was trying to triage bugs for you. I apologize.

Thanks for reading.

No reason for apologize!!! Its the opposite:

I am so glad that i get such analyses like yours because i often do not know what is right and what is wrong and what is important and what not. So getting such hints is an invaluable information for me. Please continue with that if you like! I would become more efficient and more happy :)

Hi,
I spent two hours to find out that this was my problem when importing blendshapes in Unity. I'm glad to see somebody already tracked out the problem and made a complete explanation of the problem :)

i must apologize for being so slow. I have fallen ill but i will resume as soon as i can.

i must apologize for being so slow. I have fallen ill but i will resume as soon as i can.

You don't need to apologize. Take all the time you need to get better ;)