diff --git a/assets/cubyz/shaders/chunks/chunk_vertex.vert b/assets/cubyz/shaders/chunks/chunk_vertex.vert index 7fd2400802..5af5b669ac 100644 --- a/assets/cubyz/shaders/chunks/chunk_vertex.vert +++ b/assets/cubyz/shaders/chunks/chunk_vertex.vert @@ -62,6 +62,10 @@ layout(std430, binding = 6) buffer _chunks ChunkData chunks[]; }; +vec3 square(vec3 x) { + return x*x; +} + void main() { int faceID = gl_VertexID >> 2; int vertexID = gl_VertexID & 3; @@ -81,7 +85,7 @@ void main() { fullLight >> 5 & 31u, fullLight >> 0 & 31u ); - light = max(sunLight*ambientLight, blockLight)/31; + light = min(sqrt(square(sunLight*ambientLight) + square(blockLight)), vec3(31))/31; isBackFace = encodedPositionAndLightIndex>>15 & 1; textureIndex = textureAndQuad & 65535; diff --git a/assets/cubyz/shaders/entity_vertex.vert b/assets/cubyz/shaders/entity_vertex.vert index 60826fcaec..7db6d1564b 100644 --- a/assets/cubyz/shaders/entity_vertex.vert +++ b/assets/cubyz/shaders/entity_vertex.vert @@ -23,6 +23,10 @@ layout(std430, binding = 11) buffer _quads QuadInfo quads[]; }; +vec3 square(vec3 x) { + return x*x; +} + vec3 calcLight(uint fullLight) { vec3 sunLight = vec3( fullLight >> 25 & 31u, @@ -34,7 +38,7 @@ vec3 calcLight(uint fullLight) { fullLight >> 5 & 31u, fullLight >> 0 & 31u ); - return max(sunLight*ambientLight, blockLight)/31; + return min(sqrt(square(sunLight*ambientLight) + square(blockLight)), vec3(31))/31; } void main() { diff --git a/assets/cubyz/shaders/particles/particles.vert b/assets/cubyz/shaders/particles/particles.vert index bcee51c781..f7e48f1378 100644 --- a/assets/cubyz/shaders/particles/particles.vert +++ b/assets/cubyz/shaders/particles/particles.vert @@ -45,6 +45,10 @@ const vec3 facePositions[4] = vec3[4] vec3(0.5f, 0.5f, 0.0f) ); +vec3 square(vec3 x) { + return x*x; +} + void main() { int particleID = gl_VertexID >> 2; int vertexID = gl_VertexID & 3; @@ -62,7 +66,7 @@ void main() { fullLight >> 5 & 31u, fullLight >> 0 & 31u ); - light = max(sunLight*ambientLight, blockLight)/31; + light = min(sqrt(square(sunLight*ambientLight) + square(blockLight)), vec3(31))/31; float rotation = particle.rotation; vec3 faceVertPos = facePositions[vertexID]; diff --git a/src/itemdrop.zig b/src/itemdrop.zig index 676c2ce4f4..04f2053288 100644 --- a/src/itemdrop.zig +++ b/src/itemdrop.zig @@ -721,10 +721,9 @@ pub const ItemDropRenderer = struct { // MARK: ItemDropRenderer } fn bindLightUniform(light: [6]u8, ambientLight: Vec3f) void { - c.glUniform3fv(itemUniforms.ambientLight, 1, @ptrCast(&@max( - ambientLight*@as(Vec3f, @as(Vec3f, @floatFromInt(Vec3i{light[0], light[1], light[2]}))/@as(Vec3f, @splat(255))), - @as(Vec3f, @floatFromInt(Vec3i{light[3], light[4], light[5]}))/@as(Vec3f, @splat(255)), - ))); + const sunLight: Vec3f = ambientLight*@as(Vec3f, @floatFromInt(Vec3i{light[0], light[1], light[2]}))/@as(Vec3f, @splat(255)); + const blockLight: Vec3f = @as(Vec3f, @floatFromInt(Vec3i{light[3], light[4], light[5]}))/@as(Vec3f, @splat(255)); + c.glUniform3fv(itemUniforms.ambientLight, 1, @ptrCast(&@min(@sqrt(sunLight*sunLight + blockLight*blockLight), @as(Vec3f, @splat(1))))); } fn bindModelUniforms(modelIndex: u31, blockType: u16) void {