Fix lighting
This commit is contained in:
@@ -6,13 +6,23 @@ import net.minecraft.client.MinecraftClient;
|
||||
import org.lwjgl.system.MemoryUtil;
|
||||
|
||||
import static org.lwjgl.opengl.ARBUniformBufferObject.glBindBufferBase;
|
||||
import static org.lwjgl.opengl.GL11.glBindTexture;
|
||||
import static org.lwjgl.opengl.GL33.glBindSampler;
|
||||
import static org.lwjgl.opengl.GL33.glGenSamplers;
|
||||
import static org.lwjgl.opengl.GL43.GL_SHADER_STORAGE_BUFFER;
|
||||
import static org.lwjgl.opengl.GL45.glBindTextureUnit;
|
||||
|
||||
public class LightMapHelper {
|
||||
private static final int SAMPLER = glGenSamplers();
|
||||
|
||||
static {
|
||||
//SAMPLER
|
||||
}
|
||||
/*
|
||||
private static final GlBuffer LIGHT_MAP_BUFFER = new GlBuffer(256*4);
|
||||
public static void tickLightmap() {
|
||||
long upload = UploadStream.INSTANCE.upload(LIGHT_MAP_BUFFER, 0, 256*4);
|
||||
var lmt = MinecraftClient.getInstance().gameRenderer.getLightmapTextureManager().texture.getImage();
|
||||
var lmt = MinecraftClient.getInstance().gameRenderer.getLightmapTextureManager().lightmapFramebuffer.getImage();
|
||||
for (int light = 0; light < 256; light++) {
|
||||
int x = light&0xF;
|
||||
int y = ((light>>4)&0xF);
|
||||
@@ -20,10 +30,12 @@ public class LightMapHelper {
|
||||
sample = ((sample&0xFF0000)>>16)|(sample&0xFF00)|((sample&0xFF)<<16);
|
||||
MemoryUtil.memPutInt(upload + (((x<<4)|(y))*4), sample|(0xFF<<28));
|
||||
}
|
||||
}
|
||||
//TODO: CRITICAL FIXME
|
||||
}*/
|
||||
|
||||
public static void bind(int lightingBufferIndex) {
|
||||
glBindBufferBase(GL_SHADER_STORAGE_BUFFER, lightingBufferIndex, LIGHT_MAP_BUFFER.id);
|
||||
public static void bind(int lightingIndex) {
|
||||
//glBindBufferBase(GL_SHADER_STORAGE_BUFFER, lightingBufferIndex, LIGHT_MAP_BUFFER.id);
|
||||
//glBindSampler(lightingIndex, SAMPLER);
|
||||
glBindTextureUnit(lightingIndex, MinecraftClient.getInstance().gameRenderer.getLightmapTextureManager().lightmapFramebuffer.getColorAttachment());
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
@@ -89,7 +89,7 @@ public class MDICSectionRenderer extends AbstractSectionRenderer<MDICViewport, B
|
||||
glBindBufferBase(GL_SHADER_STORAGE_BUFFER, 1, this.geometryManager.getGeometryBufferId());
|
||||
glBindBufferBase(GL_SHADER_STORAGE_BUFFER, 2, this.geometryManager.getMetadataBufferId());
|
||||
this.modelStore.bind(3, 4, 0);
|
||||
LightMapHelper.bind(5);
|
||||
LightMapHelper.bind(1);
|
||||
|
||||
glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, SharedIndexBuffer.INSTANCE.id());
|
||||
glBindBuffer(GL_DRAW_INDIRECT_BUFFER, this.drawCallBuffer.id);
|
||||
@@ -99,7 +99,7 @@ public class MDICSectionRenderer extends AbstractSectionRenderer<MDICViewport, B
|
||||
|
||||
|
||||
private void renderTerrain() {
|
||||
RenderLayer.getCutoutMipped().startDrawing();
|
||||
//RenderLayer.getCutoutMipped().startDrawing();
|
||||
|
||||
glDisable(GL_CULL_FACE);
|
||||
glEnable(GL_DEPTH_TEST);
|
||||
@@ -113,7 +113,10 @@ public class MDICSectionRenderer extends AbstractSectionRenderer<MDICViewport, B
|
||||
glBindVertexArray(0);
|
||||
glBindSampler(0, 0);
|
||||
glBindTextureUnit(0, 0);
|
||||
RenderLayer.getCutoutMipped().endDrawing();
|
||||
glBindSampler(1, 0);
|
||||
glBindTextureUnit(1, 0);
|
||||
|
||||
//RenderLayer.getCutoutMipped().endDrawing();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -103,16 +103,13 @@ layout(binding = MODEL_COLOUR_BUFFER_BINDING, std430) readonly restrict buffer M
|
||||
};
|
||||
#endif
|
||||
|
||||
#ifdef LIGHTING_BUFFER_BINDING
|
||||
layout(binding = LIGHTING_BUFFER_BINDING, std430) readonly restrict buffer LightingBuffer {
|
||||
uint lightData[];
|
||||
};
|
||||
#ifdef LIGHTING_SAMPLER_BINDING
|
||||
|
||||
layout(binding = LIGHTING_SAMPLER_BINDING) uniform sampler2D lightSampler;
|
||||
|
||||
vec4 getLighting(uint index) {
|
||||
uvec4 arr = uvec4(lightData[index]);
|
||||
arr = arr>>uvec4(16,8,0,24);
|
||||
arr = arr & uvec4(0xFF);
|
||||
return vec4(arr)*vec4(1.0f/255.0f);
|
||||
int i2 = int(index);
|
||||
return texture(lightSampler, vec2((i2>>4)&0xF, i2&0xF)/16.0f);
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
#define SECTION_METADATA_BUFFER_BINDING 2
|
||||
#define MODEL_BUFFER_BINDING 3
|
||||
#define MODEL_COLOUR_BUFFER_BINDING 4
|
||||
#define LIGHTING_BUFFER_BINDING 5
|
||||
#define LIGHTING_SAMPLER_BINDING 1
|
||||
|
||||
|
||||
#import <voxy:lod/quad_format.glsl>
|
||||
|
||||
Reference in New Issue
Block a user