aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorFalsePattern <me@falsepattern.com>2024-01-07 17:50:15 +0100
committermakamys <makamys@outlook.com>2024-01-08 22:49:40 +0100
commit3ee0c611c0d1e9cb8f74182c1dd672dda9cb36b5 (patch)
tree3fcc3a744fe099698bb51b40b715389ab0f94ffb /src
parentcaec6f115cc42e2f2cf73e136892110ba3726251 (diff)
downloadNeodymium-3ee0c611c0d1e9cb8f74182c1dd672dda9cb36b5.tar.gz
Neodymium-3ee0c611c0d1e9cb8f74182c1dd672dda9cb36b5.tar.bz2
Neodymium-3ee0c611c0d1e9cb8f74182c1dd672dda9cb36b5.zip
RPLE shader compat
Diffstat (limited to 'src')
-rw-r--r--src/main/java/makamys/neodymium/Compat.java11
-rw-r--r--src/main/java/makamys/neodymium/renderer/ChunkMesh.java8
-rw-r--r--src/main/java/makamys/neodymium/renderer/MeshQuad.java26
-rw-r--r--src/main/java/makamys/neodymium/renderer/NeoRenderer.java43
4 files changed, 74 insertions, 14 deletions
diff --git a/src/main/java/makamys/neodymium/Compat.java b/src/main/java/makamys/neodymium/Compat.java
index 6343e14..debb6d6 100644
--- a/src/main/java/makamys/neodymium/Compat.java
+++ b/src/main/java/makamys/neodymium/Compat.java
@@ -11,7 +11,6 @@ import org.lwjgl.opengl.GLContext;
import com.falsepattern.triangulator.api.ToggleableTessellator;
import cpw.mods.fml.common.Loader;
import makamys.neodymium.config.Config;
-import makamys.neodymium.util.OFUtil;
import makamys.neodymium.util.virtualjar.IVirtualJar;
import makamys.neodymium.util.virtualjar.VirtualJar;
import net.minecraft.client.Minecraft;
@@ -27,6 +26,8 @@ public class Compat {
private static int notEnoughVRAMAmountMB = -1;
private static boolean RPLE;
+
+ private static boolean FALSE_TWEAKS;
public static void init() {
isGL33Supported = GLContext.getCapabilities().OpenGL33;
@@ -38,12 +39,20 @@ public class Compat {
if (Loader.isModLoaded("rple")) {
RPLE = true;
}
+
+ if (Loader.isModLoaded("falsetweaks")) {
+ FALSE_TWEAKS = true;
+ }
}
public static boolean RPLE() {
return RPLE;
}
+ public static boolean FalseTweaks() {
+ return FALSE_TWEAKS;
+ }
+
private static boolean shadersEnabled;
public static boolean isShaders() {
diff --git a/src/main/java/makamys/neodymium/renderer/ChunkMesh.java b/src/main/java/makamys/neodymium/renderer/ChunkMesh.java
index 72c20ff..decc90d 100644
--- a/src/main/java/makamys/neodymium/renderer/ChunkMesh.java
+++ b/src/main/java/makamys/neodymium/renderer/ChunkMesh.java
@@ -110,8 +110,12 @@ public class ChunkMesh extends Mesh {
int verticesPerPrimitive = t.drawMode == GL11.GL_QUADS ? 4 : 3;
- int tessellatorVertexSize = Compat.isShaders() ? 18 : Compat.RPLE() ? 12 : 8;
-
+ int tessellatorVertexSize = 8;
+ if (Compat.isShaders())
+ tessellatorVertexSize += 10;
+ if (Compat.RPLE())
+ tessellatorVertexSize += 4;
+
for(int quadI = 0; quadI < t.vertexCount / verticesPerPrimitive; quadI++) {
MeshQuad quad = quadBuf.next();
quad.setState(t.rawBuffer, tessellatorVertexSize, quadI * (verticesPerPrimitive * tessellatorVertexSize), FLAGS, t.drawMode, NeoRegion.toRelativeOffset(-t.xOffset), NeoRegion.toRelativeOffset(-t.yOffset), NeoRegion.toRelativeOffset(-t.zOffset));
diff --git a/src/main/java/makamys/neodymium/renderer/MeshQuad.java b/src/main/java/makamys/neodymium/renderer/MeshQuad.java
index f748488..4e72535 100644
--- a/src/main/java/makamys/neodymium/renderer/MeshQuad.java
+++ b/src/main/java/makamys/neodymium/renderer/MeshQuad.java
@@ -43,6 +43,9 @@ public class MeshQuad {
public float[] um = new float[4];
public float[] vm = new float[4];
+ public float[] ue = new float[4];
+ public float[] ve = new float[4];
+
public boolean deleted;
public QuadNormal normal;
@@ -80,6 +83,12 @@ public class MeshQuad {
wt[vi] = Float.intBitsToFloat(rawBuffer[i + 15]);
um[vi] = Float.intBitsToFloat(rawBuffer[i + 16]);
vm[vi] = Float.intBitsToFloat(rawBuffer[i + 17]);
+ if (Compat.RPLE()) {
+ bsG[vi] = rawBuffer[i + 18];
+ bsB[vi] = rawBuffer[i + 19];
+ ue[vi] = Float.intBitsToFloat(rawBuffer[i + 20]);
+ ve[vi] = Float.intBitsToFloat(rawBuffer[i + 21]);
+ }
} else {
bs[vi] = flags.hasBrightness ? rawBuffer[i + 7] : DEFAULT_BRIGHTNESS;
@@ -108,6 +117,10 @@ public class MeshQuad {
if (Compat.RPLE()) {
bsG[3] = bsG[2];
bsB[3] = bsB[2];
+ if (Compat.isShaders()) {
+ ue[3] = ue[2];
+ ve[3] = ve[2];
+ }
}
cs[3] = cs[2];
if (Compat.isShaders()) {
@@ -173,10 +186,6 @@ public class MeshQuad {
out.writeInt(c);
out.writeInt(bs[vi]);
- if (Compat.RPLE()) {
- out.writeInt(bsG[vi]);
- out.writeInt(bsB[vi]);
- }
if (Compat.isShaders()) {
out.writeInt(e1[vi]);
@@ -191,6 +200,15 @@ public class MeshQuad {
out.writeFloat(um[vi]);
out.writeFloat(vm[vi]);
}
+
+ if (Compat.RPLE()) {
+ out.writeInt(bsG[vi]);
+ out.writeInt(bsB[vi]);
+ if (Compat.isShaders()) {
+ out.writeFloat(ue[vi]);
+ out.writeFloat(ve[vi]);
+ }
+ }
assert out.position() % expectedStride == 0;
diff --git a/src/main/java/makamys/neodymium/renderer/NeoRenderer.java b/src/main/java/makamys/neodymium/renderer/NeoRenderer.java
index 7d5928d..ed8be73 100644
--- a/src/main/java/makamys/neodymium/renderer/NeoRenderer.java
+++ b/src/main/java/makamys/neodymium/renderer/NeoRenderer.java
@@ -1,5 +1,8 @@
package makamys.neodymium.renderer;
+import com.falsepattern.falsetweaks.api.triangulator.VertexAPI;
+import com.falsepattern.rple.api.client.RPLELightMapUtil;
+import com.falsepattern.rple.api.client.RPLEShaderConstants;
import lombok.val;
import makamys.neodymium.Compat;
import makamys.neodymium.Neodymium;
@@ -430,7 +433,7 @@ public class NeoRenderer {
}
/**
- * @implSpec The attributes here need to be kept in sync with {@link MeshQuad#writeToBuffer(BufferWriter)}
+ * @implSpec The attributes here need to be kept in sync with {@link MeshQuad#writeToBuffer(BufferWriter, int)}
*/
public boolean init() {
// The average mesh is 60 KB. Let's be safe and assume 8 KB per mesh.
@@ -447,17 +450,27 @@ public class NeoRenderer {
attributes.addAttribute("TEXTURE", 2, 4, GL_FLOAT);
}
attributes.addAttribute("COLOR", 4, 1, GL_UNSIGNED_BYTE);
- attributes.addAttribute("BRIGHTNESS", 2, 2, GL_SHORT);
+ if (Compat.RPLE()) {
+ attributes.addAttribute("BRIGHTNESS_RED", 2, 2, GL_SHORT);
+ } else {
+ attributes.addAttribute("BRIGHTNESS", 2, 2, GL_SHORT);
+ }
if (Compat.isShaders()) {
attributes.addAttribute("ENTITY_DATA_1", 1, 4, GL_UNSIGNED_INT);
attributes.addAttribute("ENTITY_DATA_2", 1, 4, GL_UNSIGNED_INT);
attributes.addAttribute("NORMAL", 3, 4, GL_FLOAT);
attributes.addAttribute("TANGENT", 4, 4, GL_FLOAT);
attributes.addAttribute("MIDTEXTURE", 2, 4, GL_FLOAT);
- } else if (Compat.RPLE()) {
- attributes.addAttribute("BRIGHTNESS_RED", 2, 2, GL_SHORT);
- attributes.addAttribute("BRIGHTNESS_GREEN", 2, 2, GL_SHORT);
- attributes.addAttribute("BRIGHTNESS_BLUE", 2, 2, GL_SHORT);
+ if (Compat.RPLE()) {
+ attributes.addAttribute("BRIGHTNESS_GREEN", 2, 2, GL_SHORT);
+ attributes.addAttribute("BRIGHTNESS_BLUE", 2, 2, GL_SHORT);
+ attributes.addAttribute("EDGE_TEX", 2, 4, GL_FLOAT);
+ }
+ } else {
+ if (Compat.RPLE()) {
+ attributes.addAttribute("BRIGHTNESS_GREEN", 2, 2, GL_SHORT);
+ attributes.addAttribute("BRIGHTNESS_BLUE", 2, 2, GL_SHORT);
+ }
}
reloadShader();
@@ -479,7 +492,12 @@ public class NeoRenderer {
// tangent 4 floats 16 bytes offset 48
// midtexture 2 floats 8 bytes offset 64
if (Compat.isShaders()) {
- val stride = 72;
+ int stride;
+ if (Compat.FalseTweaks()) {
+ stride = VertexAPI.recomputeVertexInfo(18, 4);
+ } else {
+ stride = 72;
+ }
val entityAttrib = 10;
val midTexCoordAttrib = 11;
val tangentAttrib = 12;
@@ -522,6 +540,17 @@ public class NeoRenderer {
ARBVertexShader.glVertexAttribPointerARB(midTexCoordAttrib, 2, GL11.GL_FLOAT, false, stride, 64);
ARBVertexShader.glEnableVertexAttribArrayARB(midTexCoordAttrib);
+
+ if (Compat.RPLE()) {
+ RPLELightMapUtil.enableVertexPointersVBO();
+ ARBVertexShader.glVertexAttribPointerARB(RPLEShaderConstants.edgeTexCoordAttrib,
+ 2,
+ GL_FLOAT,
+ false,
+ stride,
+ 80);
+ ARBVertexShader.glEnableVertexAttribArrayARB(RPLEShaderConstants.edgeTexCoordAttrib);
+ }
} else {
attributes.enable();
}