fixed texture index packing
This commit is contained in:
@@ -76,6 +76,7 @@ pub fn generate_chunk_mesh(
|
|||||||
return mesh;
|
return mesh;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const TEX_MULTI: Vec2 = Vec2::new(1000., 1.);
|
||||||
fn create_tile(
|
fn create_tile(
|
||||||
pos: Vec3,
|
pos: Vec3,
|
||||||
neighbors: &[Option<f32>; 6],
|
neighbors: &[Option<f32>; 6],
|
||||||
@@ -90,13 +91,13 @@ fn create_tile(
|
|||||||
let side_tex_off = Vec2::new(side_texture_index as f32, 0.);
|
let side_tex_off = Vec2::new(side_texture_index as f32, 0.);
|
||||||
|
|
||||||
let idx = verts.len() as u32;
|
let idx = verts.len() as u32;
|
||||||
uvs.push(uv_offset + tex_off);
|
uvs.push((uv_offset / TEX_MULTI) + tex_off);
|
||||||
verts.push(pos);
|
verts.push(pos);
|
||||||
for i in 0..6 {
|
for i in 0..6 {
|
||||||
let p = pos + HEX_CORNERS[i];
|
let p = pos + HEX_CORNERS[i];
|
||||||
verts.push(p);
|
verts.push(p);
|
||||||
let uv = (HEX_CORNERS[i].xz() / 2.) + uv_offset;
|
let uv = (HEX_CORNERS[i].xz() / 2.) + uv_offset;
|
||||||
uvs.push(uv + tex_off);
|
uvs.push((uv / TEX_MULTI) + tex_off);
|
||||||
indices.push(idx);
|
indices.push(idx);
|
||||||
indices.push(idx + 1 + i as u32);
|
indices.push(idx + 1 + i as u32);
|
||||||
indices.push(idx + 1 + ((i as u32 + 1) % 6));
|
indices.push(idx + 1 + ((i as u32 + 1) % 6));
|
||||||
@@ -145,7 +146,7 @@ fn create_tile_wall(
|
|||||||
indices.push(idx + 3);
|
indices.push(idx + 3);
|
||||||
|
|
||||||
uvs.push(Vec2::ZERO + tex_off);
|
uvs.push(Vec2::ZERO + tex_off);
|
||||||
uvs.push(Vec2::new(1., 0.) + tex_off);
|
uvs.push((Vec2::new(1., 0.) / TEX_MULTI) + tex_off);
|
||||||
uvs.push(Vec2::new(0., pos.y - height) + tex_off);
|
uvs.push((Vec2::new(0., pos.y - height) / TEX_MULTI) + tex_off);
|
||||||
uvs.push(Vec2::new(1., pos.y - height) + tex_off);
|
uvs.push((Vec2::new(1., pos.y - height) / TEX_MULTI) + tex_off);
|
||||||
}
|
}
|
||||||
|
|||||||
Submodule game/main/assets updated: 60527f41d5...b5c3a166a0
Reference in New Issue
Block a user