diff options
author | FalsePattern <me@falsepattern.com> | 2023-12-05 18:36:05 +0100 |
---|---|---|
committer | makamys <makamys@outlook.com> | 2024-01-08 22:49:40 +0100 |
commit | df8f71cbdbe6086b5d360413ff7103f285a77915 (patch) | |
tree | d75103e044a8b1725d5be2eb9e0ef7fba84bbb22 /src | |
parent | 5ca3d83b6a27e899a61144bde07d9e07f204593a (diff) | |
download | Neodymium-df8f71cbdbe6086b5d360413ff7103f285a77915.tar.gz Neodymium-df8f71cbdbe6086b5d360413ff7103f285a77915.tar.bz2 Neodymium-df8f71cbdbe6086b5d360413ff7103f285a77915.zip |
begin shader compat
Diffstat (limited to 'src')
-rw-r--r-- | src/main/java/makamys/neodymium/Compat.java | 4 | ||||
-rw-r--r-- | src/main/java/makamys/neodymium/renderer/MeshQuad.java | 84 | ||||
-rw-r--r-- | src/main/java/makamys/neodymium/renderer/NeoRenderer.java | 13 |
3 files changed, 82 insertions, 19 deletions
diff --git a/src/main/java/makamys/neodymium/Compat.java b/src/main/java/makamys/neodymium/Compat.java index 8af4319..ba22265 100644 --- a/src/main/java/makamys/neodymium/Compat.java +++ b/src/main/java/makamys/neodymium/Compat.java @@ -44,6 +44,10 @@ public class Compat { return RPLE; } + public static boolean isShaders() { + return false; + } + private static void disableTriangulator() { ((ToggleableTessellator)Tessellator.instance).disableTriangulator(); } diff --git a/src/main/java/makamys/neodymium/renderer/MeshQuad.java b/src/main/java/makamys/neodymium/renderer/MeshQuad.java index 484ab8b..f748488 100644 --- a/src/main/java/makamys/neodymium/renderer/MeshQuad.java +++ b/src/main/java/makamys/neodymium/renderer/MeshQuad.java @@ -1,11 +1,8 @@ package makamys.neodymium.renderer; import java.io.IOException; -import java.util.Arrays; -import java.util.Comparator; import java.util.Locale; -import makamys.neodymium.Neodymium; import makamys.neodymium.Compat; import org.lwjgl.opengl.GL11; import org.lwjgl.util.vector.Vector3f; @@ -31,6 +28,21 @@ public class MeshQuad { public int[] bsG = new int[4]; public int[] bsB = new int[4]; + public int[] e1 = new int[4]; + public int[] e2 = new int[4]; + + public float[] xn = new float[4]; + public float[] yn = new float[4]; + public float[] zn = new float[4]; + + public float[] xt = new float[4]; + public float[] yt = new float[4]; + public float[] zt = new float[4]; + public float[] wt = new float[4]; + + public float[] um = new float[4]; + public float[] vm = new float[4]; + public boolean deleted; public QuadNormal normal; @@ -55,15 +67,30 @@ public class MeshQuad { // TODO normals? - bs[vi] = flags.hasBrightness ? rawBuffer[i + 7] : DEFAULT_BRIGHTNESS; - - if (Compat.RPLE()) { - if (flags.hasBrightness) { - bsG[vi] = rawBuffer[i + 8]; - bsB[vi] = rawBuffer[i + 9]; - } else { - bsG[vi] = DEFAULT_BRIGHTNESS; - bsB[vi] = DEFAULT_BRIGHTNESS; + if (Compat.isShaders()) { + bs[vi] = flags.hasBrightness ? rawBuffer[i + 6] : DEFAULT_BRIGHTNESS; + e1[vi] = rawBuffer[i + 7]; + e2[vi] = rawBuffer[i + 8]; + xn[vi] = Float.intBitsToFloat(rawBuffer[i + 9]); + yn[vi] = Float.intBitsToFloat(rawBuffer[i + 10]); + zn[vi] = Float.intBitsToFloat(rawBuffer[i + 11]); + xt[vi] = Float.intBitsToFloat(rawBuffer[i + 12]); + yt[vi] = Float.intBitsToFloat(rawBuffer[i + 13]); + zt[vi] = Float.intBitsToFloat(rawBuffer[i + 14]); + wt[vi] = Float.intBitsToFloat(rawBuffer[i + 15]); + um[vi] = Float.intBitsToFloat(rawBuffer[i + 16]); + vm[vi] = Float.intBitsToFloat(rawBuffer[i + 17]); + } else { + bs[vi] = flags.hasBrightness ? rawBuffer[i + 7] : DEFAULT_BRIGHTNESS; + + if (Compat.RPLE()) { + if (flags.hasBrightness) { + bsG[vi] = rawBuffer[i + 8]; + bsB[vi] = rawBuffer[i + 9]; + } else { + bsG[vi] = DEFAULT_BRIGHTNESS; + bsB[vi] = DEFAULT_BRIGHTNESS; + } } } } @@ -83,6 +110,19 @@ public class MeshQuad { bsB[3] = bsB[2]; } cs[3] = cs[2]; + if (Compat.isShaders()) { + e1[3] = e1[2]; + e2[3] = e2[2]; + xn[3] = xn[2]; + yn[3] = yn[2]; + zn[3] = zn[2]; + xt[3] = xt[2]; + yt[3] = yt[2]; + zt[3] = zt[2]; + wt[3] = wt[2]; + um[3] = um[2]; + vm[3] = vm[2]; + } } } @@ -128,15 +168,29 @@ public class MeshQuad { out.writeFloat(v); } + int c = cs[vi]; + + out.writeInt(c); + out.writeInt(bs[vi]); if (Compat.RPLE()) { out.writeInt(bsG[vi]); out.writeInt(bsB[vi]); } - int c = cs[vi]; - - out.writeInt(c); + if (Compat.isShaders()) { + out.writeInt(e1[vi]); + out.writeInt(e2[vi]); + out.writeFloat(xn[vi]); + out.writeFloat(yn[vi]); + out.writeFloat(zn[vi]); + out.writeFloat(xt[vi]); + out.writeFloat(yt[vi]); + out.writeFloat(zt[vi]); + out.writeFloat(wt[vi]); + out.writeFloat(um[vi]); + out.writeFloat(vm[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 6c0b015..fcd4c67 100644 --- a/src/main/java/makamys/neodymium/renderer/NeoRenderer.java +++ b/src/main/java/makamys/neodymium/renderer/NeoRenderer.java @@ -419,14 +419,19 @@ public class NeoRenderer { } else { attributes.addAttribute("TEXTURE", 2, 4, GL_FLOAT); } - if (Compat.RPLE()) { + attributes.addAttribute("COLOR", 4, 1, GL_UNSIGNED_BYTE); + 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); - } else { - attributes.addAttribute("BRIGHTNESS", 2, 2, GL_SHORT); } - attributes.addAttribute("COLOR", 4, 1, GL_UNSIGNED_BYTE); reloadShader(); |