From 8426006435f337883c56a7a47d8ea4c5944fc050 Mon Sep 17 00:00:00 2001 From: mcrcortex <18544518+MCRcortex@users.noreply.github.com> Date: Wed, 5 Nov 2025 15:30:03 +1000 Subject: [PATCH] barry + shift --- gradle.properties | 2 +- .../cortex/voxy/client/core/gl/Capabilities.java | 3 +++ .../rendering/building/RenderDataFactory.java | 16 ++++++++-------- .../rendering/section/MDICSectionRenderer.java | 2 ++ .../assets/voxy/shaders/lod/gl46/quads.frag | 9 +++++++++ .../assets/voxy/shaders/lod/gl46/quads3.vert | 6 ++---- .../assets/voxy/shaders/lod/quad_util.glsl | 2 +- 7 files changed, 26 insertions(+), 14 deletions(-) diff --git a/gradle.properties b/gradle.properties index 7530cea8..8b98d13e 100644 --- a/gradle.properties +++ b/gradle.properties @@ -16,6 +16,6 @@ fabric_version=0.134.1+1.21.10 # Mod Properties -mod_version = 0.2.6-alpha +mod_version = 0.2.7-alpha maven_group = me.cortex archives_base_name = voxy \ No newline at end of file diff --git a/src/main/java/me/cortex/voxy/client/core/gl/Capabilities.java b/src/main/java/me/cortex/voxy/client/core/gl/Capabilities.java index 9ed8d2b3..8a24377c 100644 --- a/src/main/java/me/cortex/voxy/client/core/gl/Capabilities.java +++ b/src/main/java/me/cortex/voxy/client/core/gl/Capabilities.java @@ -27,6 +27,7 @@ public class Capabilities { public final boolean subgroup; public final boolean sparseBuffer; public final boolean isNvidia; + public final boolean nvBarryCoords; public Capabilities() { var cap = GL.getCapabilities(); @@ -73,6 +74,8 @@ public class Capabilities { this.totalDedicatedMemory = -1; this.totalDynamicMemory = -1; } + + this.nvBarryCoords = cap.GL_NV_fragment_shader_barycentric; } public static void init() { diff --git a/src/main/java/me/cortex/voxy/client/core/rendering/building/RenderDataFactory.java b/src/main/java/me/cortex/voxy/client/core/rendering/building/RenderDataFactory.java index 5d20b2d6..c1d3b243 100644 --- a/src/main/java/me/cortex/voxy/client/core/rendering/building/RenderDataFactory.java +++ b/src/main/java/me/cortex/voxy/client/core/rendering/building/RenderDataFactory.java @@ -199,7 +199,7 @@ public class RenderDataFactory { private static long packPartialQuadData(int modelId, long state, long metadata) { //This uses hardcoded data to shuffle things - long lightAndBiome = (state&((0x1FFL<<47)|(0xFFL<<56)))>>1; + long lightAndBiome = (state&((0x1FFL<<47)|(0xFFL<<56)))>>>1; lightAndBiome &= ModelQueries.isBiomeColoured(metadata)?-1:~(0x1FFL<<46);//46 not 47 because is already shifted by 1 THIS WASTED 4 HOURS ;-; aaaaaAAAAAA lightAndBiome &= ModelQueries.isFullyOpaque(metadata)?~(0xFFL<<55):-1;//If its fully opaque it always uses neighbor light? @@ -221,7 +221,7 @@ public class RenderDataFactory { for (int i = 0; i < 32*32*32;) { long block = rawSectionData[i];//Get the block mapping if (Mapper.isAir(block)) {//If it is air, just emit lighting - sectionData[i * 2] = (block&(0xFFL<<56))>>1; + sectionData[i * 2] = (block&(0xFFL<<56))>>>1; sectionData[i * 2 + 1] = 0; } else { int modelId = rawModelIds[Mapper.getBlockId(block)]; @@ -484,7 +484,7 @@ public class RenderDataFactory { this.blockMesher.putNext(((side == 0) ? 0L : 1L) | (A&~LM) | - ((neighborId & (0xFFL << 56)) >> 1) + ((neighborId & (0xFFL << 56)) >>> 1) ); } } @@ -650,7 +650,7 @@ public class RenderDataFactory { this.blockMesher.putNext((side == 0 ? 0L : 1L) | (A&~LM) | - ((neighborId&(0xFFL<<56))>>1) + ((neighborId&(0xFFL<<56))>>>1) ); } } @@ -1017,7 +1017,7 @@ public class RenderDataFactory { long A = this.sectionData[(i<<5) * 2]; ma.putNext(0L | (A&~LM) | - ((neighborId&(0xFFL<<56))>>1) + ((neighborId&(0xFFL<<56))>>>1) ); } else {skipA++;} } else {skipA++;} @@ -1039,7 +1039,7 @@ public class RenderDataFactory { long A = this.sectionData[(i*32+31) * 2]; mb.putNext(1L | (A&~LM) | - ((neighborId&(0xFFL<<56))>>1) + ((neighborId&(0xFFL<<56))>>>1) ); } else {skipB++;} } else {skipB++;} @@ -1261,7 +1261,7 @@ public class RenderDataFactory { ma.skip(skipA); skipA = 0; //TODO: LIGHTING - long lightData = ((neighborId&(0xFFL<<56))>>1);//A; + long lightData = ((neighborId&(0xFFL<<56))>>>1);//A; //if (!ModelQueries.faceUsesSelfLighting(Am, facingForward|(axis*2))) {//TODO: check this is right // lighter = this.sectionData[bi]; //} @@ -1322,7 +1322,7 @@ public class RenderDataFactory { mb.skip(skipB); skipB = 0; //TODO: LIGHTING - long lightData = ((neighborId&(0xFFL<<56))>>1);//A; + long lightData = ((neighborId&(0xFFL<<56))>>>1);//A; //if (!ModelQueries.faceUsesSelfLighting(Am, facingForward|(axis*2))) {//TODO: check this is right // lighter = this.sectionData[bi]; //} diff --git a/src/main/java/me/cortex/voxy/client/core/rendering/section/MDICSectionRenderer.java b/src/main/java/me/cortex/voxy/client/core/rendering/section/MDICSectionRenderer.java index f8226d2e..f5aab62b 100644 --- a/src/main/java/me/cortex/voxy/client/core/rendering/section/MDICSectionRenderer.java +++ b/src/main/java/me/cortex/voxy/client/core/rendering/section/MDICSectionRenderer.java @@ -104,6 +104,8 @@ public class MDICSectionRenderer extends AbstractSectionRenderer>8)&0xFu, (interData.x>>12)&0xFu)+1); + #endif + vec2 uv2 = modf(uv, tile)*(1.0/(vec2(3.0,2.0)*256.0)); vec4 colour; vec2 texPos = uv2 + getBaseUV(); diff --git a/src/main/resources/assets/voxy/shaders/lod/gl46/quads3.vert b/src/main/resources/assets/voxy/shaders/lod/gl46/quads3.vert index 35d19fe7..2fd63921 100644 --- a/src/main/resources/assets/voxy/shaders/lod/gl46/quads3.vert +++ b/src/main/resources/assets/voxy/shaders/lod/gl46/quads3.vert @@ -7,15 +7,13 @@ #define POSITION_SCRATCH_BINDING 5 #define LIGHTING_SAMPLER_BINDING 1 -#define USE_INTERPOLATED_UV - #import #import #import #import layout(location = 0) out flat uvec4 interData; -#ifdef USE_INTERPOLATED_UV +#ifndef USE_NV_BARRY layout(location = 1) out vec2 uv; #endif @@ -37,7 +35,7 @@ void main() { uint cornerId = gl_VertexID&3; gl_Position = getQuadCornerPos(quad, cornerId); - #ifdef USE_INTERPOLATED_UV + #ifndef USE_NV_BARRY uv = getCornerUV(quad, cornerId); #endif diff --git a/src/main/resources/assets/voxy/shaders/lod/quad_util.glsl b/src/main/resources/assets/voxy/shaders/lod/quad_util.glsl index ba7d6bac..dcc62a54 100644 --- a/src/main/resources/assets/voxy/shaders/lod/quad_util.glsl +++ b/src/main/resources/assets/voxy/shaders/lod/quad_util.glsl @@ -182,7 +182,7 @@ vec4 getQuadCornerPos(in QuadData quad, uint cornerId) { return pos; } -#ifdef USE_INTERPOLATED_UV +#ifndef USE_NV_BARRY vec2 getCornerUV(const in QuadData quad, uint cornerId) { return quad.uvCorner + quad.quadSizeAddin*vec2((cornerId>>1)&1u, cornerId&1u); }