Starlight compat, start on render distance slider, added viewport "api", tweeked caching rings to 6,6
This commit is contained in:
@@ -23,6 +23,7 @@ public class VoxyConfig {
|
||||
public boolean ingestEnabled = true;
|
||||
public int qualityScale = 12;
|
||||
public int maxSections = 200_000;
|
||||
public int renderDistance = 128;
|
||||
public int geometryBufferSize = (1<<30)/8;
|
||||
public int ingestThreads = 2;
|
||||
public int savingThreads = 4;
|
||||
|
||||
@@ -91,6 +91,12 @@ public class VoxyConfigScreenFactory implements ModMenuApi {
|
||||
.setDefaultValue(DEFAULT.maxSections)
|
||||
.build());
|
||||
|
||||
category.addEntry(entryBuilder.startIntSlider(Text.translatable("voxy.config.general.renderDistance"), config.maxSections, 16, 2048)
|
||||
.setTooltip(Text.translatable("voxy.config.general.renderDistance.tooltip"))
|
||||
.setSaveConsumer(val -> config.renderDistance = val)
|
||||
.setDefaultValue(DEFAULT.renderDistance)
|
||||
.build());
|
||||
|
||||
//category.addEntry(entryBuilder.startIntSlider(Text.translatable("voxy.config.general.compression"), config.savingCompressionLevel, 1, 21)
|
||||
// .setTooltip(Text.translatable("voxy.config.general.compression.tooltip"))
|
||||
// .setSaveConsumer(val -> config.savingCompressionLevel = val)
|
||||
|
||||
@@ -22,14 +22,16 @@ public class DistanceTracker {
|
||||
private final RenderTracker tracker;
|
||||
private final int minYSection;
|
||||
private final int maxYSection;
|
||||
private final int renderDistance;
|
||||
|
||||
public DistanceTracker(RenderTracker tracker, int[] lodRingScales, int cacheLoadDistance, int cacheUnloadDistance) {
|
||||
public DistanceTracker(RenderTracker tracker, int[] lodRingScales, int renderDistance, int cacheLoadDistance, int cacheUnloadDistance) {
|
||||
this.loDRings = new TransitionRing2D[lodRingScales.length];
|
||||
this.cacheLoadRings = new TransitionRing2D[lodRingScales.length];
|
||||
this.cacheUnloadRings = new TransitionRing2D[lodRingScales.length];
|
||||
this.tracker = tracker;
|
||||
this.minYSection = MinecraftClient.getInstance().world.getBottomSectionCoord()/2;//-128;
|
||||
this.maxYSection = MinecraftClient.getInstance().world.getTopSectionCoord()/2;//128;
|
||||
this.renderDistance = renderDistance;
|
||||
|
||||
|
||||
//The rings 0+ start at 64 vanilla rd, no matter what the game is set at, that is if the game is set to 32 rd
|
||||
|
||||
@@ -49,10 +49,12 @@ public class VoxelCore {
|
||||
private final RenderTracker renderTracker;
|
||||
|
||||
private final AbstractFarWorldRenderer renderer;
|
||||
private Viewport viewport;
|
||||
private final PostProcessing postProcessing;
|
||||
|
||||
//private final Thread shutdownThread = new Thread(this::shutdown);
|
||||
|
||||
|
||||
public VoxelCore(ContextSelectionSystem.Selection worldSelection) {
|
||||
this.world = worldSelection.createEngine();
|
||||
System.out.println("Initializing voxy core");
|
||||
@@ -60,6 +62,7 @@ public class VoxelCore {
|
||||
//Trigger the shared index buffer loading
|
||||
SharedIndexBuffer.INSTANCE.id();
|
||||
this.renderer = new Gl46FarWorldRenderer(VoxyConfig.CONFIG.geometryBufferSize, VoxyConfig.CONFIG.maxSections);
|
||||
this.viewport = this.renderer.createViewport();
|
||||
System.out.println("Renderer initialized");
|
||||
|
||||
this.renderTracker = new RenderTracker(this.world, this.renderer);
|
||||
@@ -71,7 +74,7 @@ public class VoxelCore {
|
||||
//To get to chunk scale multiply the scale by 2, the scale is after how many chunks does the lods halve
|
||||
int q = VoxyConfig.CONFIG.qualityScale;
|
||||
//TODO: add an option for cache load and unload distance
|
||||
this.distanceTracker = new DistanceTracker(this.renderTracker, new int[]{q,q,q,q}, 8, 16);
|
||||
this.distanceTracker = new DistanceTracker(this.renderTracker, new int[]{q,q,q,q}, VoxyConfig.CONFIG.renderDistance/2, 6, 6);
|
||||
System.out.println("Distance tracker initialized");
|
||||
|
||||
this.postProcessing = new PostProcessing();
|
||||
@@ -151,21 +154,13 @@ public class VoxelCore {
|
||||
//var fb = Iris.getPipelineManager().getPipelineNullable().getSodiumTerrainPipeline().getTerrainSolidFramebuffer();
|
||||
//fb.bind();
|
||||
|
||||
var projection = computeProjectionMat();
|
||||
this.viewport.setProjection(projection).setModelView(matrices.peek().getPositionMatrix()).setCamera(cameraX, cameraY, cameraZ);
|
||||
|
||||
int boundFB = GL11.glGetInteger(GL_DRAW_FRAMEBUFFER_BINDING);
|
||||
this.postProcessing.setup(MinecraftClient.getInstance().getFramebuffer().textureWidth, MinecraftClient.getInstance().getFramebuffer().textureHeight, boundFB);
|
||||
|
||||
//TODO: FIXME: since we just bound the post processing FB the depth information isnt
|
||||
// copied over, we must do this manually and also copy it with respect to the
|
||||
// near/far planes
|
||||
|
||||
|
||||
//TODO: have the renderer also render a bounding full face just like black boarders around lvl 0
|
||||
// this is cause the terrain might not exist and so all the caves are visible causing hell for the
|
||||
// occlusion culler
|
||||
|
||||
var projection = computeProjectionMat();
|
||||
|
||||
this.renderer.renderFarAwayOpaque(projection, matrices, cameraX, cameraY, cameraZ);
|
||||
this.renderer.renderFarAwayOpaque(this.viewport);
|
||||
|
||||
//Compute the SSAO of the rendered terrain
|
||||
this.postProcessing.computeSSAO(projection, matrices);
|
||||
@@ -204,7 +199,7 @@ public class VoxelCore {
|
||||
System.out.println("Render gen shut down");
|
||||
try {this.world.shutdown();} catch (Exception e) {System.err.println(e);}
|
||||
System.out.println("World engine shut down");
|
||||
try {this.renderer.shutdown();} catch (Exception e) {System.err.println(e);}
|
||||
try {this.renderer.shutdown(); if (viewport!=null)this.viewport.delete();} catch (Exception e) {System.err.println(e);}
|
||||
System.out.println("Renderer shut down");
|
||||
if (this.postProcessing!=null){try {this.postProcessing.shutdown();} catch (Exception e) {System.err.println(e);}}
|
||||
System.out.println("Voxel core shut down");
|
||||
|
||||
@@ -39,8 +39,7 @@ import static org.lwjgl.opengl.ARBImaging.glBlendEquation;
|
||||
import static org.lwjgl.opengl.ARBShaderImageLoadStore.GL_FRAMEBUFFER_BARRIER_BIT;
|
||||
import static org.lwjgl.opengl.ARBShaderImageLoadStore.glMemoryBarrier;
|
||||
import static org.lwjgl.opengl.GL11.*;
|
||||
import static org.lwjgl.opengl.GL13.GL_TEXTURE0;
|
||||
import static org.lwjgl.opengl.GL13.glActiveTexture;
|
||||
import static org.lwjgl.opengl.GL13.*;
|
||||
import static org.lwjgl.opengl.GL14C.glBlendFuncSeparate;
|
||||
import static org.lwjgl.opengl.GL20C.glUniformMatrix4fv;
|
||||
import static org.lwjgl.opengl.GL45C.glBlitNamedFramebuffer;
|
||||
@@ -59,6 +58,7 @@ public class ModelTextureBakery {
|
||||
.addCapability(GL_BLEND)
|
||||
.addCapability(GL_CULL_FACE)
|
||||
.addTexture(GL_TEXTURE0)
|
||||
.addTexture(GL_TEXTURE1)
|
||||
.build()
|
||||
;
|
||||
private final Shader rasterShader = Shader.make()
|
||||
@@ -138,7 +138,8 @@ public class ModelTextureBakery {
|
||||
}
|
||||
|
||||
|
||||
renderLayer.startDrawing();
|
||||
//TODO: figure out why calling this makes minecraft render black
|
||||
//renderLayer.startDrawing();
|
||||
glClearColor(0,0,0,0);
|
||||
glClearDepth(1);
|
||||
glBindFramebuffer(GL_FRAMEBUFFER, this.framebuffer.id);
|
||||
|
||||
@@ -3,12 +3,14 @@ package me.cortex.voxy.client.core.rendering;
|
||||
//NOTE: an idea on how to do it is so that any render section, we _keep_ aquired (yes this will be very memory intensive)
|
||||
// could maybe tosomething else
|
||||
|
||||
import com.mojang.blaze3d.systems.RenderSystem;
|
||||
import me.cortex.voxy.client.core.gl.GlBuffer;
|
||||
import me.cortex.voxy.client.core.model.ModelManager;
|
||||
import me.cortex.voxy.client.core.rendering.building.BuiltSection;
|
||||
import me.cortex.voxy.client.core.rendering.util.DownloadStream;
|
||||
import me.cortex.voxy.client.core.rendering.util.UploadStream;
|
||||
import me.cortex.voxy.common.world.other.Mapper;
|
||||
import net.minecraft.block.Blocks;
|
||||
import net.minecraft.client.MinecraftClient;
|
||||
import net.minecraft.client.render.Camera;
|
||||
import net.minecraft.client.render.Frustum;
|
||||
@@ -36,7 +38,7 @@ import static org.lwjgl.opengl.GL30.*;
|
||||
|
||||
|
||||
//Todo: tinker with having the compute shader where each thread is a position to render? maybe idk
|
||||
public abstract class AbstractFarWorldRenderer {
|
||||
public abstract class AbstractFarWorldRenderer <T extends Viewport> {
|
||||
protected final int vao = glGenVertexArrays();
|
||||
|
||||
protected final GlBuffer uniformBuffer;
|
||||
@@ -44,6 +46,8 @@ public abstract class AbstractFarWorldRenderer {
|
||||
protected final ModelManager models;
|
||||
protected final GlBuffer lightDataBuffer;
|
||||
|
||||
protected final int maxSections;
|
||||
|
||||
//Current camera base level section position
|
||||
protected int sx;
|
||||
protected int sy;
|
||||
@@ -54,6 +58,7 @@ public abstract class AbstractFarWorldRenderer {
|
||||
private final ConcurrentLinkedDeque<Mapper.StateEntry> blockStateUpdates = new ConcurrentLinkedDeque<>();
|
||||
private final ConcurrentLinkedDeque<Mapper.BiomeEntry> biomeUpdates = new ConcurrentLinkedDeque<>();
|
||||
public AbstractFarWorldRenderer(int geometrySize, int maxSections) {
|
||||
this.maxSections = maxSections;
|
||||
this.uniformBuffer = new GlBuffer(1024);
|
||||
this.lightDataBuffer = new GlBuffer(256*4);//256 of uint
|
||||
this.geometry = new GeometryManager(geometrySize*8L, maxSections);
|
||||
@@ -112,11 +117,14 @@ public abstract class AbstractFarWorldRenderer {
|
||||
var update = this.blockStateUpdates.pop();
|
||||
this.models.addEntry(update.id, update.state);
|
||||
}
|
||||
//this.models.bakery.renderFaces(Blocks.LAVA.getDefaultState(), 1234, true);
|
||||
}
|
||||
|
||||
//TODO: fix this in a better way than this ungodly hacky stuff
|
||||
RenderSystem.setShaderFogColor(1f, 1f, 1f, 0f);
|
||||
}
|
||||
|
||||
public abstract void renderFarAwayOpaque(Matrix4f projection, MatrixStack stack, double cx, double cy, double cz);
|
||||
public abstract void renderFarAwayOpaque(T viewport);
|
||||
|
||||
public abstract void renderFarAwayTranslucent();
|
||||
|
||||
@@ -147,4 +155,6 @@ public abstract class AbstractFarWorldRenderer {
|
||||
public ModelManager getModelManager() {
|
||||
return this.models;
|
||||
}
|
||||
|
||||
public abstract T createViewport();
|
||||
}
|
||||
|
||||
@@ -5,6 +5,7 @@ import me.cortex.voxy.client.core.gl.shader.Shader;
|
||||
import me.cortex.voxy.client.core.gl.shader.ShaderType;
|
||||
import me.cortex.voxy.client.core.rendering.util.UploadStream;
|
||||
import me.cortex.voxy.client.mixin.joml.AccessFrustumIntersection;
|
||||
import net.minecraft.block.Blocks;
|
||||
import net.minecraft.client.render.RenderLayer;
|
||||
import net.minecraft.client.util.math.MatrixStack;
|
||||
import org.joml.Matrix4f;
|
||||
@@ -30,7 +31,7 @@ import static org.lwjgl.opengl.GL43.*;
|
||||
import static org.lwjgl.opengl.GL43.GL_SHADER_STORAGE_BUFFER;
|
||||
import static org.lwjgl.opengl.GL45C.glClearNamedBufferData;
|
||||
|
||||
public class Gl46FarWorldRenderer extends AbstractFarWorldRenderer {
|
||||
public class Gl46FarWorldRenderer extends AbstractFarWorldRenderer<Gl46Viewport> {
|
||||
private final Shader commandGen = Shader.make()
|
||||
.add(ShaderType.COMPUTE, "voxy:lod/gl46/cmdgen.comp")
|
||||
.compile();
|
||||
@@ -49,15 +50,12 @@ public class Gl46FarWorldRenderer extends AbstractFarWorldRenderer {
|
||||
|
||||
private final GlBuffer glCommandBuffer;
|
||||
private final GlBuffer glCommandCountBuffer;
|
||||
private final GlBuffer glVisibilityBuffer;
|
||||
|
||||
public Gl46FarWorldRenderer(int geometryBuffer, int maxSections) {
|
||||
super(geometryBuffer, maxSections);
|
||||
this.glCommandBuffer = new GlBuffer(maxSections*5L*4 * 6);
|
||||
this.glCommandCountBuffer = new GlBuffer(4*2);
|
||||
this.glVisibilityBuffer = new GlBuffer(maxSections*4L);
|
||||
glClearNamedBufferData(this.glCommandBuffer.id, GL_R8UI, GL_RED_INTEGER, GL_UNSIGNED_BYTE, new int[1]);
|
||||
glClearNamedBufferData(this.glVisibilityBuffer.id, GL_R8UI, GL_RED_INTEGER, GL_UNSIGNED_BYTE, new int[1]);
|
||||
setupVao();
|
||||
}
|
||||
|
||||
@@ -72,7 +70,6 @@ public class Gl46FarWorldRenderer extends AbstractFarWorldRenderer {
|
||||
glBindBufferBase(GL_SHADER_STORAGE_BUFFER, 2, this.glCommandBuffer.id);
|
||||
glBindBufferBase(GL_SHADER_STORAGE_BUFFER, 3, this.glCommandCountBuffer.id);
|
||||
glBindBufferBase(GL_SHADER_STORAGE_BUFFER, 4, this.geometry.metaId());
|
||||
glBindBufferBase(GL_SHADER_STORAGE_BUFFER, 5, this.glVisibilityBuffer.id);
|
||||
glBindBufferBase(GL_SHADER_STORAGE_BUFFER, 6, this.models.getBufferId());
|
||||
glBindBufferBase(GL_SHADER_STORAGE_BUFFER, 7, this.models.getColourBufferId());
|
||||
glBindBufferBase(GL_SHADER_STORAGE_BUFFER, 8, this.lightDataBuffer.id);//Lighting LUT
|
||||
@@ -85,12 +82,11 @@ public class Gl46FarWorldRenderer extends AbstractFarWorldRenderer {
|
||||
// would be visible in the current viewport (if there are 2 viewports)
|
||||
|
||||
//To fix the issue, need to make a viewport api, that independently tracks the frameId and has its own glVisibilityBuffer buffer
|
||||
private int frameId;
|
||||
private void updateUniformBuffer(Matrix4f projection, MatrixStack stack, double cx, double cy, double cz) {
|
||||
private void updateUniformBuffer(Gl46Viewport viewport) {
|
||||
long ptr = UploadStream.INSTANCE.upload(this.uniformBuffer, 0, this.uniformBuffer.size());
|
||||
|
||||
var mat = new Matrix4f(projection).mul(stack.peek().getPositionMatrix());
|
||||
var innerTranslation = new Vector3f((float) (cx-(this.sx<<5)), (float) (cy-(this.sy<<5)), (float) (cz-(this.sz<<5)));
|
||||
var mat = new Matrix4f(viewport.projection).mul(viewport.modelView);
|
||||
var innerTranslation = new Vector3f((float) (viewport.cameraX-(this.sx<<5)), (float) (viewport.cameraY-(this.sy<<5)), (float) (viewport.cameraZ-(this.sz<<5)));
|
||||
mat.translate(-innerTranslation.x, -innerTranslation.y, -innerTranslation.z);
|
||||
mat.getToAddress(ptr); ptr += 4*4*4;
|
||||
MemoryUtil.memPutInt(ptr, this.sx); ptr += 4;
|
||||
@@ -102,10 +98,10 @@ public class Gl46FarWorldRenderer extends AbstractFarWorldRenderer {
|
||||
plane.getToAddress(ptr); ptr += 4*4;
|
||||
}
|
||||
innerTranslation.getToAddress(ptr); ptr += 4*3;
|
||||
MemoryUtil.memPutInt(ptr, this.frameId++); ptr += 4;
|
||||
MemoryUtil.memPutInt(ptr, viewport.frameId++); ptr += 4;
|
||||
}
|
||||
|
||||
public void renderFarAwayOpaque(Matrix4f projection, MatrixStack stack, double cx, double cy, double cz) {
|
||||
public void renderFarAwayOpaque(Gl46Viewport viewport) {
|
||||
if (this.geometry.getSectionCount() == 0) {
|
||||
return;
|
||||
}
|
||||
@@ -123,11 +119,12 @@ public class Gl46FarWorldRenderer extends AbstractFarWorldRenderer {
|
||||
//RenderSystem.enableBlend();
|
||||
//RenderSystem.defaultBlendFunc();
|
||||
|
||||
this.updateUniformBuffer(projection, stack, cx, cy, cz);
|
||||
this.updateUniformBuffer(viewport);
|
||||
|
||||
UploadStream.INSTANCE.commit();
|
||||
|
||||
glBindVertexArray(this.vao);
|
||||
glBindBufferBase(GL_SHADER_STORAGE_BUFFER, 5, viewport.visibilityBuffer.id);
|
||||
|
||||
|
||||
//Bind the texture atlas
|
||||
@@ -215,6 +212,10 @@ public class Gl46FarWorldRenderer extends AbstractFarWorldRenderer {
|
||||
RenderLayer.getTranslucent().endDrawing();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Gl46Viewport createViewport() {
|
||||
return new Gl46Viewport(this.maxSections);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void shutdown() {
|
||||
@@ -223,7 +224,6 @@ public class Gl46FarWorldRenderer extends AbstractFarWorldRenderer {
|
||||
this.lodShader.free();
|
||||
this.cullShader.free();
|
||||
this.glCommandBuffer.free();
|
||||
this.glVisibilityBuffer.free();
|
||||
this.glCommandCountBuffer.free();
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,55 @@
|
||||
package me.cortex.voxy.client.core.rendering;
|
||||
|
||||
import me.cortex.voxy.client.core.gl.GlBuffer;
|
||||
import me.cortex.voxy.client.core.gl.shader.Shader;
|
||||
import me.cortex.voxy.client.core.gl.shader.ShaderType;
|
||||
import me.cortex.voxy.client.core.rendering.util.UploadStream;
|
||||
import me.cortex.voxy.client.mixin.joml.AccessFrustumIntersection;
|
||||
import net.minecraft.client.render.RenderLayer;
|
||||
import net.minecraft.client.util.math.MatrixStack;
|
||||
import org.joml.Matrix4f;
|
||||
import org.joml.Vector3f;
|
||||
import org.lwjgl.opengl.GL11C;
|
||||
import org.lwjgl.system.MemoryUtil;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import static org.lwjgl.opengl.ARBIndirectParameters.GL_PARAMETER_BUFFER_ARB;
|
||||
import static org.lwjgl.opengl.ARBIndirectParameters.glMultiDrawElementsIndirectCountARB;
|
||||
import static org.lwjgl.opengl.GL11.*;
|
||||
import static org.lwjgl.opengl.GL14C.glBlendFuncSeparate;
|
||||
import static org.lwjgl.opengl.GL30.glBindVertexArray;
|
||||
import static org.lwjgl.opengl.GL30C.GL_R8UI;
|
||||
import static org.lwjgl.opengl.GL30C.GL_RED_INTEGER;
|
||||
import static org.lwjgl.opengl.GL40C.GL_DRAW_INDIRECT_BUFFER;
|
||||
import static org.lwjgl.opengl.GL42.GL_BLEND;
|
||||
import static org.lwjgl.opengl.GL42.GL_CULL_FACE;
|
||||
import static org.lwjgl.opengl.GL42.GL_DEPTH_TEST;
|
||||
import static org.lwjgl.opengl.GL42.GL_ONE;
|
||||
import static org.lwjgl.opengl.GL42.GL_ONE_MINUS_SRC_ALPHA;
|
||||
import static org.lwjgl.opengl.GL42.GL_SRC_ALPHA;
|
||||
import static org.lwjgl.opengl.GL42.GL_TEXTURE_2D;
|
||||
import static org.lwjgl.opengl.GL42.GL_TEXTURE_BINDING_2D;
|
||||
import static org.lwjgl.opengl.GL42.GL_UNSIGNED_BYTE;
|
||||
import static org.lwjgl.opengl.GL42.GL_UNSIGNED_INT;
|
||||
import static org.lwjgl.opengl.GL42.glBindTexture;
|
||||
import static org.lwjgl.opengl.GL42.glColorMask;
|
||||
import static org.lwjgl.opengl.GL42.glDepthMask;
|
||||
import static org.lwjgl.opengl.GL42.glDisable;
|
||||
import static org.lwjgl.opengl.GL42.glEnable;
|
||||
import static org.lwjgl.opengl.GL42.*;
|
||||
import static org.lwjgl.opengl.GL43.*;
|
||||
import static org.lwjgl.opengl.GL45C.glClearNamedBufferData;
|
||||
|
||||
public class Gl46Viewport extends Viewport {
|
||||
GlBuffer visibilityBuffer;
|
||||
public Gl46Viewport(int maxSections) {
|
||||
this.visibilityBuffer = new GlBuffer(maxSections*4L);
|
||||
glClearNamedBufferData(this.visibilityBuffer.id, GL_R8UI, GL_RED_INTEGER, GL_UNSIGNED_BYTE, new int[1]);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void delete() {
|
||||
this.visibilityBuffer.free();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,31 @@
|
||||
package me.cortex.voxy.client.core.rendering;
|
||||
|
||||
import org.joml.Matrix4f;
|
||||
|
||||
public abstract class Viewport {
|
||||
int frameId;
|
||||
Matrix4f projection;
|
||||
Matrix4f modelView;
|
||||
double cameraX;
|
||||
double cameraY;
|
||||
double cameraZ;
|
||||
|
||||
public abstract void delete();
|
||||
|
||||
public Viewport setProjection(Matrix4f projection) {
|
||||
this.projection = projection;
|
||||
return this;
|
||||
}
|
||||
|
||||
public Viewport setModelView(Matrix4f modelView) {
|
||||
this.modelView = modelView;
|
||||
return this;
|
||||
}
|
||||
|
||||
public Viewport setCamera(double x, double y, double z) {
|
||||
this.cameraX = x;
|
||||
this.cameraY = y;
|
||||
this.cameraZ = z;
|
||||
return this;
|
||||
}
|
||||
}
|
||||
@@ -256,7 +256,7 @@ public class RenderDataFactory {
|
||||
}
|
||||
|
||||
//if the model has a fluid state but is not a liquid need to see if the solid state had a face rendered and that face is occluding, if so, dont render the fluid state face
|
||||
if (ModelManager.faceOccludes(metadata, face)) {
|
||||
if ((!ModelManager.isFluid(metadata)) && ModelManager.faceOccludes(metadata, face)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
@@ -1,14 +0,0 @@
|
||||
package me.cortex.voxy.client.mixin.minecraft;
|
||||
|
||||
import net.minecraft.client.render.BackgroundRenderer;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
import org.spongepowered.asm.mixin.injection.Constant;
|
||||
import org.spongepowered.asm.mixin.injection.ModifyConstant;
|
||||
|
||||
@Mixin(BackgroundRenderer.class)
|
||||
public class MixinBackgroundRenderer {
|
||||
@ModifyConstant(method = "applyFog", constant = @Constant(floatValue = 192.0F), require = 0)
|
||||
private static float changeFog(float fog) {
|
||||
return 9999999f;
|
||||
}
|
||||
}
|
||||
@@ -19,10 +19,6 @@ import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
|
||||
|
||||
@Mixin(WorldRenderer.class)
|
||||
public abstract class MixinWorldRenderer implements IGetVoxelCore {
|
||||
@Shadow protected abstract void renderLayer(RenderLayer renderLayer, MatrixStack matrices, double cameraX, double cameraY, double cameraZ, Matrix4f positionMatrix);
|
||||
|
||||
@Shadow protected abstract void setupTerrain(Camera camera, Frustum frustum, boolean hasForcedFrustum, boolean spectator);
|
||||
|
||||
@Shadow private Frustum frustum;
|
||||
|
||||
@Shadow private @Nullable ClientWorld world;
|
||||
@@ -103,15 +99,4 @@ public abstract class MixinWorldRenderer implements IGetVoxelCore {
|
||||
this.core = null;
|
||||
}
|
||||
}
|
||||
|
||||
@Redirect(method = "render", at = @At(value = "INVOKE", target = "Ljava/lang/Math;max(FF)F"), require = 0)
|
||||
private float redirectMax(float a, float b) {
|
||||
return a;
|
||||
}
|
||||
|
||||
@Redirect(method = "render", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/render/GameRenderer;getViewDistance()F"), require = 0)
|
||||
private float changeRD(GameRenderer instance) {
|
||||
float viewDistance = instance.getViewDistance();
|
||||
return 16*5120;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,79 @@
|
||||
package me.cortex.voxy.common.world.other;
|
||||
|
||||
import ca.spottedleaf.starlight.common.light.StarLightEngine;
|
||||
import ca.spottedleaf.starlight.common.light.StarLightInterface;
|
||||
import ca.spottedleaf.starlight.common.light.StarLightLightingProvider;
|
||||
import it.unimi.dsi.fastutil.Pair;
|
||||
import net.fabricmc.loader.api.FabricLoader;
|
||||
import net.minecraft.client.MinecraftClient;
|
||||
import net.minecraft.util.math.ChunkPos;
|
||||
import net.minecraft.util.math.ChunkSectionPos;
|
||||
import net.minecraft.world.LightType;
|
||||
import net.minecraft.world.chunk.ChunkNibbleArray;
|
||||
import net.minecraft.world.chunk.WorldChunk;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
public class LightingFetcher {
|
||||
//TODO: FIXME: I dont think the 2 codepaths are needed, just do what you do for starlight for vanilla and it should work just fine
|
||||
|
||||
private static boolean STARLIGHT_INSTALLED = FabricLoader.getInstance().isModLoaded("starlight");
|
||||
private static void fetchLightingDataVanilla(Map<Long, Pair<ChunkNibbleArray, ChunkNibbleArray>> out, WorldChunk chunk) {
|
||||
var lp = chunk.getWorld().getLightingProvider();
|
||||
var blockLight = lp.get(LightType.BLOCK);
|
||||
var skyLight = lp.get(LightType.SKY);
|
||||
int i = chunk.getBottomSectionCoord() - 1;
|
||||
for (var section : chunk.getSectionArray()) {
|
||||
i++;
|
||||
if (section == null) continue;
|
||||
if (section.isEmpty()) continue;
|
||||
var pos = ChunkSectionPos.from(chunk.getPos(), i);
|
||||
if (blockLight.getLightSection(pos).isUninitialized())
|
||||
continue;
|
||||
var bl = blockLight.getLightSection(pos);
|
||||
var sl = skyLight.getLightSection(pos);
|
||||
if (bl == null && sl == null) continue;
|
||||
bl = bl==null?null:bl.copy();
|
||||
sl = sl==null?null:sl.copy();
|
||||
out.put(pos.asLong(), Pair.of(bl, sl));
|
||||
}
|
||||
}
|
||||
|
||||
private static void fetchLightingDataStarlight(Map<Long, Pair<ChunkNibbleArray, ChunkNibbleArray>> out, WorldChunk chunk) {
|
||||
var starlight = ((StarLightLightingProvider)chunk.getWorld().getLightingProvider());
|
||||
var blp = starlight.getLightEngine().getBlockReader();
|
||||
var slp = starlight.getLightEngine().getSkyReader();
|
||||
|
||||
int i = chunk.getBottomSectionCoord() - 1;
|
||||
for (var section : chunk.getSectionArray()) {
|
||||
i++;
|
||||
if (section == null) continue;
|
||||
if (section.isEmpty()) continue;
|
||||
var pos = ChunkSectionPos.from(chunk.getPos(), i);
|
||||
var bl = blp.getLightSection(pos);
|
||||
if (!(bl == null || bl.isUninitialized())) {
|
||||
bl = bl.copy();
|
||||
} else {
|
||||
bl = null;
|
||||
}
|
||||
var sl = slp.getLightSection(pos);
|
||||
if (!(sl == null || sl.isUninitialized())) {
|
||||
sl = sl.copy();
|
||||
} else {
|
||||
sl = null;
|
||||
}
|
||||
if (bl == null && sl == null) {
|
||||
continue;
|
||||
}
|
||||
out.put(pos.asLong(), Pair.of(bl, sl));
|
||||
}
|
||||
}
|
||||
|
||||
public static void fetchLightingData(Map<Long, Pair<ChunkNibbleArray, ChunkNibbleArray>> out, WorldChunk chunk) {
|
||||
if (STARLIGHT_INSTALLED) {
|
||||
fetchLightingDataStarlight(out, chunk);
|
||||
} else {
|
||||
fetchLightingDataVanilla(out, chunk);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -4,6 +4,7 @@ import it.unimi.dsi.fastutil.Pair;
|
||||
import me.cortex.voxy.common.voxelization.VoxelizedSection;
|
||||
import me.cortex.voxy.common.voxelization.WorldConversionFactory;
|
||||
import me.cortex.voxy.common.world.WorldEngine;
|
||||
import me.cortex.voxy.common.world.other.LightingFetcher;
|
||||
import net.minecraft.util.math.ChunkSectionPos;
|
||||
import net.minecraft.world.LightType;
|
||||
import net.minecraft.world.chunk.ChunkNibbleArray;
|
||||
@@ -79,24 +80,7 @@ public class VoxelIngestService {
|
||||
}
|
||||
|
||||
public void enqueueIngest(WorldChunk chunk) {
|
||||
var lp = chunk.getWorld().getLightingProvider();
|
||||
var blockLight = lp.get(LightType.BLOCK);
|
||||
var skyLight = lp.get(LightType.SKY);
|
||||
int i = chunk.getBottomSectionCoord() - 1;
|
||||
for (var section : chunk.getSectionArray()) {
|
||||
i++;
|
||||
if (section == null) continue;
|
||||
if (section.isEmpty()) continue;
|
||||
var pos = ChunkSectionPos.from(chunk.getPos(), i);
|
||||
if (lp.getStatus(LightType.BLOCK, pos) == LightStorage.Status.EMPTY)
|
||||
continue;
|
||||
var bl = blockLight.getLightSection(pos);
|
||||
var sl = skyLight.getLightSection(pos);
|
||||
if (bl == null && sl == null) continue;
|
||||
bl = bl==null?null:bl.copy();
|
||||
sl = sl==null?null:sl.copy();
|
||||
this.captureLightMap.put(pos.asLong(), Pair.of(bl, sl));
|
||||
}
|
||||
LightingFetcher.fetchLightingData(this.captureLightMap, chunk);
|
||||
this.ingestQueue.add(chunk);
|
||||
this.ingestCounter.release();
|
||||
}
|
||||
|
||||
@@ -15,6 +15,8 @@
|
||||
"voxy.config.general.geometryBuffer.tooltip": "How many quads the geometry buffer can hold",
|
||||
"voxy.config.general.maxSections": "Max Sections",
|
||||
"voxy.config.general.maxSections.tooltip": "The max number of sections the renderer can contain",
|
||||
"voxy.config.general.renderDistance": "Render Distance",
|
||||
"voxy.config.general.renderDistance.tooltip": "The render distance in chunks",
|
||||
|
||||
"voxy.config.threads.ingest": "Ingest",
|
||||
"voxy.config.threads.ingest.tooltip": "How many threads voxy will use for ingesting new chunks",
|
||||
|
||||
@@ -4,7 +4,6 @@
|
||||
"compatibilityLevel": "JAVA_17",
|
||||
"client": [
|
||||
"joml.AccessFrustumIntersection",
|
||||
"minecraft.MixinBackgroundRenderer",
|
||||
"minecraft.MixinClientChunkManager",
|
||||
"minecraft.MixinDebugHud",
|
||||
"minecraft.MixinMinecraftClient",
|
||||
|
||||
Reference in New Issue
Block a user