Fk enhanced forloop bullshit
This commit is contained in:
@@ -2,12 +2,20 @@ package me.cortex.voxy.client.core.model;
|
||||
|
||||
|
||||
import it.unimi.dsi.fastutil.ints.IntLinkedOpenHashSet;
|
||||
import me.cortex.voxy.client.core.gl.GlFramebuffer;
|
||||
import me.cortex.voxy.client.core.rendering.util.RawDownloadStream;
|
||||
import me.cortex.voxy.common.world.other.Mapper;
|
||||
import org.lwjgl.opengl.GL11;
|
||||
|
||||
import java.lang.invoke.VarHandle;
|
||||
import java.util.List;
|
||||
|
||||
import static org.lwjgl.opengl.ARBFramebufferObject.GL_COLOR_ATTACHMENT0;
|
||||
import static org.lwjgl.opengl.GL11.GL_COLOR_BUFFER_BIT;
|
||||
import static org.lwjgl.opengl.GL11C.GL_NEAREST;
|
||||
import static org.lwjgl.opengl.GL30C.GL_DRAW_FRAMEBUFFER_BINDING;
|
||||
import static org.lwjgl.opengl.GL45.glBlitNamedFramebuffer;
|
||||
|
||||
public class ModelBakerySubsystem {
|
||||
//Redo to just make it request the block faces with the async texture download stream which
|
||||
// basicly solves all the render stutter due to the baking
|
||||
@@ -18,9 +26,11 @@ public class ModelBakerySubsystem {
|
||||
public final ModelFactory factory;
|
||||
private final IntLinkedOpenHashSet blockIdQueue = new IntLinkedOpenHashSet();
|
||||
|
||||
private static final GlFramebuffer TMP = new GlFramebuffer();
|
||||
|
||||
public ModelBakerySubsystem(Mapper mapper) {
|
||||
this.factory = new ModelFactory(mapper, this.storage, this.textureDownStream);
|
||||
TMP.bind(GL_COLOR_ATTACHMENT0, this.storage.textures).verify();
|
||||
}
|
||||
|
||||
public void tick() {
|
||||
@@ -47,6 +57,10 @@ public class ModelBakerySubsystem {
|
||||
|
||||
//Tick the download stream
|
||||
this.textureDownStream.tick();
|
||||
|
||||
|
||||
//Debug blit texture
|
||||
glBlitNamedFramebuffer(TMP.id, GL11.glGetInteger(GL_DRAW_FRAMEBUFFER_BINDING),0,0,256*3*16,256*2*16, 0,0, 256*3*16,256*2*16, GL_COLOR_BUFFER_BIT, GL_NEAREST);
|
||||
}
|
||||
|
||||
public void shutdown() {
|
||||
|
||||
@@ -188,8 +188,8 @@ public class ModelFactory {
|
||||
//Copy out colour
|
||||
for (int i = 0; i < FACE_SIZE; i++) {
|
||||
//De-interpolate results
|
||||
colour[i] = MemoryUtil.memGetInt(faceDataPtr+ (i*4));
|
||||
depth[i] = MemoryUtil.memGetInt(faceDataPtr+ (i*4)+4);
|
||||
colour[i] = MemoryUtil.memGetInt(faceDataPtr+ (i*4*2));
|
||||
depth[i] = MemoryUtil.memGetInt(faceDataPtr+ (i*4*2)+4);
|
||||
}
|
||||
|
||||
textureData[face] = new ColourDepthTextureData(colour, depth, MODEL_TEXTURE_SIZE, MODEL_TEXTURE_SIZE);
|
||||
|
||||
@@ -120,7 +120,11 @@ public class RenderDataFactory {
|
||||
//Ordering is: translucent, double sided quads, directional quads
|
||||
offsets[0] = meshlet;
|
||||
int mix = 32, miy = 32, miz = 32, max = 0, may = 0, maz = 0;
|
||||
for (long data : this.translucentQuadCollector) {
|
||||
|
||||
final int TSIZE = this.translucentQuadCollector.size();
|
||||
LongArrayList arrayList = this.translucentQuadCollector;
|
||||
for (int i = 0; i < TSIZE; i++) {
|
||||
long data = arrayList.getLong(i);
|
||||
if (innerQuadCount == 0) {
|
||||
//Write out meshlet header
|
||||
|
||||
@@ -171,7 +175,11 @@ public class RenderDataFactory {
|
||||
}
|
||||
|
||||
offsets[1] = meshlet;
|
||||
for (long data : this.doubleSidedQuadCollector) {
|
||||
|
||||
final int DSIZE = this.doubleSidedQuadCollector.size();
|
||||
arrayList = this.doubleSidedQuadCollector;
|
||||
for (int i = 0; i < DSIZE; i++) {
|
||||
long data = arrayList.getLong(i);
|
||||
if (innerQuadCount == 0) {
|
||||
//Write out meshlet header
|
||||
|
||||
@@ -221,7 +229,10 @@ public class RenderDataFactory {
|
||||
|
||||
for (int face = 0; face < 6; face++) {
|
||||
offsets[face + 2] = meshlet;
|
||||
for (long data : this.directionalQuadCollectors[face]) {
|
||||
final var faceArray = this.directionalQuadCollectors[face];
|
||||
final int FSIZE = faceArray.size();
|
||||
for (int i = 0; i < FSIZE; i++) {
|
||||
long data = faceArray.getLong(i);
|
||||
if (innerQuadCount == 0) {
|
||||
//Write out meshlet header
|
||||
|
||||
@@ -276,18 +287,27 @@ public class RenderDataFactory {
|
||||
|
||||
//Ordering is: translucent, double sided quads, directional quads
|
||||
offsets[0] = coff;
|
||||
for (long data : this.translucentQuadCollector) {
|
||||
int size = this.translucentQuadCollector.size();
|
||||
LongArrayList arrayList = this.translucentQuadCollector;
|
||||
for (int i = 0; i < size; i++) {
|
||||
long data = arrayList.getLong(i);
|
||||
MemoryUtil.memPutLong(ptr + ((coff++) * 8L), data);
|
||||
}
|
||||
|
||||
offsets[1] = coff;
|
||||
for (long data : this.doubleSidedQuadCollector) {
|
||||
size = this.doubleSidedQuadCollector.size();
|
||||
arrayList = this.doubleSidedQuadCollector;
|
||||
for (int i = 0; i < size; i++) {
|
||||
long data = arrayList.getLong(i);
|
||||
MemoryUtil.memPutLong(ptr + ((coff++) * 8L), data);
|
||||
}
|
||||
|
||||
for (int face = 0; face < 6; face++) {
|
||||
offsets[face + 2] = coff;
|
||||
for (long data : this.directionalQuadCollectors[face]) {
|
||||
final LongArrayList faceArray = this.directionalQuadCollectors[face];
|
||||
size = faceArray.size();
|
||||
for (int i = 0; i < size; i++) {
|
||||
long data = faceArray.getLong(i);
|
||||
MemoryUtil.memPutLong(ptr + ((coff++) * 8L), data);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -15,7 +15,7 @@ layout(location=4) uniform uint bufferOffset;
|
||||
|
||||
void main() {
|
||||
ivec2 point = ivec2(gl_GlobalInvocationID.xy);
|
||||
uint writeIndex = ((gl_GlobalInvocationID.x+(gl_GlobalInvocationID.y*HEIGHT))*2)+bufferOffset;
|
||||
uint writeIndex = ((gl_GlobalInvocationID.x+(gl_GlobalInvocationID.y*WIDTH))*2)+bufferOffset;
|
||||
uvec4 colour = clamp(uvec4(texelFetch(colourTexIn, point, 0)*255), uvec4(0), uvec4(255));//TODO: check that this actually gets to the range of 255
|
||||
colour <<= uvec4(0,8,16,24);//ABGR format!!!
|
||||
outBuffer[writeIndex] = colour.r|colour.g|colour.b|colour.a;
|
||||
|
||||
Reference in New Issue
Block a user