Exporters: Add support for morph targets using optimized meshes

Created on 3 Jul 2019  路  10Comments  路  Source: BabylonJS/Exporters

I have encountered a problem when exporting a mesh from with morphtargets which are optimized, demonstrated in the image below:

problem_1

Where the optimized morphtarget-vertices are dislocated, while the non-optimized morphtarget-vertices export correctly. The base-mesh-vertices export correctly however for both cases: Optimized and non-optimized. I have exported the mesh from 3Ds Max 2019. The problem does not appear when using the exporter in Maya though.

I have looked a bit into the code already and could not figure out the problem yet. Any suggestions to solve the problem are highly appreciated!

enhancement help wanted 3dsmax

Most helpful comment

So you have kind of a fix? We will gladly accept all help you can bring

So far we do not plan to change the way we optimize our vertices but if you already have something working that changes the plan :)

All 10 comments

Interesting. I'll take a look into it. @theRevilot, can you share your project file that reproduces this?

Reading the 3dsMax documentation on morph targets, it doesn't appear that morph targets are supported with optimized meshes, due to possible disparity in vert count between seed & target meshes after the optimization pass, I'd assume.

Does this work with other 3d scene formats?

@Drigax , thank you for the quick response!

I have provided all files in the attached zip folder. It includes the cube presented above in all babylon-exporter formats: babylon, binary babylon, gltf, glb.
babExportMorphData.zip

Debbugging into the exporter it seems that all conversions use the same code, which produces the same problem when checking babylon's 'optimze vertices' button: The morphtargets are setup wrong.

The mesh itself is not optimized within 3ds max. Morphtargets in the example scene do have the same amount of vertices as their seed-mesh.
The problem really seems to appear at the optimization step of morphtargets during export, as the seed-mesh gets optimzed correctly.

So just to be sure, it works of you turn off Babylon.js vertex optimization right?

This sounds reasonable for me as we can optimize the meshes up to a point where mesh and morph targets do not have the same vertex count.

If this is the case the idea could be to do no optimization if we detect morph targets (or emit a warning?)

@deltakosh yes correct, it works for me if I turn off vertex optimization in the Babylon.js exporter.

Well yes the target mesh can get optimized to a point where the vertex count does not correspond to the seed-mesh-vertex count, which is kind of the problem that I am adressing.

Would it not be beneficial to ensure that the amount of optimized target-vertices corresponds to the amount of seed-mesh-vertices during export though? - I have changed the code in such a way that vertex positions get optimized, without accounting for correct texture coordinates and normals for instance. As a result optimized morphtargets morph correctly after export, reducing the file size tremendously. My point is that seed-mesh-vertices could depict the way target-mesh-vertices are setup during export and eventually account for correct optimized morphtarget interpolation, as well as for a small file-size.

So you have kind of a fix? We will gladly accept all help you can bring

So far we do not plan to change the way we optimize our vertices but if you already have something working that changes the plan :)

Alright. So I think I have found a simple fix for this issue: The main problem was that while the base-mesh stores texture-coordinates for each vertex, the target-mesh does not. As a result the amount of vertices generated for the base-mesh is higher than the amount of target-mesh vertices when optimized. I solve this problem by applying the texture coordinates of the base-mesh to the target-mesh respectively during export.

I'm having issues with 3DS Max 2018 babylon exporter using morph targets without vertex optimisation. All looks correct in the viewport, animation groups setup correctly, but when viewing with donmccurdy mesh looks messed up.

Exported all targets out of Max into Blender used shape keys and exported first time without issue - not sure what the problem is with the Max exporter??

Here are my exports if they help at all?

morphed_pipes.zip

I don't think we made any actual progress on this. Closing this issue.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

EtagiBI picture EtagiBI  路  4Comments

echadwick-wayfair picture echadwick-wayfair  路  4Comments

aguaviva picture aguaviva  路  8Comments

vpenades picture vpenades  路  9Comments

echadwick-wayfair picture echadwick-wayfair  路  3Comments