我已经搜索了多个论坛,但仍无法找到它。这是图像: Sample
我添加了BlendingAttribute
,但仍有一些(并非所有)纹理呈现错误。那些尖锐的面应该是透明的。这是我的片段:
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();
}
我检查了我的纹理文件,它们很好。我的FBX文件(我使用SketchUp 8)也很好。为什么有些面孔无法正确渲染透明度?这个错误吗?
答案 0 :(得分:1)
通过添加一行找到:
terrainInstance.materials.get(n).set(new FloatAttribute(FloatAttribute.AlphaTest, 0.8f));
for
循环中的修复了透明度问题。