barry + shift
This commit is contained in:
@@ -16,6 +16,6 @@ fabric_version=0.134.1+1.21.10
|
|||||||
|
|
||||||
|
|
||||||
# Mod Properties
|
# Mod Properties
|
||||||
mod_version = 0.2.6-alpha
|
mod_version = 0.2.7-alpha
|
||||||
maven_group = me.cortex
|
maven_group = me.cortex
|
||||||
archives_base_name = voxy
|
archives_base_name = voxy
|
||||||
@@ -27,6 +27,7 @@ public class Capabilities {
|
|||||||
public final boolean subgroup;
|
public final boolean subgroup;
|
||||||
public final boolean sparseBuffer;
|
public final boolean sparseBuffer;
|
||||||
public final boolean isNvidia;
|
public final boolean isNvidia;
|
||||||
|
public final boolean nvBarryCoords;
|
||||||
|
|
||||||
public Capabilities() {
|
public Capabilities() {
|
||||||
var cap = GL.getCapabilities();
|
var cap = GL.getCapabilities();
|
||||||
@@ -73,6 +74,8 @@ public class Capabilities {
|
|||||||
this.totalDedicatedMemory = -1;
|
this.totalDedicatedMemory = -1;
|
||||||
this.totalDynamicMemory = -1;
|
this.totalDynamicMemory = -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
this.nvBarryCoords = cap.GL_NV_fragment_shader_barycentric;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void init() {
|
public static void init() {
|
||||||
|
|||||||
@@ -199,7 +199,7 @@ public class RenderDataFactory {
|
|||||||
|
|
||||||
private static long packPartialQuadData(int modelId, long state, long metadata) {
|
private static long packPartialQuadData(int modelId, long state, long metadata) {
|
||||||
//This uses hardcoded data to shuffle things
|
//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.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?
|
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;) {
|
for (int i = 0; i < 32*32*32;) {
|
||||||
long block = rawSectionData[i];//Get the block mapping
|
long block = rawSectionData[i];//Get the block mapping
|
||||||
if (Mapper.isAir(block)) {//If it is air, just emit lighting
|
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;
|
sectionData[i * 2 + 1] = 0;
|
||||||
} else {
|
} else {
|
||||||
int modelId = rawModelIds[Mapper.getBlockId(block)];
|
int modelId = rawModelIds[Mapper.getBlockId(block)];
|
||||||
@@ -484,7 +484,7 @@ public class RenderDataFactory {
|
|||||||
|
|
||||||
this.blockMesher.putNext(((side == 0) ? 0L : 1L) |
|
this.blockMesher.putNext(((side == 0) ? 0L : 1L) |
|
||||||
(A&~LM) |
|
(A&~LM) |
|
||||||
((neighborId & (0xFFL << 56)) >> 1)
|
((neighborId & (0xFFL << 56)) >>> 1)
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -650,7 +650,7 @@ public class RenderDataFactory {
|
|||||||
|
|
||||||
this.blockMesher.putNext((side == 0 ? 0L : 1L) |
|
this.blockMesher.putNext((side == 0 ? 0L : 1L) |
|
||||||
(A&~LM) |
|
(A&~LM) |
|
||||||
((neighborId&(0xFFL<<56))>>1)
|
((neighborId&(0xFFL<<56))>>>1)
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1017,7 +1017,7 @@ public class RenderDataFactory {
|
|||||||
long A = this.sectionData[(i<<5) * 2];
|
long A = this.sectionData[(i<<5) * 2];
|
||||||
ma.putNext(0L |
|
ma.putNext(0L |
|
||||||
(A&~LM) |
|
(A&~LM) |
|
||||||
((neighborId&(0xFFL<<56))>>1)
|
((neighborId&(0xFFL<<56))>>>1)
|
||||||
);
|
);
|
||||||
} else {skipA++;}
|
} else {skipA++;}
|
||||||
} else {skipA++;}
|
} else {skipA++;}
|
||||||
@@ -1039,7 +1039,7 @@ public class RenderDataFactory {
|
|||||||
long A = this.sectionData[(i*32+31) * 2];
|
long A = this.sectionData[(i*32+31) * 2];
|
||||||
mb.putNext(1L |
|
mb.putNext(1L |
|
||||||
(A&~LM) |
|
(A&~LM) |
|
||||||
((neighborId&(0xFFL<<56))>>1)
|
((neighborId&(0xFFL<<56))>>>1)
|
||||||
);
|
);
|
||||||
} else {skipB++;}
|
} else {skipB++;}
|
||||||
} else {skipB++;}
|
} else {skipB++;}
|
||||||
@@ -1261,7 +1261,7 @@ public class RenderDataFactory {
|
|||||||
ma.skip(skipA); skipA = 0;
|
ma.skip(skipA); skipA = 0;
|
||||||
|
|
||||||
//TODO: LIGHTING
|
//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
|
//if (!ModelQueries.faceUsesSelfLighting(Am, facingForward|(axis*2))) {//TODO: check this is right
|
||||||
// lighter = this.sectionData[bi];
|
// lighter = this.sectionData[bi];
|
||||||
//}
|
//}
|
||||||
@@ -1322,7 +1322,7 @@ public class RenderDataFactory {
|
|||||||
mb.skip(skipB); skipB = 0;
|
mb.skip(skipB); skipB = 0;
|
||||||
|
|
||||||
//TODO: LIGHTING
|
//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
|
//if (!ModelQueries.faceUsesSelfLighting(Am, facingForward|(axis*2))) {//TODO: check this is right
|
||||||
// lighter = this.sectionData[bi];
|
// lighter = this.sectionData[bi];
|
||||||
//}
|
//}
|
||||||
|
|||||||
@@ -104,6 +104,8 @@ public class MDICSectionRenderer extends AbstractSectionRenderer<MDICViewport, B
|
|||||||
.defineIf("TAA_PATCH", taa != null)
|
.defineIf("TAA_PATCH", taa != null)
|
||||||
.defineIf("DEBUG_RENDER", false)
|
.defineIf("DEBUG_RENDER", false)
|
||||||
|
|
||||||
|
//.defineIf("USE_NV_BARRY", Capabilities.INSTANCE.nvBarryCoords)
|
||||||
|
|
||||||
.defineIf("DARKENED_TINTING", Minecraft.getInstance().level.effects().constantAmbientLight())//TODO: FIXME: this is really jank atm
|
.defineIf("DARKENED_TINTING", Minecraft.getInstance().level.effects().constantAmbientLight())//TODO: FIXME: this is really jank atm
|
||||||
|
|
||||||
.addSource(ShaderType.VERTEX, vertex);
|
.addSource(ShaderType.VERTEX, vertex);
|
||||||
|
|||||||
@@ -2,6 +2,9 @@
|
|||||||
//Use quad shuffling to compute fragment mip
|
//Use quad shuffling to compute fragment mip
|
||||||
//#extension GL_KHR_shader_subgroup_quad: enable
|
//#extension GL_KHR_shader_subgroup_quad: enable
|
||||||
|
|
||||||
|
#ifdef USE_NV_BARRY
|
||||||
|
#extension GL_NV_fragment_shader_barycentric: require
|
||||||
|
#endif
|
||||||
|
|
||||||
layout(binding = 0) uniform sampler2D blockModelAtlas;
|
layout(binding = 0) uniform sampler2D blockModelAtlas;
|
||||||
layout(binding = 2) uniform sampler2D depthTex;
|
layout(binding = 2) uniform sampler2D depthTex;
|
||||||
@@ -12,7 +15,9 @@ layout(binding = 2) uniform sampler2D depthTex;
|
|||||||
// however they are not a full block
|
// however they are not a full block
|
||||||
|
|
||||||
layout(location = 0) in flat uvec4 interData;
|
layout(location = 0) in flat uvec4 interData;
|
||||||
|
#ifndef USE_NV_BARRY
|
||||||
layout(location = 1) in vec2 uv;
|
layout(location = 1) in vec2 uv;
|
||||||
|
#endif
|
||||||
|
|
||||||
#ifdef DEBUG_RENDER
|
#ifdef DEBUG_RENDER
|
||||||
layout(location = 7) in flat uint quadDebug;
|
layout(location = 7) in flat uint quadDebug;
|
||||||
@@ -109,6 +114,10 @@ void main() {
|
|||||||
//vec2 uv = vec2(0);
|
//vec2 uv = vec2(0);
|
||||||
//Tile is the tile we are in
|
//Tile is the tile we are in
|
||||||
vec2 tile;
|
vec2 tile;
|
||||||
|
#ifdef USE_NV_BARRY
|
||||||
|
vec2 uv = mix(gl_BaryCoordNV.yx, 1-gl_BaryCoordNV.xz, gl_PrimitiveID&1)*(vec2((interData.x>>8)&0xFu, (interData.x>>12)&0xFu)+1);
|
||||||
|
#endif
|
||||||
|
|
||||||
vec2 uv2 = modf(uv, tile)*(1.0/(vec2(3.0,2.0)*256.0));
|
vec2 uv2 = modf(uv, tile)*(1.0/(vec2(3.0,2.0)*256.0));
|
||||||
vec4 colour;
|
vec4 colour;
|
||||||
vec2 texPos = uv2 + getBaseUV();
|
vec2 texPos = uv2 + getBaseUV();
|
||||||
|
|||||||
@@ -7,15 +7,13 @@
|
|||||||
#define POSITION_SCRATCH_BINDING 5
|
#define POSITION_SCRATCH_BINDING 5
|
||||||
#define LIGHTING_SAMPLER_BINDING 1
|
#define LIGHTING_SAMPLER_BINDING 1
|
||||||
|
|
||||||
#define USE_INTERPOLATED_UV
|
|
||||||
|
|
||||||
#import <voxy:lod/quad_format.glsl>
|
#import <voxy:lod/quad_format.glsl>
|
||||||
#import <voxy:lod/block_model.glsl>
|
#import <voxy:lod/block_model.glsl>
|
||||||
#import <voxy:lod/gl46/bindings.glsl>
|
#import <voxy:lod/gl46/bindings.glsl>
|
||||||
#import <voxy:lod/quad_util.glsl>
|
#import <voxy:lod/quad_util.glsl>
|
||||||
|
|
||||||
layout(location = 0) out flat uvec4 interData;
|
layout(location = 0) out flat uvec4 interData;
|
||||||
#ifdef USE_INTERPOLATED_UV
|
#ifndef USE_NV_BARRY
|
||||||
layout(location = 1) out vec2 uv;
|
layout(location = 1) out vec2 uv;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
@@ -37,7 +35,7 @@ void main() {
|
|||||||
uint cornerId = gl_VertexID&3;
|
uint cornerId = gl_VertexID&3;
|
||||||
gl_Position = getQuadCornerPos(quad, cornerId);
|
gl_Position = getQuadCornerPos(quad, cornerId);
|
||||||
|
|
||||||
#ifdef USE_INTERPOLATED_UV
|
#ifndef USE_NV_BARRY
|
||||||
uv = getCornerUV(quad, cornerId);
|
uv = getCornerUV(quad, cornerId);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|||||||
@@ -182,7 +182,7 @@ vec4 getQuadCornerPos(in QuadData quad, uint cornerId) {
|
|||||||
return pos;
|
return pos;
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef USE_INTERPOLATED_UV
|
#ifndef USE_NV_BARRY
|
||||||
vec2 getCornerUV(const in QuadData quad, uint cornerId) {
|
vec2 getCornerUV(const in QuadData quad, uint cornerId) {
|
||||||
return quad.uvCorner + quad.quadSizeAddin*vec2((cornerId>>1)&1u, cornerId&1u);
|
return quad.uvCorner + quad.quadSizeAddin*vec2((cornerId>>1)&1u, cornerId&1u);
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user