[SOLVED] Broken transparency/shadows for glTf PBR Model

Hi,

I’m relatively new to game development, and especially jMonkeyEngine, and experiencing a strange problem when importing a glTf model:
The textures of some surfaces become transparent and show strange patterns, that probably resemble the shadows the surfaces should receive.

The picture above shows the current output of a minimalistic sample program i created to narrow down the error(right), the rendered blender output (middle) and the model as it appears in blender layout mode(left). The sample program that produces the image shown above:

public class PbrSceneTest extends SimpleApplication {

    public static void main(String[] args) {
        PbrSceneTest app = new PbrSceneTest();
        app.start();
    }

    private DirectionalLight dl;

    @Override
    public void simpleInitApp() {

        getRenderManager().setPreferredLightMode(TechniqueDef.LightMode.StaticPass);
        getRenderManager().setSinglePassLightBatchSize(10);

        viewPort.setBackgroundColor(ColorRGBA.DarkGray);

        dl = new DirectionalLight();
        dl.setDirection(new Vector3f(-1, -1, -1).normalizeLocal());
        rootNode.addLight(dl);
        dl.setColor(ColorRGBA.White);

        ChaseCameraAppState chaser = new ChaseCameraAppState();
        chaser.setDragToRotate(true);
        chaser.setMinVerticalRotation(-FastMath.HALF_PI);
        chaser.setMaxDistance(1000);
        chaser.setInvertVerticalAxis(true);
        getStateManager().attach(chaser);
        chaser.setTarget(rootNode);
        flyCam.setEnabled(false);

        rootNode.attachChild(loadScene());
    }
    private Node loadScene() {
        Node level = (Node) assetManager.loadModel("Scenes/tree_house/scene.gltf");

        level.setLocalScale(5);

        return level;
    }
}

What puzzles me even more is, that if i open the model in blender, similar behavior can be observed in the layout-view, when rendering, everything looks as it should 'though.

I also get the following warning when loading the model:
“The texture Scenes/tree_house/textures/Trees_metallicRoughness.png has linear color space, but the material parameter LightMap specifies no color space requirement, this may lead to unexpected behavior.”
I am pretty the cause of this warning is not the cause of the observed behavior, as assigning a linear color space to LightMap does not change anything on the observed behavior.
I have tried jme-3.2.4 and 3.3.0, and everything i could to figure out where the error might be, but failed.

Do you have any Idea what might cause the strange rendering effects, or even how to fix it?

Model Link

1 Like

sorry i initially thought its just about shadow transparency.

Could you check blender “Face Orientation” ?

image

select here, and show screenshot, if there are “Red areas” its wrong.

edit:

  • also leafs itself if using default pbr you need have them double side, or use some shader that shade them properly from both sides

  • also i dont know scale of your scene, but too big scale or to small camera frustrum might cause some issues too.

Also, in blender in material tab check if blend mode is set to “Opaque”.

Thank you for the fast answer,
the face orientation looks very promising already, there are red areas!

So this means some surfaces of the model are flipped?
What I don’t understand then is why the surfaces pointing in the wrong direction resemble exactly the shape of the leaves, and why in blender rendering mode the model gets rendered perfectly.

I tried traversing through all materials of the model, and setting CullMode to off, the holes still appear like before, and in the shape of the leaves.

Also the scale of the model should not be a problem, the farPlane is set toa distance of 1000, while the diameter of the map is about 100.

Edit: Changing the Backface-Culling-Optionn in blender fixes SOME of the holes, yet not all, they still appear in the shape of leaves.

Thank you for your fast reply, the blend mode was set to ‘Alpha Clip’, changing that value (also to Opaque) seems not to influence the appearance.

Yes. In blender go to edit mode, select all faces an Shift+N to recalculate normals. This may fix it if it didn’t you need to flip them manually I guess.

indeed this result looks crazy, red ares should not contain blue leaf areas. but maybe you have some hidden objects there or something.

Try copy only bridge model and see if it have this result itself, then add tree and see again. because imo this areas should not be so mess.

step by step make new scene and see when it break.

The answer was too easy… The model i downloaded had a wrong texture linked to it in the glTf file-format, which seemed to be auto-generated…
Thank you for your Help!

1 Like