Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Importing from Collada file with shape keys creates a horror game asset #19195

Closed
mysticfall opened this issue May 27, 2018 · 10 comments
Closed
Assignees
Milestone

Comments

@mysticfall
Copy link
Contributor

Godot version:
master / 430d847

OS/device including version:
Manjaro Linux 17.1

Issue description:
If I import a Collada(*.dae) file which was created with Godot's Better Collada addon, it will create an instant horror game ready asset when it contains shape keys:

When viewed inside the editor:
unidentified creature

Assuming from its physiology, it seems that the creature is of a different species that I found in #16994.

Steps to reproduce:
The source material which reproduces the issue is available from the below link, but because of godotengine/collada-exporter#41, you'll need to delete most of the shape keys to avoid a freeze when you export it:

I checked 'Shape Keys` when I export it from Blender, and imported it to Godot with saving meshes separately / no animation settings.

@mhilbrunner
Copy link
Member

Possibly relevant: #12618

@mysticfall
Copy link
Contributor Author

mysticfall commented May 27, 2018

In my case, I have the same warning message mentioned in #12618, but not the error. I tested again with triangulation applied to the mesh by different methods, and applying triangulation to all faces didn't make any change while using a modifier produced the 'out of size' error.

I could eliminate the warning by checking the triangulation option from the exporter panel, but it just broke the mesh in a different way (as probably mentioned by another issue: godotengine/collada-exporter#69).

@reduz reduz self-assigned this Sep 7, 2018
@glaforte
Copy link
Contributor

I took the Blender file from the link, exported it with the current version of the "Godot's Better Collada" add-on for Blender. I imported it in Godot 3.1 alpha 2. I got the following state:

image

This is a difficult issue because of the size of the model! Since the 'current state' of the issue is different than the reporter's, I'll build the old revision marked above - try to reproduce the issue there. Also, I'll investigate why the head mesh is partially visible on the current 'master' branch of Godot.

@glaforte
Copy link
Contributor

I built the revision 430d847 of Godot and reproduced the 'current state' of the issue. I checked the 'Godot's Better Collada' add-on code: there's been no relevant changes since May 2018. I checked the reporter's git-hub and the linked Blender file did change in September 2018, so that safely explains the difference between the 'reported state' and the 'current state'.

@glaforte
Copy link
Contributor

glaforte commented Nov 24, 2018

The head mesh is not visible because its base mesh is discarded during the import process.
It is discarded because its morph targets have differing vertex counts after their import.
The COLLADA document is coherent, though.
The different vertex counts in the morph targets come from the Godot COLLADA importer.
The Godot COLLADA importer calls 'SurfaceTool::generate_tangents' for all the morph target meshes.
This function does a lot more than generate tangents:
A) It de-indexes the vertices before the tangent generation.
B) Calls the 'mikktspace' third-party library to generate the tangents.
C) It re-indexes the vertices after the tangent generation (which can greatly reduce the vertex count).

Unfortunately, some of the head's vertices degenerate in only one/some morph targets.
The 'SurfaceTool::generate_tangents' function therefore optimizes the morph target meshes differently.
I suspect the the 'mikktspace' library, where the function 'MergeVertsFast' uses the position/normal/tex-coord values to match vertices. Depending on the degeneration of some triangles, their tangents will differ between morph targets and the optimization opportunities differ.

In the Head mesh, the 'Expressions_eyeClosedPressureL_max' morph target has 3169 vertices for its third surface, while the 'Expressions_eyeClosedPressureL_min' morph target has 3168 vertices for its third surface.

@mysticfall
Copy link
Contributor Author

@glaforte I don't have much to add to this issue, since I now use Blender exporter and the problem doesn't exist any more.

But I'm pretty sure there would be people who need to use blend shapes with COLLADA and I know how difficult to track down this type of issues. I just wanted to say thanks to you hard work so, thanks and hope you to get to the bottom of the problem soon! 👍

@glaforte
Copy link
Contributor

@mysticfall Thanks for encouragement! I'll review my assumptions and assertions, this morning. I think there might be something that escapes me still :)

@glaforte
Copy link
Contributor

Filed godotengine/collada-exporter#93 with an export bug in the Godot's Better Collada'. Working around this bug, now.

@glaforte
Copy link
Contributor

When checking the export option for the "tangent arrays" export option in Godot's Better Collada' export, in Blender, the issue does not occur.

@glaforte
Copy link
Contributor

Wrote a fix that removes the 'de-index' and 're-index' steps in the 'SurfaceTool::generate_tangents' function. The callbacks for the 'mikktspace' library are capable of working with the indexed data..

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants