diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/main/java/makamys/neodymium/Config.java | 2 | ||||
-rw-r--r-- | src/main/java/makamys/neodymium/renderer/CullableMeshCollection.java | 15 | ||||
-rw-r--r-- | src/main/java/makamys/neodymium/renderer/Mesh.java | 2 |
3 files changed, 13 insertions, 6 deletions
diff --git a/src/main/java/makamys/neodymium/Config.java b/src/main/java/makamys/neodymium/Config.java index 8c93dde..2ab3ecf 100644 --- a/src/main/java/makamys/neodymium/Config.java +++ b/src/main/java/makamys/neodymium/Config.java @@ -30,6 +30,7 @@ public class Config { public static boolean hotswap; public static boolean simplifyChunkMeshes; + public static boolean cullFaces; public static int maxMeshesPerFrame; public static int sortFrequency; public static int gcRate; @@ -72,6 +73,7 @@ public class Config { hotswap = config.getBoolean("hotswap", "_general", false, "Apply changes made in the config file immediately without having to reload the world. Off by default because it could potentially cause poor performance on certain platforms. Note that not all settings can be hotswapped."); simplifyChunkMeshes = config.getBoolean("simplifyChunkMeshes", "render", false, "Simplify chunk meshes so they are made of less vertices. Proof of concept, produces very janky results."); + cullFaces = config.getBoolean("cullFaces", "render", false, "Don't submit faces for rendering if they are facing away from the camera. Reduces GPU workload at the cost of increasing driver overhead. On weaker graphics cards this may significantly improve performance, but on better cards it may have the opposite effect."); sortFrequency = config.getInt("sortFrequency", "render", 1, 1, Integer.MAX_VALUE, "Interval (in frames) between the sorting of meshes. Increasing this might increase framerate, but increase the likelyhood of graphical artifacts when moving quickly."); gcRate = config.getInt("gcRate", "render", 1, 1, Integer.MAX_VALUE, "Maximum number of meshes to relocate in the buffer each frame. Setting this to a higher value will make it harder for the VRAM to get full (which causes a lag spike when it happens), but slightly reduces overall framerate. Examining the VRAM debugger can help find the right value."); diff --git a/src/main/java/makamys/neodymium/renderer/CullableMeshCollection.java b/src/main/java/makamys/neodymium/renderer/CullableMeshCollection.java index 9c039b4..cdc31a6 100644 --- a/src/main/java/makamys/neodymium/renderer/CullableMeshCollection.java +++ b/src/main/java/makamys/neodymium/renderer/CullableMeshCollection.java @@ -4,6 +4,7 @@ import java.util.Arrays; import java.util.List; import java.util.stream.Collectors; +import makamys.neodymium.Config; import makamys.neodymium.renderer.ChunkMesh.Flags; public class CullableMeshCollection { @@ -11,12 +12,16 @@ public class CullableMeshCollection { private ChunkMesh[] meshes = new ChunkMesh[QuadNormal.values().length]; public CullableMeshCollection(int x, int y, int z, Flags flags, int quadCount, List<MeshQuad> quads, int pass) { - for(QuadNormal normal : QuadNormal.values()) { - List<MeshQuad> normalQuads = quads.stream().filter(q -> MeshQuad.isValid(q) && q.normal == normal).collect(Collectors.toList()); - if(!normalQuads.isEmpty()) { - putMeshWithNormal(normal, new ChunkMesh(x, y, z, flags, normalQuads.size(), normalQuads, pass)); - getMeshWithNormal(normal).normal = normal; + if(Config.cullFaces) { + for(QuadNormal normal : QuadNormal.values()) { + List<MeshQuad> normalQuads = quads.stream().filter(q -> MeshQuad.isValid(q) && q.normal == normal).collect(Collectors.toList()); + if(!normalQuads.isEmpty()) { + putMeshWithNormal(normal, new ChunkMesh(x, y, z, flags, normalQuads.size(), normalQuads, pass)); + getMeshWithNormal(normal).normal = normal; + } } + } else { + putMeshWithNormal(QuadNormal.NONE, new ChunkMesh(x, y, z, flags, quadCount, quads, pass)); } } diff --git a/src/main/java/makamys/neodymium/renderer/Mesh.java b/src/main/java/makamys/neodymium/renderer/Mesh.java index 61d4222..6eadf88 100644 --- a/src/main/java/makamys/neodymium/renderer/Mesh.java +++ b/src/main/java/makamys/neodymium/renderer/Mesh.java @@ -16,7 +16,7 @@ public abstract class Mesh { public int offset = -1; public int pass; int x, y, z; - public QuadNormal normal; + public QuadNormal normal = QuadNormal.NONE; public abstract int getStride(); |