Jump to content

GLTF Morph Targets Not Working


MackeyK24
 Share

Recommended Posts

Yo @Deltakosh and @Sebavan ... I am having problems with loading a GLTF Character with Morph Targets.

 

I exported a GLTF file with guy that has a SMILE MORPH TARGET... When viewing with BabylonJS the Skin on arms gets distorted with lines or something and IT DOES NOT show the actual SMILE on the face. But viewin the same file in simply switching to THREE.JS it look great, no distortion and is it showing the smile. Any clues ???

BabylonJS Screen Shot (Look close up on face and arms.. and NO SMILE)

 

76171038_ScreenShot2018-09-27at4_01_09AM.thumb.png.8ea8541601b16cb6b6e9ae4768d042dd.png

 

Now same GLTF Viewing session... just switched to THREE.JS

 

1057835593_ScreenShot2018-09-27at4_01_39AM.thumb.png.8c25208ce2224f470cf259c10d1beccc.png

 

Hmmm... We do support morph targets... right ???

 

Link to comment
Share on other sites

Yo @bghgary did you notice the multiple skeleton animations in that test Remy model.

FYI... I made that export using that Animation baking code I sent you before where I thru all the bones and SAMPLE the animation clip then encode the TRS for each bone at the given frame time

All other UnityGLTF seem to be missing that part that actually encode skeleton animations 

but my Canvas Tools works great... I am working on the actual blend shape animation key frames next ?

Link to comment
Share on other sites

Yo @bghgary I have a question about the Accessor Mix And Max and GLTF Validator.

 

For Example: 

I have a Vector3[] ExportAccessor function... during setting the mix and max... There is CLEARLY a -1 in the Vector.z in one of the vector4 array elements... that is the LOWEST Vector.Z value in the array... But for some reason the GLTF Validator in VSCODE and the one in the THREE.JS GLTF Viewer say there is a Validate error..

it says the min value = -1 BUT the Actual lowest value = 1.

How can that be. I looped thru the whole array tracing the Z component... I clearly see a -1... I also popped those in a List and used the values.Min() and values.Max()

functions... WHICH ALSO CLEAR RETURNS -1 as the lowest Z value. Why the heck would the validator say that wrong and the actual value is 1 ???

 

Link to comment
Share on other sites

Yo @bghgary ... Thanks a million bro. That was it exactly. I dont know how i missed that. I use buffer list for all values now and switch the handness when dumping into buffer list.. Then i can use that same list for Mix Max Values Function as well as loop thru serializing the values:

 One example ExportAccessor function:

		private AccessorId ExportAccessor(Vector3[] arr, bool switchHandedness=false, string accessorName = null)
		{
			var count = arr.Length;
			if (count == 0)
			{
				throw new Exception("Accessors can not have a count of 0.");
			}

			var accessor = new Accessor();
			accessor.ComponentType = GLTFComponentType.Float;
			accessor.Count = count;
			accessor.Type = GLTFAccessorAttributeType.VEC3;
			accessor.Name = accessorName;

			List<Vector3> values = new List<Vector3>();
			foreach (var vec in arr) { values.Add(switchHandedness ? vec.SwitchHandedness() : vec); }
			accessor.Min = new List<double> { values.Select(value => value.x).Min(), values.Select(value => value.y).Min(), values.Select(value => value.z).Min() };
			accessor.Max = new List<double> { values.Select(value => value.x).Max(), values.Select(value => value.y).Max(), values.Select(value => value.z).Max() };

			var byteOffset = _bufferWriter.BaseStream.Position;

			foreach (var vec in values) {
				_bufferWriter.Write(vec.x);
				_bufferWriter.Write(vec.y);
				_bufferWriter.Write(vec.z);
			}

			var byteLength = _bufferWriter.BaseStream.Position - byteOffset;

			accessor.BufferView = ExportBufferView((int)byteOffset, (int)byteLength);

			var id = new AccessorId {
				Id = _root.Accessors.Count,
				Root = _root
			};
			_root.Accessors.Add(accessor);

			return id;
		}

Works like a charm... 0 ERRORS now... Thanks again :)

 

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...