Surface world: grass in daylight, forests, cliffs with cave mouths; free-game and editor option
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
ef10b5c432
commit
8a35a903de
32 files changed
+343
-24
No files matched your search
+19
-7
@@ -449,6 +449,10 @@ fn ambient_field(map: &Map) -> Vec<f32> {
|
||||
(false, Owner::Hero) => 0.6,
|
||||
_ => 0.0,
|
||||
};
|
||||
// daylight above ground (cliffs and trees too)
|
||||
if map.sky(i) {
|
||||
f[i] = 1.6;
|
||||
}
|
||||
if t.river() == Some(Kind::Lava) {
|
||||
f[i] = f[i].max(0.8); // lava lights up its surroundings
|
||||
}
|
||||
@@ -672,7 +676,11 @@ fn build_chunk(map: &Map, amb: &[f32], glow: &[f32], cx: i32, cz: i32, atlas: &T
|
||||
for z in cz * CHUNK..((cz + 1) * CHUNK).min(mh() as i32) {
|
||||
for x in cx * CHUNK..((cx + 1) * CHUNK).min(mw() as i32) {
|
||||
let t = map.t[idx(x, z)];
|
||||
let tex = Gfx::tile_tex(t.kind, t.owner, t.var, t.reinforced);
|
||||
let mut tex = Gfx::tile_tex(t.kind, t.owner, t.var, t.reinforced);
|
||||
// open land above ground is grass (until a master claims it)
|
||||
if map.sky(idx(x, z)) && t.kind == Kind::Floor && t.owner == Owner::None {
|
||||
tex = T_GRASS + (t.var as u32 & 3);
|
||||
}
|
||||
let (ua, ub) = cell_uv(tex);
|
||||
let (xf, zf) = (x as f32, z as f32);
|
||||
if !map.shown(idx(x, z)) {
|
||||
@@ -836,11 +844,13 @@ fn build_chunk(map: &Map, amb: &[f32], glow: &[f32], cx: i32, cz: i32, atlas: &T
|
||||
c,
|
||||
[Vec3::Y; 4],
|
||||
);
|
||||
// outlines: north and west edge, only between two open tiles (each edge once)
|
||||
if !solid_at(map, x, z - 1) {
|
||||
// outlines: north and west edge, only between two open tiles (each edge once);
|
||||
// open land above ground has none
|
||||
let outdoors = map.sky(idx(x, z)) && t.owner == Owner::None;
|
||||
if !solid_at(map, x, z - 1) && !outdoors {
|
||||
ln.strip(vec3(xf, 0.0, zf), vec3(xf + 1.0, 0.0, zf), Vec3::Y, OUTLINE_W, OUTLINE_C);
|
||||
}
|
||||
if !solid_at(map, x - 1, z) {
|
||||
if !solid_at(map, x - 1, z) && !outdoors {
|
||||
ln.strip(vec3(xf, 0.0, zf), vec3(xf, 0.0, zf + 1.0), Vec3::Y, OUTLINE_W, OUTLINE_C);
|
||||
}
|
||||
// room decor
|
||||
@@ -871,7 +881,7 @@ fn build_chunk(map: &Map, amb: &[f32], glow: &[f32], cx: i32, cz: i32, atlas: &T
|
||||
}
|
||||
}
|
||||
// wear and tear: grit and cracks on plain floors
|
||||
if matches!(t.kind, Kind::Floor) {
|
||||
if matches!(t.kind, Kind::Floor) && !outdoors {
|
||||
let hsh = (x as u32).wrapping_mul(2654435761) ^ (z as u32).wrapping_mul(2246822519);
|
||||
let hsh = (hsh ^ (hsh >> 15)).wrapping_mul(2246822519);
|
||||
let decal = match hsh % 11 {
|
||||
@@ -1083,7 +1093,7 @@ fn chunk_sig(map: &Map, cx: i32, cz: i32) -> u64 {
|
||||
Kind::Drawbridge => t.res as u64,
|
||||
_ => 0,
|
||||
};
|
||||
let shown = map.shown(idx(x, z)) as u64;
|
||||
let shown = map.shown(idx(x, z)) as u64 | (map.sky(idx(x, z)) as u64) << 1;
|
||||
(t.kind as u64) | (t.owner as u64) << 5 | (t.marked as u64) << 8 | (t.reinforced as u64) << 9 | shown << 10 | extra << 11
|
||||
}
|
||||
None => 0xff,
|
||||
@@ -1462,7 +1472,9 @@ impl R3d {
|
||||
let amb = |x: f32, z: f32| {
|
||||
let (ix, iz) = (x as i32, z as i32);
|
||||
let own = g.map.get(ix, iz).map_or(false, |t| t.owner == Owner::Player);
|
||||
if own {
|
||||
if inb(ix, iz) && g.map.sky(idx(ix, iz)) {
|
||||
0.95
|
||||
} else if own {
|
||||
0.75
|
||||
} else {
|
||||
0.5
|
||||
|
||||
Reference in new issue
Block a user