diff --git a/assets/cubyz/shaders/item_drop.fs b/assets/cubyz/shaders/item_drop.fs index fa10879e..22ca45c6 100644 --- a/assets/cubyz/shaders/item_drop.fs +++ b/assets/cubyz/shaders/item_drop.fs @@ -26,6 +26,8 @@ layout(location = 7) uniform float sizeScale; layout(location = 8) uniform float reflectionMapSize; layout(location = 9) uniform float contrast; +layout(location = 10) uniform vec2 glDepthRange; + const float[6] normalVariations = float[6]( 1.0, 0.80, @@ -175,9 +177,7 @@ void mainItemDrop() { vec3 modifiedCameraSpacePos = cameraSpacePos*(1 + total_tMax*sizeScale*length(direction)/length(cameraSpacePos)); vec4 projection = projectionMatrix*vec4(modifiedCameraSpacePos, 1); float depth = projection.z/projection.w; - gl_FragDepth = ((gl_DepthRange.diff * depth) + gl_DepthRange.near + gl_DepthRange.far)/2.0; - - + gl_FragDepth = (((glDepthRange.y - glDepthRange.x) * depth) + glDepthRange.x + glDepthRange.y)/2.0; fragColor = decodeColor(block); fragColor.a = 1; // No transparency supported! diff --git a/src/itemdrop.zig b/src/itemdrop.zig index b7853530..dc354004 100644 --- a/src/itemdrop.zig +++ b/src/itemdrop.zig @@ -553,6 +553,7 @@ pub const ItemDropRenderer = struct { // MARK: ItemDropRenderer block: c_int, reflectionMapSize: c_int, contrast: c_int, + glDepthRange: c_int, } = undefined; var itemModelSSBO: graphics.SSBO = undefined; @@ -682,6 +683,9 @@ pub const ItemDropRenderer = struct { // MARK: ItemDropRenderer c.glUniform3fv(itemUniforms.ambientLight, 1, @ptrCast(&ambientLight)); c.glUniformMatrix4fv(itemUniforms.viewMatrix, 1, c.GL_TRUE, @ptrCast(&viewMatrix)); c.glUniform1f(itemUniforms.contrast, 0.12); + var depthRange: [2]f32 = undefined; + c.glGetFloatv(c.GL_DEPTH_RANGE, &depthRange); + c.glUniform2fv(itemUniforms.glDepthRange, 1, &depthRange); } fn bindLightUniform(light: [6]u8, ambientLight: Vec3f) void {