aboutsummaryrefslogtreecommitdiff
path: root/src/render
diff options
context:
space:
mode:
Diffstat (limited to 'src/render')
-rw-r--r--src/render/models.rs9
-rw-r--r--src/render/processing.rs24
2 files changed, 27 insertions, 6 deletions
diff --git a/src/render/models.rs b/src/render/models.rs
index 66b8714..24e7817 100644
--- a/src/render/models.rs
+++ b/src/render/models.rs
@@ -15,9 +15,12 @@ pub fn processed_block_texture(name: &str) -> ImageBuffer<Rgba<u8>, Vec<u8>> {
crossed_planes(&auto_block_texture())
}
"lilac" | "peony" | "rose_bush" | "tall_grass" => crossed_planes(&auto_block_texture()),
- "water" => full_isometric_sides(
- &crop16(&tint(&block_texture("water_still"), (0, 0, 255))),
- &crop16(&tint(&block_texture("water_flow"), (0, 0, 255))),
+ "water" => adjust_alpha(
+ 64,
+ &full_isometric_sides(
+ &crop16(&tint(&block_texture("water_still"), (0, 0, 255))),
+ &crop16(&tint(&block_texture("water_flow"), (0, 0, 255))),
+ ),
),
"lava" => full_isometric_sides(
&crop16(&block_texture("lava_still")),
diff --git a/src/render/processing.rs b/src/render/processing.rs
index 451fab3..7c35736 100644
--- a/src/render/processing.rs
+++ b/src/render/processing.rs
@@ -8,6 +8,20 @@ pub fn biome_tint(s: &Texture) -> Texture {
tint(s, (100, 200, 50))
}
+pub fn adjust_alpha(fac: u8, source: &Texture) -> Texture {
+ let mut t = ImageBuffer::new(16, 16);
+ for (x, y, p) in t.enumerate_pixels_mut() {
+ let sp = source.get_pixel(x, y);
+ *p = Rgba::from([
+ sp.0[0],
+ sp.0[1],
+ sp.0[2],
+ ((sp.0[3] as u16 * fac as u16) / 255) as u8,
+ ])
+ }
+ return t;
+}
+
pub fn tint(source: &Texture, tint: (u16, u16, u16)) -> Texture {
let mut t = ImageBuffer::new(16, 16);
for (x, y, p) in t.enumerate_pixels_mut() {
@@ -33,15 +47,19 @@ pub fn crop16(tex: &Texture) -> Texture {
pub fn transparent() -> Texture {
let mut t = ImageBuffer::new(16, 16);
- for (_,_,p) in t.enumerate_pixels_mut() {
- *p = Rgba::from([0,0,0,255])
+ for (_, _, p) in t.enumerate_pixels_mut() {
+ *p = Rgba::from([0, 0, 0, 255])
}
return t;
}
pub fn block_texture(block_name: &str) -> Texture {
image::open(&Path::new(
- format!("./assets/assets/minecraft/textures/block/{}.png", block_name).as_str(),
+ format!(
+ "./assets/assets/minecraft/textures/block/{}.png",
+ block_name
+ )
+ .as_str(),
))
.unwrap_or_else(|_err| {
image::open(&Path::new(