Fully works
This commit is contained in:
@@ -8,7 +8,7 @@ yarn_mappings=1.20.4+build.1
|
|||||||
loader_version=0.15.0
|
loader_version=0.15.0
|
||||||
|
|
||||||
# Mod Properties
|
# Mod Properties
|
||||||
mod_version = 0.0.2-alpha
|
mod_version = 0.0.3-alpha
|
||||||
maven_group = me.cortex
|
maven_group = me.cortex
|
||||||
archives_base_name = zenith
|
archives_base_name = zenith
|
||||||
|
|
||||||
|
|||||||
@@ -65,7 +65,7 @@ public class VoxelCore {
|
|||||||
|
|
||||||
this.postProcessing = null;//new PostProcessing();
|
this.postProcessing = null;//new PostProcessing();
|
||||||
|
|
||||||
this.world.getMapper().setCallbacks(a->{}, a->{});
|
this.world.getMapper().setCallbacks(this.renderer::addBlockState, a->{});
|
||||||
|
|
||||||
|
|
||||||
////Resave the db incase it failed a recovery
|
////Resave the db incase it failed a recovery
|
||||||
|
|||||||
@@ -244,6 +244,8 @@ public class ModelManager {
|
|||||||
|
|
||||||
faceModelData |= needsAlphaDiscard?1<<22:0;
|
faceModelData |= needsAlphaDiscard?1<<22:0;
|
||||||
|
|
||||||
|
faceModelData |= (!faceCoversFullBlock)?1<<23:0;
|
||||||
|
|
||||||
MemoryUtil.memPutInt(faceUploadPtr, faceModelData);
|
MemoryUtil.memPutInt(faceUploadPtr, faceModelData);
|
||||||
}
|
}
|
||||||
this.metadataCache[modelId] = metadata;
|
this.metadataCache[modelId] = metadata;
|
||||||
|
|||||||
@@ -7,6 +7,8 @@ import me.cortex.zenith.client.core.gl.GlBuffer;
|
|||||||
import me.cortex.zenith.client.core.model.ModelManager;
|
import me.cortex.zenith.client.core.model.ModelManager;
|
||||||
import me.cortex.zenith.client.core.rendering.building.BuiltSection;
|
import me.cortex.zenith.client.core.rendering.building.BuiltSection;
|
||||||
import me.cortex.zenith.client.core.rendering.util.UploadStream;
|
import me.cortex.zenith.client.core.rendering.util.UploadStream;
|
||||||
|
import me.cortex.zenith.common.world.other.Mapper;
|
||||||
|
import net.minecraft.block.BlockState;
|
||||||
import net.minecraft.client.MinecraftClient;
|
import net.minecraft.client.MinecraftClient;
|
||||||
import net.minecraft.client.render.Camera;
|
import net.minecraft.client.render.Camera;
|
||||||
import net.minecraft.client.render.Frustum;
|
import net.minecraft.client.render.Frustum;
|
||||||
@@ -15,6 +17,8 @@ import org.joml.FrustumIntersection;
|
|||||||
import org.lwjgl.system.MemoryUtil;
|
import org.lwjgl.system.MemoryUtil;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
|
import java.util.concurrent.ConcurrentLinkedDeque;
|
||||||
|
|
||||||
import static org.lwjgl.opengl.ARBMultiDrawIndirect.glMultiDrawElementsIndirect;
|
import static org.lwjgl.opengl.ARBMultiDrawIndirect.glMultiDrawElementsIndirect;
|
||||||
import static org.lwjgl.opengl.GL30.*;
|
import static org.lwjgl.opengl.GL30.*;
|
||||||
@@ -43,6 +47,7 @@ public abstract class AbstractFarWorldRenderer {
|
|||||||
|
|
||||||
protected FrustumIntersection frustum;
|
protected FrustumIntersection frustum;
|
||||||
|
|
||||||
|
private final ConcurrentLinkedDeque<Mapper.StateEntry> blockStateUpdates = new ConcurrentLinkedDeque<>();
|
||||||
public AbstractFarWorldRenderer(int geometrySize, int maxSections) {
|
public AbstractFarWorldRenderer(int geometrySize, int maxSections) {
|
||||||
this.uniformBuffer = new GlBuffer(1024);
|
this.uniformBuffer = new GlBuffer(1024);
|
||||||
this.lightDataBuffer = new GlBuffer(256*4);//256 of uint
|
this.lightDataBuffer = new GlBuffer(256*4);//256 of uint
|
||||||
@@ -59,7 +64,6 @@ public abstract class AbstractFarWorldRenderer {
|
|||||||
this.sy = camera.getBlockPos().getY() >> 5;
|
this.sy = camera.getBlockPos().getY() >> 5;
|
||||||
this.sz = camera.getBlockPos().getZ() >> 5;
|
this.sz = camera.getBlockPos().getZ() >> 5;
|
||||||
|
|
||||||
|
|
||||||
//TODO: move this to a render function that is only called
|
//TODO: move this to a render function that is only called
|
||||||
// once per frame when using multi viewport mods
|
// once per frame when using multi viewport mods
|
||||||
//it shouldent matter if its called multiple times a frame however, as its synced with fences
|
//it shouldent matter if its called multiple times a frame however, as its synced with fences
|
||||||
@@ -80,6 +84,12 @@ public abstract class AbstractFarWorldRenderer {
|
|||||||
|
|
||||||
//Upload any new geometry
|
//Upload any new geometry
|
||||||
this.geometry.uploadResults();
|
this.geometry.uploadResults();
|
||||||
|
|
||||||
|
//Do any BlockChanges
|
||||||
|
while (!this.blockStateUpdates.isEmpty()) {
|
||||||
|
var update = this.blockStateUpdates.pop();
|
||||||
|
this.models.addEntry(update.id, update.state);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public abstract void renderFarAwayOpaque(MatrixStack stack, double cx, double cy, double cz);
|
public abstract void renderFarAwayOpaque(MatrixStack stack, double cx, double cy, double cz);
|
||||||
@@ -90,6 +100,10 @@ public abstract class AbstractFarWorldRenderer {
|
|||||||
this.geometry.enqueueResult(result);
|
this.geometry.enqueueResult(result);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void addBlockState(Mapper.StateEntry entry) {
|
||||||
|
this.blockStateUpdates.add(entry);
|
||||||
|
}
|
||||||
|
|
||||||
public void addDebugData(List<String> debug) {
|
public void addDebugData(List<String> debug) {
|
||||||
this.models.addDebugInfo(debug);
|
this.models.addDebugInfo(debug);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -10,4 +10,8 @@ vec4 extractFaceSizes(uint faceData) {
|
|||||||
|
|
||||||
uint faceHasAlphaCuttout(uint faceData) {
|
uint faceHasAlphaCuttout(uint faceData) {
|
||||||
return (faceData>>22)&1;
|
return (faceData>>22)&1;
|
||||||
|
}
|
||||||
|
|
||||||
|
uint faceHasAlphaCuttoutOverride(uint faceData) {
|
||||||
|
return (faceData>>23)&1;
|
||||||
}
|
}
|
||||||
@@ -20,7 +20,8 @@ void main() {
|
|||||||
//Transform ipos with respect to the vertex corner
|
//Transform ipos with respect to the vertex corner
|
||||||
ivec3 pos = (((ipos<<detail)-baseSectionPos)<<5);
|
ivec3 pos = (((ipos<<detail)-baseSectionPos)<<5);
|
||||||
pos += aabbOffset;
|
pos += aabbOffset;
|
||||||
pos += (ivec3(gl_VertexID&1, (gl_VertexID>>2)&1, (gl_VertexID>>1)&1)*size)*(1<<detail);
|
pos -= (1<<detail);
|
||||||
|
pos += (ivec3(gl_VertexID&1, (gl_VertexID>>2)&1, (gl_VertexID>>1)&1)*(size+1))*(1<<detail);
|
||||||
|
|
||||||
gl_Position = MVP * vec4(vec3(pos),1);
|
gl_Position = MVP * vec4(vec3(pos),1);
|
||||||
|
|
||||||
|
|||||||
@@ -1,6 +1,9 @@
|
|||||||
#version 460 core
|
#version 460 core
|
||||||
layout(binding = 0) uniform sampler2D blockModelAtlas;
|
layout(binding = 0) uniform sampler2D blockModelAtlas;
|
||||||
|
|
||||||
|
//TODO: need to fix when merged quads have discardAlpha set to false but they span multiple tiles
|
||||||
|
// however they are not a full block
|
||||||
|
|
||||||
layout(location = 0) in vec2 uv;
|
layout(location = 0) in vec2 uv;
|
||||||
layout(location = 1) in flat vec2 baseUV;
|
layout(location = 1) in flat vec2 baseUV;
|
||||||
layout(location = 2) in flat vec4 colourTinting;
|
layout(location = 2) in flat vec4 colourTinting;
|
||||||
|
|||||||
@@ -60,8 +60,9 @@ void main() {
|
|||||||
vec3 corner = innerPos * (1<<lodLevel) + lodCorner;
|
vec3 corner = innerPos * (1<<lodLevel) + lodCorner;
|
||||||
|
|
||||||
vec2 faceOffset = getFaceSizeOffset(faceData, cornerIdx);
|
vec2 faceOffset = getFaceSizeOffset(faceData, cornerIdx);
|
||||||
vec2 quadSize = vec2(extractSize(quad) * ivec2((cornerIdx>>1)&1, cornerIdx&1));
|
ivec2 quadSize = extractSize(quad);
|
||||||
vec2 size = (quadSize + faceOffset) * (1<<lodLevel);
|
vec2 respectiveQuadSize = vec2(quadSize * ivec2((cornerIdx>>1)&1, cornerIdx&1));
|
||||||
|
vec2 size = (respectiveQuadSize + faceOffset) * (1<<lodLevel);
|
||||||
|
|
||||||
vec3 offset = vec3(size, (float(face&1) + getDepthOffset(faceData, face)) * (1<<lodLevel));
|
vec3 offset = vec3(size, (float(face&1) + getDepthOffset(faceData, face)) * (1<<lodLevel));
|
||||||
|
|
||||||
@@ -84,10 +85,13 @@ void main() {
|
|||||||
//TODO: make the face orientated by 2x3 so that division is not a integer div and modulo isnt needed
|
//TODO: make the face orientated by 2x3 so that division is not a integer div and modulo isnt needed
|
||||||
// as these are very slow ops
|
// as these are very slow ops
|
||||||
baseUV = modelUV + (vec2(face%3, face/3) * (1f/(vec2(3,2)*256f)));
|
baseUV = modelUV + (vec2(face%3, face/3) * (1f/(vec2(3,2)*256f)));
|
||||||
uv = quadSize + faceOffset;//Add in the face offset for 0,0 uv
|
uv = respectiveQuadSize + faceOffset;//Add in the face offset for 0,0 uv
|
||||||
|
|
||||||
discardAlpha = faceHasAlphaCuttout(faceData);
|
discardAlpha = faceHasAlphaCuttout(faceData);
|
||||||
|
|
||||||
|
//We need to have a conditional override based on if the model size is < a full face + quadSize > 1
|
||||||
|
discardAlpha |= uint(any(greaterThan(quadSize, ivec2(1)))) & faceHasAlphaCuttoutOverride(faceData);
|
||||||
|
|
||||||
//Compute lighting
|
//Compute lighting
|
||||||
colourTinting = getLighting(extractLightId(quad));
|
colourTinting = getLighting(extractLightId(quad));
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user