Reputation: 43
I've already searched multiple forums but still can't find it. Here is the image: Sample
I have added BlendingAttribute
but some (not all) textures still rendered incorrectly. Those pointed faces should be transparent. Here is my snippet:
private void doneLoading() {
terrain = assets.get("xx.g3db", Model.class);
terrainInstance = new ModelInstance(terrain);
for(n = 2; n < terrainInstance.materials.size; n++){
terrainInstance.materials.get(n).set(new BlendingAttribute(GL30.GL_SRC_ALPHA, GL30.GL_ONE_MINUS_SRC_ALPHA)); // this should working for all faces
}
instances.add(terrainInstance);
loading = false;
}
@Override
public void render() {
if (loading && assets.update()) {
doneLoading();
}
personcam.update(Gdx.graphics.getDeltaTime());
Gdx.gl.glViewport(0, 0, Gdx.graphics.getWidth(), Gdx.graphics.getHeight());
Gdx.gl.glTexParameteri(GL30.GL_TEXTURE_2D, GL30.GL_TEXTURE_MAG_FILTER, GL30.GL_NEAREST);
Gdx.gl.glClearColor(1, 1, 1, 1);
Gdx.gl.glClear(GL30.GL_COLOR_BUFFER_BIT | GL30.GL_DEPTH_BUFFER_BIT);
modelBatch.begin(cam);
modelBatch.render(instances, environment);
modelBatch.end();
}
I have checked my texture files and they are fine. My FBX file (i'm using SketchUp 8) is fine too. Why are some faces not render transparency correctly? Is this bug?
Upvotes: 1
Views: 268
Reputation: 43
Found by adding a single line:
terrainInstance.materials.get(n).set(new FloatAttribute(FloatAttribute.AlphaTest, 0.8f));
in the for
loop fixes the transparency problem.
Upvotes: 1