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

Gltf export blend shape #48947

Closed
wants to merge 1 commit into from
Closed

Conversation

fire
Copy link
Member

@fire fire commented May 21, 2021

Work on gltf export.

Fixes: #47121

GLTF Export blend shape notes from Lyuma

This code is invalid:

                        Color tangent;
                        tangent.r = tarr[(i * 4) + 0];
                        tangent.g = tarr[(i * 4) + 1];
                        tangent.b = tarr[(i * 4) + 2];
                        tangent.a = tarr[(i * 4) + 3];
                        Vector3 vec3;
                        vec3.x = tarr[(i * 4) + 0];
                        vec3.y = tarr[(i * 4) + 1];
                        vec3.z = tarr[(i * 4) + 2];
                        vec3 *= tarr[(i * 4) + 3] * -1;
                    }

If TANGENT is encoded as vec3, the w component should be dropped, not multiplied.

This code has a bug:

                Vector<Vector3> narr = array_morph[Mesh::ARRAY_NORMAL];
                if (varr.size()) {
                    t["NORMAL"] = _encode_accessor_as_vec3(state, narr, true);
                }

Should be if(narr.size()) {

Line 6262: If we encounter another :blend_shapes/ track for a mesh whose blend shapes we have already exported, we must avoid exporting the blend shapes for that mesh a second time.

keyframes should be capped at a constant * the original number of keyframes. for example, min of 1.0 / BAKE_FPS and (total length / (10 * number of keyframes))

We should check if tracks are linear and avoid the complicated baking cases.

blend shape A   ..      . .    .
blend shape O   .    . .   .   .
->
output          ..   . .. ..   .

Line 6358: change to if key_count == 0: Why two zeros? I think we should do only one key

                weight.times.push_back(0.0f);
                weight.times.push_back(0.0f);
                weight.values.push_back(0.0f);
                weight.values.push_back(0.0f);
                track.weight_tracks.push_back(weight);

@fire fire requested a review from a team as a code owner May 21, 2021 23:35
@fire fire marked this pull request as draft May 21, 2021 23:35
@Calinou Calinou added this to the 4.0 milestone May 21, 2021
@fire
Copy link
Member Author

fire commented Jun 23, 2021

Remaining issues.

Line 6262: If we encounter another :blend_shapes/ track for a mesh whose blend shapes we have already exported, we must avoid exporting the blend shapes for that mesh a second time.

keyframes should be capped at a constant * the original number of keyframes. for example, min of 1.0 / BAKE_FPS and (total length / (10 * number of keyframes))

We should check if tracks are linear and avoid the complicated baking cases.

Edited:

Removed tangent export for blend shapes (morph targets).

@fire fire force-pushed the gltf-export-blend-shape branch 7 times, most recently from a3993c6 to c457858 Compare June 28, 2021 05:11
Export blend shape animations.

Better output on blend shape tangent arrays.
@fire fire mentioned this pull request Jun 30, 2021
@fire
Copy link
Member Author

fire commented Aug 9, 2021

Superseded by: #50019

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

Successfully merging this pull request may close these issues.

Blend shapes are glTF2 exported duplicated
3 participants