libgdx / fbx-conv

Command line utility using the FBX SDK to convert FBX/Collada/Obj files to a custom text/binary format for static, keyframed and skinned meshes.
Apache License 2.0
448 stars 116 forks source link

Models loading but not showing #72

Closed Arcnor closed 9 years ago

Arcnor commented 9 years ago

I've tried with the latest precompiled version on Mac and Windows, and all the models I've tried are loading properly, but not showing at all. Tried compiling it myself on Mac and got the same problem.

Tried with the same models with an old fbx-conv binary I had around, and it worked properly, so something must be wrong with the code and the latest version.

Tried everything with LibGX 1.4.1.

Arcnor commented 9 years ago

Also, at least one report on the forums: http://www.badlogicgames.com/forum/viewtopic.php?f=11&t=16750&p=73076

badlogic commented 9 years ago

We can't do much without a problematic model file. On Nov 25, 2014 11:37 AM, "Edu Garcia" notifications@github.com wrote:

Also, at least one report on the forums: http://www.badlogicgames.com/forum/viewtopic.php?f=11&t=16750&p=73076

— Reply to this email directly or view it on GitHub https://github.com/libgdx/fbx-conv/issues/72#issuecomment-64380525.

Arcnor commented 9 years ago

I don't think models are the problem (I tried several, and all of them worked with a previous version), but I'm attaching one anyway.

https://gist.github.com/Arcnor/75b0447a0148a74b0752/raw/9ce511edd57bc5a791f2919858d035291b2e7043/pillar.zip

Arcnor commented 9 years ago

Forgot to mention: with that test FBX, you'll need to replace the textures in the generated G3D[BJ](it's trying to load the psd by default, but I replace that to use the existing jpg)

xoppa commented 9 years ago

Please check: https://github.com/libgdx/libgdx/wiki/Importing-Blender-models-in-LibGDX

Also, it is quite common that the materials from Blender export with opacity set to Zero. If you notice your model is not being rendered. Go to the Material in Blender, and below "Transparency" set its Alpha to the desired one (usually 1, for full opacity).

Arcnor commented 9 years ago

I don't think that's the issue (this model doesn't come from Blender but Maya, it loads properly on FBX Review and as I said, with previous versions of the tools, this and other models loaded properly).

I'll continue investigating when I get the time and reopen this if/when I get the cause.

Thanks.

xoppa commented 9 years ago

If you export to g3dj and open the file in a text editor then you'll see the line "opacity": 0.000000 for both materials.

Arcnor commented 9 years ago

You're right, but still, loading that g3dj with opacity 0, I still can see it using LibGDX 1.4.1, so that doesn't seem to be the issue (or it's a different one)

Arcnor commented 9 years ago

Ah no, sorry. For that loaded file, I'm doing material.set(new BlendingAttribute(GL20.GL_SRC_ALPHA, GL20.GL_ONE_MINUS_SRC_ALPHA)); and that seems to fix it. I'm testing all the conversions again without that line to see which ones are failing.

Arcnor commented 9 years ago

Ok, so in the end it seems that the problem is that opacity line. The old version of fbx-conv that I'm using (not sure from when, but the files are dated May 10, 2014) is not adding any opacity line. The newest one is adding that opacity 0.000. However, as I said, I'm also viewing the files on FBX Review and they look fine, so I'm going to check if the FBX really has 0 opacity.

Arcnor commented 9 years ago

Converting my test FBXs to ASCII FBX and checking the material section, I see two values. TransparencyFactor, set to 1, and Opacity, also set to 1.

So not sure why fbx-conv is setting that to 0.

xoppa commented 9 years ago

As per doc: TransparencyFactor Transparency factor property. This property is used to make a surface more or less opaque (0 = opaque, 1 = transparent).

Which is why fbx-conv does: result->opacity.set(1.f - lambert->TransparencyFactor.Get());

Arcnor commented 9 years ago

Then fbx-conv is ignoring the opacity value? What should happen when you have both opacity = 1 and transparencyFactor = 1? Also, when did this behavior changed?

My reasoning about that transparency versus opacity (that of course might be wrong) is that transparency will affect the alpha of the texture in Maya/3dsMAX, and opacity will control the actual opacity of the material. So for example, opaque pixels in the texture wont be affected by the transparency factor, but opacity will affect them.

xoppa commented 9 years ago

Afaik there isn't an opacity property in the specification (please link to the docs if you find that it does). Perhaps it's an extended property or converted by the fbx sdk or alike. Nonetheless, the doc on the transparency factor is very clear and doesn't mention textures or alike.

There was a bug in an earlier version of fbx-conv which caused an opacity of 0 not to be exported. This is later on solved by explicitly exporting it if a transparency factor is specified.

Arcnor commented 9 years ago

Yeah, you're right, it doesn't show on the FBX SDK docs. But it's there when I use the Autodesk FBX Exporter, so I'm not sure what's the deal with that.

For now, I'll just set the opacity to 1 always, and I'll ask the shop where I got this files from to check the transparency there, although nobody has reported this, so I think I'm not going to get anything on that front.

Thank you for your time.