Almost all works
This commit is contained in:
@@ -100,7 +100,7 @@ public class VoxelCore {
|
||||
//this.distanceTracker.init(camera.getBlockPos().getX(), camera.getBlockPos().getZ());
|
||||
this.firstTime = false;
|
||||
|
||||
this.renderTracker.addLvl0(0,0,0);
|
||||
this.renderTracker.addLvl0(0,6,0);
|
||||
|
||||
|
||||
}
|
||||
|
||||
@@ -100,9 +100,9 @@ public class ModelManager {
|
||||
//TODO: so need a few things, per face sizes and offsets, the sizes should be computed from the pixels and find the minimum bounding pixel
|
||||
// while the depth is computed from the depth buffer data
|
||||
public int addEntry(int blockId, BlockState blockState) {
|
||||
//if (this.idMappings[blockId] != -1) {
|
||||
// throw new IllegalArgumentException("Trying to add entry for duplicate id");
|
||||
//}
|
||||
if (this.idMappings[blockId] != -1) {
|
||||
throw new IllegalArgumentException("Trying to add entry for duplicate id");
|
||||
}
|
||||
|
||||
int modelId = -1;
|
||||
var textureData = this.bakery.renderFaces(blockState, 123456);
|
||||
@@ -111,7 +111,7 @@ public class ModelManager {
|
||||
if (possibleDuplicate != -1) {//Duplicate found
|
||||
this.idMappings[blockId] = possibleDuplicate;
|
||||
modelId = possibleDuplicate;
|
||||
//return possibleDuplicate;
|
||||
return possibleDuplicate;
|
||||
} else {//Not a duplicate so create a new entry
|
||||
modelId = this.modelTexture2id.size();
|
||||
this.idMappings[blockId] = modelId;
|
||||
@@ -163,6 +163,16 @@ public class ModelManager {
|
||||
//TODO: implement
|
||||
boolean hasBiomeColourResolver = false;
|
||||
|
||||
|
||||
//TODO: THIS, note this can be tested for in 2 ways, re render the model with quad culling disabled and see if the result
|
||||
// is the same, (if yes then needs double sided quads)
|
||||
// another way to test it is if e.g. up and down havent got anything rendered but the sides do (e.g. all plants etc)
|
||||
boolean needsDoubleSidedQuads = false;
|
||||
|
||||
//TODO: special case stuff like vines and glow lichen, where it can be represented by a single double sided quad
|
||||
// since that would help alot with perf of lots of vines
|
||||
|
||||
|
||||
//This also checks if there is a block colour resolver for the given blockstate and marks that the block has a resolver
|
||||
var sizes = this.computeModelDepth(textureData, checkMode);
|
||||
|
||||
@@ -209,10 +219,10 @@ public class ModelManager {
|
||||
|
||||
int faceModelData = 0;
|
||||
faceModelData |= faceSize[0] | (faceSize[1]<<4) | (faceSize[2]<<8) | (faceSize[3]<<12);
|
||||
faceModelData |= Math.round(offset*63);//Change the scale from 0->1 (ends inclusive) float to 0->63 (6 bits) NOTE! that 63 == 1.0f meaning its shifted all the way to the other side of the model
|
||||
faceModelData |= Math.round(offset*63)<<16;//Change the scale from 0->1 (ends inclusive) float to 0->63 (6 bits) NOTE! that 63 == 1.0f meaning its shifted all the way to the other side of the model
|
||||
//Still have 11 bits free
|
||||
|
||||
MemoryUtil.memPutInt(faceUploadPtr, faceModelData);
|
||||
MemoryUtil.memPutInt(faceUploadPtr, 0);
|
||||
}
|
||||
this.metadataCache[modelId] = metadata;
|
||||
|
||||
|
||||
@@ -150,8 +150,8 @@ public class GeometryManager {
|
||||
MemoryUtil.memPutInt(ptr, (int) this.aabb); ptr += 4;
|
||||
ptr += 4;
|
||||
|
||||
MemoryUtil.memPutInt(ptr, this.opaqueGeometryPtr); ptr += 4;
|
||||
MemoryUtil.memPutInt(ptr, this.count); ptr += 4;
|
||||
//MemoryUtil.memPutInt(ptr, this.opaqueQuadCount); ptr += 4;
|
||||
|
||||
//MemoryUtil.memPutInt(ptr, (int) this.translucentGeometryPtr + this.translucentPreDataCount); ptr += 4;
|
||||
//MemoryUtil.memPutInt(ptr, this.translucentQuadCount); ptr += 4;
|
||||
@@ -163,7 +163,7 @@ public class GeometryManager {
|
||||
|
||||
//TODO: support translucent geometry
|
||||
//return new SectionMeta(geometry.position, 0, geometryPtr, (int) (geometry.opaque.buffer().size/8), 0, -1,0, 0);
|
||||
return new SectionMeta(geometry.position, 0, geometryPtr, (int) (geometry.opaque.buffer().size/8), 0);
|
||||
return new SectionMeta(geometry.position, 0, geometryPtr, (int) (geometry.opaque.buffer().size/8), -1);
|
||||
}
|
||||
|
||||
private void freeMeta(SectionMeta meta) {
|
||||
|
||||
@@ -107,12 +107,14 @@ public class Gl46FarWorldRenderer extends AbstractFarWorldRenderer {
|
||||
glMemoryBarrier(GL_COMMAND_BARRIER_BIT | GL_SHADER_STORAGE_BARRIER_BIT | GL_UNIFORM_BARRIER_BIT);
|
||||
|
||||
this.lodShader.bind();
|
||||
glDisable(GL_CULL_FACE);
|
||||
glMultiDrawElementsIndirect(GL_TRIANGLES, GL_UNSIGNED_SHORT, 0, this.geometry.getSectionCount(), 0);
|
||||
glEnable(GL_CULL_FACE);
|
||||
//ARBIndirectParameters.glMultiDrawElementsIndirectCountARB(
|
||||
|
||||
glMemoryBarrier(GL_PIXEL_BUFFER_BARRIER_BIT | GL_FRAMEBUFFER_BARRIER_BIT);
|
||||
|
||||
cullShader.bind();
|
||||
this.cullShader.bind();
|
||||
glColorMask(false, false, false, false);
|
||||
glDepthMask(false);
|
||||
|
||||
|
||||
@@ -34,8 +34,20 @@ public class RenderDataFactory {
|
||||
// this stops e.g. multiple layers of glass (and ocean) from having 3000 layers of quads etc
|
||||
|
||||
var buff = new MemoryBuffer(8*1);
|
||||
//MemoryUtil.memPutLong(buff.address, encodeRaw(1, 0,2,0,0,0,515,0, 0));//92
|
||||
//MemoryUtil.memPutLong(buff.address+8, encodeRaw(2, 1,1,0,0,0,515,0, 0));//92
|
||||
//MemoryUtil.memPutLong(buff.address+16, encodeRaw(3, 0,0,0,0,0,515,0, 0));//92
|
||||
//MemoryUtil.memPutLong(buff.address+24, encodeRaw(4, 0,2,0,0,0,515,0, 0));//92
|
||||
//MemoryUtil.memPutLong(buff.address+32, encodeRaw(5, 0,2,0,0,0,515,0, 0));//92
|
||||
|
||||
MemoryUtil.memPutLong(buff.address, encodeRaw(2, 1,1,0,0,0,515,0, 0));//92
|
||||
//MemoryUtil.memPutLong(buff.address, encodeRaw(3, 0,0,0,0,0,515,0, 0));//92
|
||||
return new BuiltSection(section.getKey(), new BuiltSectionGeometry(buff, new short[0]), null);
|
||||
}
|
||||
|
||||
|
||||
private static long encodeRaw(int face, int width, int height, int x, int y, int z, int blockId, int biomeId, int lightId) {
|
||||
return ((long)face) | (((long) width)<<3) | (((long) height)<<7) | (((long) z)<<11) | (((long) y)<<16) | (((long) x)<<21) | (((long) blockId)<<26) | (((long) biomeId)<<46) | (((long) lightId)<<55);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user