fix: lerp RGB toward sky colour with full opacity — no alpha fade
- tile_for_depth: alpha always 1.0, lerp RGB from white toward sky RGB instead of fading tile out via alpha. Tiles stay opaque. - Expose LAYER_ALPHA as pub const so it can be tuned at runtime - LAYER_ALPHA changed from 41/255 to 50/255 for steeper visible fade - Invisible tiles: explicit solid sky colour, not tile_for_depth(0, 999)
This commit is contained in:
@@ -66,6 +66,7 @@ impl TilemapChunkSpawner {
|
|||||||
}
|
}
|
||||||
|
|
||||||
pub const FIXTURE_ROW_OFFSET: u16 = 6;
|
pub const FIXTURE_ROW_OFFSET: u16 = 6;
|
||||||
|
pub const LAYER_ALPHA: f32 = 50_f32 / 255_f32;
|
||||||
|
|
||||||
fn tile_id_to_tileset_index(tile_id: u32) -> Option<u16> {
|
fn tile_id_to_tileset_index(tile_id: u32) -> Option<u16> {
|
||||||
if tile_id == 0 {
|
if tile_id == 0 {
|
||||||
@@ -86,7 +87,6 @@ fn tile_for_depth(real_index: u16, z_diff: i32) -> TileData {
|
|||||||
const SKY_R: f32 = 133_f32 / 255_f32;
|
const SKY_R: f32 = 133_f32 / 255_f32;
|
||||||
const SKY_G: f32 = 167_f32 / 255_f32;
|
const SKY_G: f32 = 167_f32 / 255_f32;
|
||||||
const SKY_B: f32 = 178_f32 / 255_f32;
|
const SKY_B: f32 = 178_f32 / 255_f32;
|
||||||
const LAYER_ALPHA: f32 = 70_f32 / 255_f32;
|
|
||||||
|
|
||||||
if z_diff <= 0 {
|
if z_diff <= 0 {
|
||||||
return TileData {
|
return TileData {
|
||||||
@@ -107,18 +107,13 @@ fn tile_for_depth(real_index: u16, z_diff: i32) -> TileData {
|
|||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
if t < 0.5 {
|
let r = (1_f32 - t) + SKY_R * t;
|
||||||
TileData {
|
let g = (1_f32 - t) + SKY_G * t;
|
||||||
tileset_index: real_index,
|
let b = (1_f32 - t) + SKY_B * t;
|
||||||
color: Color::srgba(1_f32, 1_f32, 1_f32, 1_f32 - t * 2_f32),
|
TileData {
|
||||||
visible: true,
|
tileset_index: real_index,
|
||||||
}
|
color: Color::srgb(r, g, b),
|
||||||
} else {
|
visible: true,
|
||||||
TileData {
|
|
||||||
tileset_index: 0,
|
|
||||||
color: Color::srgba(SKY_R, SKY_G, SKY_B, (t - 0.5_f32) * 2_f32),
|
|
||||||
visible: true,
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -163,7 +158,15 @@ fn populate_chunk_tiles(
|
|||||||
let tile_data = if is_visible {
|
let tile_data = if is_visible {
|
||||||
tile_for_depth(tileset_idx, z_diff)
|
tile_for_depth(tileset_idx, z_diff)
|
||||||
} else {
|
} else {
|
||||||
tile_for_depth(0, 999)
|
TileData {
|
||||||
|
tileset_index: 0,
|
||||||
|
color: Color::srgb(
|
||||||
|
133_f32 / 255_f32,
|
||||||
|
167_f32 / 255_f32,
|
||||||
|
178_f32 / 255_f32,
|
||||||
|
),
|
||||||
|
visible: true,
|
||||||
|
}
|
||||||
};
|
};
|
||||||
tiles.push(Some(tile_data));
|
tiles.push(Some(tile_data));
|
||||||
} else {
|
} else {
|
||||||
|
|||||||
Reference in New Issue
Block a user