aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authormakamys <makamys@outlook.com>2022-06-30 08:43:04 +0200
committermakamys <makamys@outlook.com>2022-06-30 08:43:04 +0200
commit359c4b702d4327d92704201fc2977dbf9d179dd7 (patch)
tree7940fc8e0e02452758c7c4a5b759fa5d3378cb5d /src
parent25c0977e33d6a376c92830da56473ebfa1e97959 (diff)
downloadNeodymium-359c4b702d4327d92704201fc2977dbf9d179dd7.tar.gz
Neodymium-359c4b702d4327d92704201fc2977dbf9d179dd7.tar.bz2
Neodymium-359c4b702d4327d92704201fc2977dbf9d179dd7.zip
Don't do face culling for translucent quads
Order matters when quads are translucent. Partial fix for incorrect water rendering.
Diffstat (limited to 'src')
-rw-r--r--src/main/java/makamys/neodymium/renderer/ChunkMesh.java10
1 files changed, 7 insertions, 3 deletions
diff --git a/src/main/java/makamys/neodymium/renderer/ChunkMesh.java b/src/main/java/makamys/neodymium/renderer/ChunkMesh.java
index 3971c65..df4f9f7 100644
--- a/src/main/java/makamys/neodymium/renderer/ChunkMesh.java
+++ b/src/main/java/makamys/neodymium/renderer/ChunkMesh.java
@@ -178,20 +178,24 @@ public class ChunkMesh extends Mesh {
ByteBuffer buffer = BufferUtils.createByteBuffer(quadCount * 4 * MeshQuad.getStride());
BufferWriter out = new BufferWriter(buffer);
- quads.sort(MESH_QUAD_RENDER_COMPARATOR);
+ boolean sortByNormals = pass == 0;
+
+ if(sortByNormals) {
+ quads.sort(MESH_QUAD_RENDER_COMPARATOR);
+ }
try {
int i = 0;
for(MeshQuad quad : quads) {
if(i < quadCount) {
if(MeshQuad.isValid(quad)) {
- int subMeshStartIdx = QUAD_NORMAL_TO_NORMAL_ORDER[quad.normal.ordinal()];
+ int subMeshStartIdx = sortByNormals ? QUAD_NORMAL_TO_NORMAL_ORDER[quad.normal.ordinal()] : 0;
if(subMeshStart[subMeshStartIdx] == -1) {
subMeshStart[subMeshStartIdx] = i;
}
quad.writeToBuffer(out);
i++;
- } else {
+ } else if(sortByNormals){
break;
}
}