aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/main/java/makamys/neodymium/Config.java2
-rw-r--r--src/main/java/makamys/neodymium/renderer/MeshQuad.java17
-rw-r--r--src/main/java/makamys/neodymium/renderer/NeoRenderer.java12
-rw-r--r--src/main/resources/shaders/chunk.frag7
4 files changed, 27 insertions, 11 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;
diff --git a/src/main/resources/shaders/chunk.frag b/src/main/resources/shaders/chunk.frag
index 2e729b1..1922f03 100644
--- a/src/main/resources/shaders/chunk.frag
+++ b/src/main/resources/shaders/chunk.frag
@@ -27,7 +27,12 @@ void main()
goodTexCoord = ProvokingTexCoord.xy + (((TexCoord.xy - ProvokingTexCoord.xy) / MQPos.zw) * vec2(wrappedU, wrappedV));
}
#endif
- vec4 texColor = texture(atlas, goodTexCoord / 16384.0);
+
+ vec4 texColor = texture(atlas, goodTexCoord
+#ifdef SHORT_UV
+ / 16384.0
+#endif
+ );
vec4 colorMult = Color/256.0;