I’ve been trying to implement transparent voxel support to my (modified) version of this voxel engine from Threejsfundamentals, and so far, it works.
I’m using chunks (multiple objects) in my game, and sometimes, the chunk behind the transparent voxel is invisible:
The chunks are not separate - faces are calculated and one geometry is created, so unfortunately renderOrder may not work. Unless, I could create an additional object per chunk, that would have exclusively transparent voxels. This would make renderOrder possible.
Look into the material property alphaTest. It’s a float between 0…1 which will discard any pixel fragment below the specified alpha value (0…1 * 255) when rendering.
eg.
material.transparent = true;
material.alphaMap = texture.load( ‘…png’ )
material.depthTest = true; // ← all pixel fragments will test depth before being drawn
material.depthWrite = true; // ← all pixel fragments will update depth buffer when drawn - unless they are discarded
material.alphaTest = 0.5; // ← anything below an alpha score of 128 will be discarded.