diff options
author | makamys <makamys@outlook.com> | 2022-06-23 10:26:38 +0200 |
---|---|---|
committer | makamys <makamys@outlook.com> | 2022-06-23 12:22:23 +0200 |
commit | 07c988f5a0ce2f7c60b864dd5ee64860d7cea457 (patch) | |
tree | c201085eba5e33b1713618ed4f90977b7a9ab356 /src/main/java | |
parent | 83b035c243b3ffeac9d57f7ab6d4cd89c0e25851 (diff) | |
download | Neodymium-07c988f5a0ce2f7c60b864dd5ee64860d7cea457.tar.gz Neodymium-07c988f5a0ce2f7c60b864dd5ee64860d7cea457.tar.bz2 Neodymium-07c988f5a0ce2f7c60b864dd5ee64860d7cea457.zip |
Make UV shortification disableable
Diffstat (limited to 'src/main/java')
-rw-r--r-- | src/main/java/makamys/neodymium/Config.java | 2 | ||||
-rw-r--r-- | src/main/java/makamys/neodymium/renderer/MeshQuad.java | 17 | ||||
-rw-r--r-- | src/main/java/makamys/neodymium/renderer/NeoRenderer.java | 12 |
3 files changed, 21 insertions, 10 deletions
diff --git a/src/main/java/makamys/neodymium/Config.java b/src/main/java/makamys/neodymium/Config.java index 813fc4b..2bdc543 100644 --- a/src/main/java/makamys/neodymium/Config.java +++ b/src/main/java/makamys/neodymium/Config.java @@ -31,6 +31,7 @@ public class Config { public static boolean simplifyChunkMeshes; public static boolean cullFaces; + public static boolean shortUV; public static int maxMeshesPerFrame; public static int sortFrequency; public static int gcRate; @@ -74,6 +75,7 @@ public class Config { simplifyChunkMeshes = config.getBoolean("simplifyChunkMeshes", "render", false, "Simplify chunk meshes so they are made of less vertices. Reduces vertex count at the cost of increasing shader complexity. The optimal setting depends on your hardware. Requires renderer restart when changed."); cullFaces = config.getBoolean("cullFaces", "render", true, "Don't submit faces for rendering if they are facing away from the camera. Reduces GPU workload at the cost of increasing driver overhead. This will improve the framerate most of the time, but may reduce it if you are not fillrate-limited."); + shortUV = config.getBoolean("shortUV", "render", true, "Store texture coordinates as shorts instead of floats. Slightly improves performance."); 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."); VRAMSize = config.getInt("VRAMSize", "render", 1024, 1, Integer.MAX_VALUE, "VRAM buffer size (MB). 512 seems to be a good value on Normal render distance. Increase this if you encounter warnings about the VRAM getting full. Does not affect RAM usage. Requires renderer restart when changed."); diff --git a/src/main/java/makamys/neodymium/renderer/MeshQuad.java b/src/main/java/makamys/neodymium/renderer/MeshQuad.java index 0fe580c..23617a4 100644 --- a/src/main/java/makamys/neodymium/renderer/MeshQuad.java +++ b/src/main/java/makamys/neodymium/renderer/MeshQuad.java @@ -166,8 +166,13 @@ public class MeshQuad { float u = us[vi]; float v = vs[vi]; - out.writeShort((short)(u * 16384)); - out.writeShort((short)(v * 16384)); + if(Config.shortUV) { + out.writeShort((short)(u * 16384)); + out.writeShort((short)(v * 16384)); + } else { + out.writeFloat(u); + out.writeFloat(v); + } int b = bs[vi]; @@ -208,10 +213,10 @@ public class MeshQuad { public static int getStride() { return - 3 * 4 // XYZ (float) - + 2 * 2 // UV (float) - + 4 // B (int) - + 4 // C (int) + 3 * 4 // XYZ (float) + + 2 * (Config.shortUV ? 2 : 4) // UV (float) + + 4 // B (int) + + 4 // C (int) + (Config.simplifyChunkMeshes ? 4 : 0) // megaquad XY (byte) ; } diff --git a/src/main/java/makamys/neodymium/renderer/NeoRenderer.java b/src/main/java/makamys/neodymium/renderer/NeoRenderer.java index 43e3546..701e009 100644 --- a/src/main/java/makamys/neodymium/renderer/NeoRenderer.java +++ b/src/main/java/makamys/neodymium/renderer/NeoRenderer.java @@ -443,11 +443,12 @@ public class NeoRenderer { int stride = MeshQuad.getStride(); glVertexAttribPointer(0, 3, GL_FLOAT, false, stride, 0); - glVertexAttribPointer(1, 2, GL_SHORT, false, stride, 3 * 4); - glVertexAttribPointer(2, 2, GL_SHORT, false, stride, 4 * 4); - glVertexAttribPointer(3, 4, GL_UNSIGNED_BYTE, false, stride, 5 * 4); + glVertexAttribPointer(1, 2, Config.shortUV ? GL_SHORT : GL_FLOAT, false, stride, 3 * 4); + int uvEnd = Config.shortUV ? 4 * 4 : 5 * 4; + glVertexAttribPointer(2, 2, GL_SHORT, false, stride, uvEnd); + glVertexAttribPointer(3, 4, GL_UNSIGNED_BYTE, false, stride, uvEnd + 1 * 4); if(Config.simplifyChunkMeshes) { - glVertexAttribPointer(4, 4, GL_UNSIGNED_BYTE, false, stride, 6 * 4); + glVertexAttribPointer(4, 4, GL_UNSIGNED_BYTE, false, stride, uvEnd + 2 * 4); } glEnableVertexAttribArray(0); @@ -479,6 +480,9 @@ public class NeoRenderer { if(Config.simplifyChunkMeshes) { defines.add("SIMPLIFY_MESHES"); } + if(Config.shortUV) { + defines.add("SHORT_UV"); + } boolean errors = false; |