The title might be a bit misleading but I'm having a hard time to explain the problem so I'll try with pictures:
I'm trying to create a voxel game and at the moment I try to get textures with transparency working. The mesh is generated for each chunk individually so that every chunk has its own ModelInstance that is rendered.
And the result should be like in the second picture (almost) so that every block is rendered behind the transparent textures but thats not the case for every side.
The relevant code for the transparent textures:
Mesh mesh = new Mesh(true, meshDataBlended.sizeEstimate, (int)Math.round(meshDataBlended.sizeEstimate * 1.5),
new VertexAttribute(VertexAttributes.Usage.Position, 3, ShaderProgram.POSITION_ATTRIBUTE),
new VertexAttribute(VertexAttributes.Usage.Normal, 3, ShaderProgram.NORMAL_ATTRIBUTE),
new VertexAttribute(VertexAttributes.Usage.TextureCoordinates, 2, ShaderProgram.TEXCOORD_ATTRIBUTE + "0"));
BlendingAttribute blendingAttribute = new BlendingAttribute();
blendingAttribute.blended = false;
blendingAttribute.sourceFunction = GL20.GL_SRC_ALPHA;
blendingAttribute.destFunction = GL20.GL_ONE_MINUS_SRC_ALPHA;
mesh.setVertices(meshDataBlended.vertices);
mesh.setIndices(meshDataBlended.indices);
Node terrainNode = modelBuilder.node();
terrainNode.id = "terrain_blended";
modelBuilder.part(
"terrain_blended", mesh, GL20.GL_TRIANGLES,
new Material(TextureAttribute.createDiffuse(World.TEXTURE), blendingAttribute)
);
I'm pretty new to OpenGL, so I'm totally lost with this problem. No idea why it behaves like this and I even don't know where I could find the needed informations. So far i just know that it depends on what is rendered first (that's why it works from one side but not the opposite side) Sorry for using Minecraft textures it's just for testing purposes.
Let me know if some additional information is needed I'll add them then.
Thanks Blakk
EDIT: setting blended to true will make everything visible behind the leaves except other leaves (still only from specific sides).