Water flow texture
This commit is contained in:
@@ -560,6 +560,16 @@ function fill_liquid_cells(chunks: (Uint32Array | null)[], nid: number, index: n
|
||||
return liquid_cells;
|
||||
}
|
||||
|
||||
// for a liquid with a flowing texture of its own, how much of it a block shows: as many pixels across as the still one,
|
||||
// so minecraft's 32×32 flowing water next to its 16×16 still water shows half. see liquid_quads
|
||||
function flowing_scale(block: BlockRegistry): number | undefined {
|
||||
const textures = liquid_textures(block.textures);
|
||||
if (textures.flowing === textures.still) return undefined;
|
||||
const still = textures_info[textures.still] ?? textures_info["engine:missing"];
|
||||
const flowing = textures_info[textures.flowing] ?? textures_info["engine:missing"];
|
||||
return Math.min(1, still.width / flowing.width);
|
||||
}
|
||||
|
||||
// a liquid's quad for the mesher, see liquid_mesh.ts. it's lit like a full block's face on that side
|
||||
function liquid_mesh_quad(
|
||||
block: BlockRegistry,
|
||||
@@ -673,6 +683,7 @@ function make_chunk_mesh(chunk_x: number, chunk_z: number, chunks: (Uint32Array
|
||||
cells,
|
||||
{ same: above === block_nid, solid: hides_liquid(above) },
|
||||
{ same: below === block_nid, solid: hides_liquid(below) },
|
||||
flowing_scale(block_info),
|
||||
);
|
||||
for (const { face, positions, uvs, still } of quads) {
|
||||
const quad = liquid_mesh_quad(block_info, face, positions, uvs, still);
|
||||
|
||||
Reference in New Issue
Block a user