Fix issues with mesa stencil, added self culling option,
This commit is contained in:
@@ -2,6 +2,7 @@ package me.cortex.voxy.client.core;
|
||||
|
||||
import me.cortex.voxy.client.RenderStatistics;
|
||||
import me.cortex.voxy.client.TimingStatistics;
|
||||
import me.cortex.voxy.client.core.gl.Capabilities;
|
||||
import me.cortex.voxy.client.core.model.ModelBakerySubsystem;
|
||||
import me.cortex.voxy.client.core.rendering.Viewport;
|
||||
import me.cortex.voxy.client.core.rendering.hierachical.AsyncNodeManager;
|
||||
@@ -93,13 +94,16 @@ public abstract class AbstractRenderPipeline extends TrackedObject {
|
||||
}
|
||||
|
||||
protected void initDepthStencil(int sourceFrameBuffer, int targetFb, int width, int height) {
|
||||
|
||||
glClearNamedFramebufferfi(targetFb, GL_DEPTH_STENCIL, 0, 1.0f, 1);
|
||||
glBlitNamedFramebuffer(sourceFrameBuffer, targetFb, 0,0, width, height, 0,0, width, height, GL_DEPTH_BUFFER_BIT, GL_NEAREST);
|
||||
|
||||
glBindFramebuffer(GL30.GL_FRAMEBUFFER, targetFb);
|
||||
//GL11C.glClearStencil(1);
|
||||
//GL11C.glClear(GL_STENCIL_BUFFER_BIT);
|
||||
|
||||
/*
|
||||
if (Capabilities.INSTANCE.isMesa){
|
||||
glClearStencil(1);
|
||||
glClear(GL_STENCIL_BUFFER_BIT);
|
||||
}*/
|
||||
|
||||
//This whole thing is hell, we basicly want to create a mask stenicel/depth mask specificiclly
|
||||
// in theory we could do this in a single pass by passing in the depth buffer from the sourceFrambuffer
|
||||
|
||||
@@ -273,12 +273,6 @@ public class ModelFactory {
|
||||
|
||||
int checkMode = blockRenderLayer==BlockRenderLayer.SOLID?TextureUtils.WRITE_CHECK_STENCIL:TextureUtils.WRITE_CHECK_ALPHA;
|
||||
|
||||
if (Capabilities.INSTANCE.isMesa) {
|
||||
//Mesa does not work with GL_DEPTH_STENCIL_TEXTURE_MODE GL_STENCIL_INDEX
|
||||
// the sampler in the compute shader always reads zero even when stencil is guarenteed not to be zero
|
||||
// (e.g. clearing with stencil 10)
|
||||
checkMode = TextureUtils.WRITE_CHECK_ALPHA;
|
||||
}
|
||||
|
||||
var colourProvider = getColourProvider(blockState.getBlock());
|
||||
|
||||
|
||||
@@ -42,6 +42,8 @@ public class GlViewCapture {
|
||||
this.framebuffer = new GlFramebuffer().bind(GL_COLOR_ATTACHMENT0, this.colourTex).bind(GL_DEPTH_STENCIL_ATTACHMENT, this.depthTex).verify().name("ModelFramebuffer");
|
||||
|
||||
glTextureParameteri(this.stencilTex.id, GL_DEPTH_STENCIL_TEXTURE_MODE, GL_STENCIL_INDEX);
|
||||
glTextureParameteri(this.stencilTex.id, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
|
||||
glTextureParameteri(this.stencilTex.id, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
|
||||
|
||||
this.copyOutShader = Shader.makeAuto()
|
||||
.define("WIDTH", width)
|
||||
|
||||
@@ -18,6 +18,7 @@ import java.util.Arrays;
|
||||
|
||||
public class RenderDataFactory {
|
||||
private static final boolean CHECK_NEIGHBOR_FACE_OCCLUSION = true;
|
||||
private static final boolean DISABLE_CULL_SAME_OCCLUDES = true;
|
||||
|
||||
private static final boolean VERIFY_MESHING = VoxyCommon.isVerificationFlagOn("verifyMeshing");
|
||||
|
||||
@@ -340,7 +341,7 @@ public class RenderDataFactory {
|
||||
private static final long LM = (0xFFL<<55);
|
||||
|
||||
private static boolean shouldMeshNonOpaqueBlockFace(int face, long quad, long meta, long neighborQuad, long neighborMeta) {
|
||||
if (((quad^neighborQuad)&(0xFFFFL<<26))==0) return false;//This is a hack, if the neigbor and this are the same, dont mesh the face
|
||||
if (((quad^neighborQuad)&(0xFFFFL<<26))==0 && ((!DISABLE_CULL_SAME_OCCLUDES) || ModelQueries.faceOccludes(meta, face))) return false;//This is a hack, if the neigbor and this are the same, dont mesh the face// TODO: FIXME
|
||||
if (!ModelQueries.faceExists(meta, face)) return false;//Dont mesh if no face
|
||||
//if (ModelQueries.faceCanBeOccluded(meta, face)) //TODO: maybe enable this
|
||||
if (ModelQueries.faceOccludes(neighborMeta, face^1)) return false;
|
||||
@@ -752,7 +753,7 @@ public class RenderDataFactory {
|
||||
//Check and test if can cull W.R.T neighbor
|
||||
if (Mapper.getBlockId(neighborId) != 0) {//Not air
|
||||
int modelId = this.modelMan.getModelId(Mapper.getBlockId(neighborId));
|
||||
if (modelId == ((A>>26)&0xFFFF)) {
|
||||
if (modelId == ((A>>26)&0xFFFF)) {//TODO: FIXME, this technically isnt correct as need to check self occulsion, thinks?
|
||||
fail = true;
|
||||
} else {
|
||||
long meta = this.modelMan.getModelMetadataFromClientId(modelId);
|
||||
@@ -766,7 +767,7 @@ public class RenderDataFactory {
|
||||
long nA = this.sectionData[(idx+skipAmount) * 2];
|
||||
long nB = this.sectionData[(idx+skipAmount) * 2 + 1];
|
||||
boolean failB = false;
|
||||
if ((nA&(0xFFFFL<<26)) == (A&(0xFFFFL<<26))) {
|
||||
if ((nA&(0xFFFFL<<26)) == (A&(0xFFFFL<<26))) {//TODO: FIXME, this technically isnt correct as need to check self occulsion, thinks?
|
||||
failB = true;
|
||||
} else {
|
||||
if (ModelQueries.faceOccludes(nB, (axis << 1) | (side))) {
|
||||
|
||||
Reference in New Issue
Block a user