BabylonJS / BabylonToolkit

Home of the community maintained Unity & Unreal exporters for Babylon.js
179 stars 47 forks source link

Animation problem Unity exporter #7

Closed vanlecs09 closed 5 years ago

vanlecs09 commented 5 years ago

fish3d

The animation of my gameobject is weird after doing build and preview

Selmar commented 5 years ago

If possible, it will be helpful for whoever investigates the issue to have the source files!

vanlecs09 commented 5 years ago

I add babylon animation component to object. I think the problem come from curve animation?

sebavan commented 5 years ago

Our exporter devs are in vacation at the moment, so this will be check in about a week :-)

vanlecs09 commented 5 years ago

what about shader? The following model using the same shader. One using unity and one exporting to babylon.

screen shot 2018-11-23 at 10 54 03 pm screen shot 2018-11-23 at 10 55 10 pm

One more question, if we have raw class or struct in C#. We need to convert all C# class to Typescript or javascript right?

sebavan commented 5 years ago

About the classes yes but about the shader, it looks more like a wrong culling issue or mesh picked as transparent while it should not.

vanlecs09 commented 5 years ago
screen shot 2018-11-28 at 4 19 13 pm screen shot 2018-11-28 at 4 20 14 pm

Hi @sebavan Uncheck "Alpha is transparent" solve problem, but the fish lose its caustic effect. I don't see caustic texture in browser sources. Can you explain how shader update texture if they are not include in model?

screen shot 2018-11-28 at 4 23 25 pm
kcoley commented 5 years ago

@MackeyK24 would you be able to take a look at this?

MackeyK24 commented 5 years ago

Package up and send me the scene

vanlecs09 commented 5 years ago

Here it is. https://drive.google.com/open?id=1At_8KpVBDjHM_y-uD7koTWB8CNxj5FHh

MackeyK24 commented 5 years ago

I dont think this is the right package. It has a bunch of random letter folder. Does not look like actual scene package.

Use Unity to package your scene: https://docs.unity3d.com/Manual/HOWTO-exportpackage.html

On Tue, Dec 4, 2018 at 9:33 PM vanlecs09 notifications@github.com wrote:

Here it is. https://drive.google.com/open?id=1At_8KpVBDjHM_y-uD7koTWB8CNxj5FHh

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/BabylonJS/Exporters/issues/390#issuecomment-444387100, or mute the thread https://github.com/notifications/unsubscribe-auth/AEx_p9GxTTs6GNJrTMOvQGUWP86A9D_hks5u13augaJpZM4YwVU0 .

MackeyK24 commented 5 years ago

Yo @vanlecs09

Nevermind... I got it... The Mac actually tries to unzip the .zip and then it also unzips the .unitypackage as well. I guess it can tell that the .unitypackage is actually a compressed format. i had to use windows to unzip the main .zip and leave the .unitypackage in tact.

Checking things out now :)

vanlecs09 commented 5 years ago

OK, Can you also check the animation of blue fish? Thanks

MackeyK24 commented 5 years ago

OK... I found 2 issues with fish... But first... You got ALOT of Unsupported Unity Components on yuour scene... As well as missing prefabs... Remember the Toolkit is a way for use Babylon Folks to use the Unity Editor to make our scenes for BabylonJS. It is NOT a Unity to Babylon converter. Only a subset of components are supported. It is really intended to start with a clean project and add your babylon stuff to it... This looks like a already made Unity Scene meant for use in Unity Game Engine.

With that being said, i cleaned out everything except the two Fish (And the MainCamera And Directional Light).

With the fish... Your model has TOO many Bone Influencers (it has 5). The Toolkit only supports 4 max bone influencers. You need to RE-SKIN your models with 4 max bone influencers .

I created Maya Art Tools that make that as easy as a button click. I have a Maya Art Tools video that goes into that

And the Animations have a -90 deg rotation on them. Your gonna have to RE-SAMPLE those animation keyframes without that -90 deg rotation. I dont have video for that. I normally use maya. But you can use any modeling software. Just select all your keyframes and UNLOCK them and change that -90 to 0 on all the keyframes...

P.S. I dont know WHAT unity does to offset that -90 deg rotation when used in Unity. But when exporting for use in an external WebGL Engine like BabylonJS. That rotation is used. So if your key frames have a -90 deg rotation in Unity... So will Babylon :)

MackeyK24 commented 5 years ago

Note: If your models looks like 'Spaghetti' with stuff going every which way. That is a tell tell sign of too many bone influencers for the toolkit. You must re-skin (recreate your skin cluster in modeling software) with 4 max bone influencers

MackeyK24 commented 5 years ago

FYI... There is a Babylon Toolkit 4.0.0 Alpha 10 Update.

The PR is waiting for approval from @deltakosh ...

Note: I compiled the Scene Manager using TypeScript 3.2.1 ... So if you have problems using an OLDER typescript compiler. Try updating your typescript: npm install -g typescript

vanlecs09 commented 5 years ago

Thanks @MackeyK24 for getting back to me. What about shader problem. I want my fish has caustic effect on each fish. Seem like i need to add other custom shader controller script?

MackeyK24 commented 5 years ago

I dont know what caustic effect is... Can you make a video showing me what that should look like

vanlecs09 commented 5 years ago
49141537-69db7980-f329-11e8-8ba3-0bbe61712037

Like this, i use the same shader but got difference result when export to babylon. Here is babylon version.

49141589-85df1b00-f329-11e8-997e-a8c6518cc56c
MackeyK24 commented 5 years ago

FYI... I was loosing my motivation to continue the Babylon Toolkit (Cant get folks to help me code out a few things to make it really work)

So i started on a new project. Making a Next Gen Scene content exporter using industry standard GLTF with Extra Unity Metadata. I get so much better results converting unity content using the GLTF 2.0 spec than i did using the Babylon Entities DLL

Now my new tool is NO WHERE ready (does not have all the features i put into Babylon Toolkit Gen One... I am gonna have to start over creating the new toolkit using GLTF)

Anyways... For shits and giggles... i used your fish mode (FBX) AS IS... No re-skining bone influences and no re-sampling the animation to remove 90 deg rotation... It works very well...

Try and extract and load this sample fish.glb into the babylon sandbox by dragging the glb file onto sandbox

Fish.glb.zip

Animation looks good and no weird looking model because of bone influencers

Check it out and let me know how it looks on your end :)

MackeyK24 commented 5 years ago

Yo @vanlecs09 ... Send my that scene with the fish and the caustic effect... i will try to see what (IF ANYTHING) i can do to help with that :)

vanlecs09 commented 5 years ago

You can check the left fish in "TestBabylon.unitypackage" :D.

screen shot 2018-12-05 at 10 35 06 pm
MackeyK24 commented 5 years ago

Do you mean make another gltf export using the left fish as well ???

How does the first fish look in the babylon sandbox ???

MackeyK24 commented 5 years ago

I noticed that these animations actually TWO type of animations.

1... The transform animation... It looks like it move the whole fish left and right 2... The actual bone animation... that animates just the bone... But the root transform itself does not move.

I will have to look into getting both type of animations to work using GLTF.

But here is the Fish2 example...

Fish2.glb.zip

vanlecs09 commented 5 years ago

No I mean the caustic effect on the fish skin using shader. Not about animation. I use the same shader, which is "babylon/custom shader/fish material". But on browser the "caustic effect" not showing.

screen shot 2018-12-06 at 12 03 45 am
vanlecs09 commented 5 years ago

Anyway, Thanks for your active support. I really appreciate you work. After solving shader problem, you can close this thread. I will discuss with my team about html5game solution. @MackeyK24 :D

MackeyK24 commented 5 years ago

Did you write GLSL shader code for Babylon ???

The toolkit does not use unity shaders at all... we just use the unity shader so specify the Babylon shader material to use

vanlecs09 commented 5 years ago

Ok. I will check it. Thanks

MackeyK24 commented 5 years ago

Yo @vanlecs09 ... Het man, thanks for making an issue with these animations. I was able to find out a few things about how Unity Stores and Bakes animations.

First... I had only seen animations that were either transform or skeletal animations. Transform animation do just what is sound like... Is encodes the POSITION, ROTATION and SCALE using target curve animation bindings. But Skeletal animations are a bit different. You have to SAMPLE each bone for each animation clip at the calculated frame time and encode that TRS onto each bone. These skeletal animations are usually produced by some kind of motion capture using modeling software.

I had never seen animation clips that have BOTH regular transform animations (Like the fish has for the swaying back and forth of the parent game object) and skeletal animations (that wiggles the fish tail of the swim action)

This now supports the DEATH animations that FLIP the main fish transform and scales it down to ZERO over the course of the animation.

Using GLTF and the Animation Channels and Samples you can easily specify DIFFERENT animation node targets. Now i can support those complex Transform and Skeletal animations that are encoded in the same animation clip.

Take a look at your Fish in the Babylon Sandbox

Test-Fish-2.glb.zip

Now that has the full animated SWIM and DEATH animations :)

krebsandrej commented 5 years ago

Hi,

I also have an animation problem and I thought I would ask here, since there is already an open thread: p5hiiav9jd Basically the problem is, that when I try making an animation by keyframing objects in a file, it just animates the root of the hierarchy. I can workaround that by using bones, but that causes some other problems (unity won't bake skinned mesh renderer) and it would be a lot easier to animate the individual pieces. I am also including the unity project which also contains the original maya files as well as the exported FBX files: https://we.tl/t-MQZiPH25Pl

I would just like to know if this is just not supported in its current form or is there something I'm missing.

Thanks in advance and good job on the exporter/editor conversion

MackeyK24 commented 5 years ago

This is because this animation is a Unity animation that has BOTH transform animation on the object its self as well as skeletal animations. The old toolkit was kind oif an EITHER OR thing. Either its doing transform animation on the mesh position rotation and scale OR its doing BONE translation animation.

The GLTF 2.0 spec (Which i wrote code to support all animation export types) supports

This is fixed with new toolkit that uses GLTF Animation Export spec... So all works great now with multiple targets of the mesh :)