resource/block_color: fix scaling of biome-specific colors

All biome-specific colors (water/foliage/grass) were too bright by a
factor of 255 (i.e., white).
This commit is contained in:
Matthias Schiffer 2023-07-03 23:45:00 +02:00
parent 99c4de0b07
commit c471f84573
Signed by: neocturne
GPG key ID: 16EF3F64CB201D9C

View file

@ -2,10 +2,14 @@ use super::{Biome, BlockType, Color};
use glam::Vec3;
fn color_vec(color: Color) -> Vec3 {
fn color_vec_unscaled(color: Color) -> Vec3 {
Vec3::from_array(color.0.map(f32::from))
}
fn color_vec(color: Color) -> Vec3 {
color_vec_unscaled(color) / 255.0
}
fn color_from_params(colors: &[Vec3; 3], biome: &Biome, depth: f32) -> Vec3 {
let temp = (biome.temp() - f32::max((depth - 64.0) / 600.0, 0.0)).clamp(0.0, 1.0);
let downfall = biome.downfall().clamp(0.0, 1.0) * temp;
@ -71,7 +75,7 @@ const EVERGREEN_COLOR: Vec3 = Vec3::new(0.380, 0.600, 0.380); // == color_vec(Co
pub fn block_color(block: BlockType, biome: &Biome, depth: f32) -> [u8; 4] {
use super::BlockFlag::*;
let mut color = color_vec(block.color);
let mut color = color_vec_unscaled(block.color);
if block.is(Grass) {
color *= biome.grass_color(depth);