Water tweaks

This commit is contained in:
2026-10-07 11:43:19 -03:00
parent 40d5a4f5af
commit 8f8030c02e
4 changed files with 63 additions and 4 deletions
+15
View File
@@ -585,6 +585,20 @@ function liquid_mesh_quad(
};
}
// the liquid's surface seen from below, so it shows from under water: the top quad facing down, lit and shaded like
// the top. its corners go the other way round, the lighting the mesher just worked out with them
const UNDERSIDE_CORNERS = [0, 3, 2, 1];
function underside(top: MeshQuad): MeshQuad {
for (const light of [corner_sky, corner_block, corner_ao]) light.set(UNDERSIDE_CORNERS.map((k) => light[k]));
return {
...top,
face: 1,
positions: UNDERSIDE_CORNERS.flatMap((k) => top.positions.slice(k * 3, k * 3 + 3)),
uvs: UNDERSIDE_CORNERS.flatMap((k) => top.uvs.slice(k * 2, k * 2 + 2)),
};
}
// region has to be filled and lit first
// chunks are the 3x3 chunks' blocks with their states, the middle one's for models that change with them and the
// ones around it for liquids, whose surface follows their neighbors'
@@ -666,6 +680,7 @@ function make_chunk_mesh(chunk_x: number, chunk_z: number, chunks: (Uint32Array
// like minecraft's liquids, no ambient occlusion
corner_ao.fill(1);
emit(quad, layer_id, x, y, z, alpha);
if (face === 0) emit(underside(quad), layer_id, x, y, z, alpha);
}
continue;
}