shan
shan

Reputation: 3155

LibGDX fbx export not displaying image texture — shows up as black

not quite sure where the problem is occurring here. I have a model that looks like this in Blender:

render view of model

and I have it all UV mapped and such — the blue highlighted edges are from a transparent .png texture. Here is the node editor:

node editor of material

Now when I export to .fbx as per LibGDX recommendation, I use these settings:

fbx export settings

But when I run it through fbx-convert and generate my g3dj file, the material shows up like this:

"materials": [
    {
        "id": "blue_wireframe_glow", 
        "ambient": [ 0.200000,  0.200000,  0.200000], 
        "diffuse": [ 0.800000,  0.800000,  0.800000], 
        "emissive": [ 0.000000,  0.000000,  0.000000], 
        "opacity":  0.000000,
        "specular": [ 0.200000,  0.200000,  0.200000], 
        "shininess":  20.000000
    }
], 

with no image texture in sight (even when changing opacity to 1.0). Is there something else I'm supposed to be doing that will make it so that the image texture will appear in the g3dj file? Am I attaching it wrong or something in Blender? I'm using Blender Cycles, if that matters. I also put the image file in the same folder as the g3dj file in my project. Here's the code I use to load it:

modelBatch = new ModelBatch();
modelLoader = new G3dModelLoader(new JsonReader());
heatExchangerModel = modelLoader.loadModel(Gdx.files.internal("models/heat_exchanger.g3dj"));
modelInstance = new ModelInstance(heatExchangerModel);

When I view it in my desktop Java application it just appears as a black model with no texture after I manually set the opacity to 1.0 in the g3dj file. Not sure where I'm going wrong here — any ideas?

edit: I've been reading some more and found that Blender Cycles can't export it's materials to FBX (not sure if true? or only very basic materials at least) and tried it with Blender Render and was able to get the texture to load in, but the model still doesn't quite look like it should with Blender.

Can someone just point me to the proper way to do materials in libGDX? Am I supposed to write my own from scratch? I feel like doing this all in Blender and then exporting might not be the way I'm supposed to do it.

Upvotes: 5

Views: 1449

Answers (1)

Sean Novak
Sean Novak

Reputation: 520

Cool looking shader shanling.

I would try a couple things from here. First, export your FBX as ASCII out of Blender. See if you can spot your file path from there. I'll bet it's getting lost before the fbx->g3dj process.

Second, I think building your shader with nodes might throw off the FBX exporter. Blender is awesome, but it is still open source and subject to imperfection. (So is every other package, but no company will admit to THAT!) Try building the same shader in the shader builder pane and see if that helps.

Otherwise, you're just going to have to rebuild the shader in libGDX. Either coding it in Java. OR, I'll bet you can modify your g3dj to include the file path as an emissive map.

For example: this is a portion of one of my g3dj files where I added a normal map. Change the type to "EMISSIVE" or "EMIT", I think. You should be in business after that.

"materials": [
            {
                "id": "background", 
                "ambient": [ 0.000000,  0.000000,  0.000000], 
                "diffuse": [ 0.800000,  0.800000,  0.800000], 
                "emissive": [ 0.800000,  0.800000,  0.800000], 
                "opacity":  1.000000, 
                "reflection": [ 0.100000,  0.100000,  0.100000],
                "shininess":  65.098038, 
                "textures": [
                    {
                        "id": "Texture.005", 
                        "filename": "carbonClr.png", 
                        "type": "DIFFUSE"
                    },
                    {
                        "id": "Texture.006", 
                        "filename": "carbonNormal.png", 
                        "type": "NORMAL"
                    }
                ]
            }
        ]       

Hope that helps!

Upvotes: 2

Related Questions