From b5e3cbcab8bf375899140883e402d80519127d3a Mon Sep 17 00:00:00 2001 From: Kevin Reid Date: Tue, 14 Nov 2023 11:53:35 -0800 Subject: [PATCH] Use per-face colors in light propagation. --- .../output-path-with-graphics.stdout | 4 ++-- all-is-cubes/src/block/evaluated.rs | 9 ++++++++- all-is-cubes/src/space/light/updater.rs | 9 +++++++-- test-renderers/expected/icons-all.png | Bin 4219 -> 4218 bytes 4 files changed, 17 insertions(+), 5 deletions(-) diff --git a/all-is-cubes-desktop/tests/end-to-end/output-path-with-graphics.stdout b/all-is-cubes-desktop/tests/end-to-end/output-path-with-graphics.stdout index 937297eef..4cab6fea6 100644 --- a/all-is-cubes-desktop/tests/end-to-end/output-path-with-graphics.stdout +++ b/all-is-cubes-desktop/tests/end-to-end/output-path-with-graphics.stdout @@ -1,5 +1,5 @@ -[?25l â–„â–„â–„â–„â–„â–„â–„â–„â–„â–„â–„â–„ - â–„â–„â–„â–„â–„â–„â–„â–„â–„â–„â–„â–„ +[?25l â–„â–„â–„â–„â–„â–„â–„â–„â–„â–„â–„â–„ + â–„â–„â–„â–„â–„â–„â–„â–„â–„â–„â–„â–„       diff --git a/all-is-cubes/src/block/evaluated.rs b/all-is-cubes/src/block/evaluated.rs index 814cf19c6..6acad7cc2 100644 --- a/all-is-cubes/src/block/evaluated.rs +++ b/all-is-cubes/src/block/evaluated.rs @@ -7,7 +7,7 @@ use euclid::Vector3D; use ordered_float::NotNan; use crate::content::palette; -use crate::math::{Cube, Face6, FaceMap, GridAab, OpacityCategory, Rgb, Rgba, Vol}; +use crate::math::{Cube, Face6, Face7, FaceMap, GridAab, OpacityCategory, Rgb, Rgba, Vol}; use crate::raytracer; use crate::universe::RefError; use crate::{ @@ -314,6 +314,13 @@ impl EvaluatedBlock { self.voxels.bounds() } + pub(crate) fn face7_color(&self, face: Face7) -> Rgba { + match Face6::try_from(face) { + Ok(face) => self.face_colors[face], + Err(_) => self.color, + } + } + /// Expresses the opacity of the block as an [`OpacityCategory`]. /// /// If the return value is [`OpacityCategory::Partial`], this does not necessarily mean diff --git a/all-is-cubes/src/space/light/updater.rs b/all-is-cubes/src/space/light/updater.rs index 82cec267a..f00a6c50f 100644 --- a/all-is-cubes/src/space/light/updater.rs +++ b/all-is-cubes/src/space/light/updater.rs @@ -688,7 +688,8 @@ impl LightBuffer { } let stored_light = current_light.get(light_cube); - let surface_color = ev_hit.color.clamp().to_rgb() * SURFACE_ABSORPTION + let surface_color = ev_hit.face7_color(hit.face()).clamp().to_rgb() + * SURFACE_ABSORPTION + Rgb::ONE * (1. - SURFACE_ABSORPTION); let light_from_struck_face = ev_hit.light_emission + stored_light.value() * surface_color; @@ -728,7 +729,11 @@ impl LightBuffer { // as opposed to passing through it. // The block evaluation algorithm incidentally computes a suitable // approximation as an alpha value. - let coverage = ev_hit.color.alpha().into_inner().clamp(0.0, 1.0); + let coverage = ev_hit + .face7_color(hit.face()) + .alpha() + .into_inner() + .clamp(0.0, 1.0); self.incoming_light += (ev_hit.light_emission + stored_light) * coverage * ray_state.alpha diff --git a/test-renderers/expected/icons-all.png b/test-renderers/expected/icons-all.png index 49858a6298523b86753f8e05f958968978b2469d..fec36c954342a478b5dab9b8b4e0c4133731dddc 100644 GIT binary patch delta 3334 zcma);`9IWa8^`bOw;6`XX~vSJWUSe;rG%OpV@nE!gA`NJq->eQk(v2gLW>&4`c#HE zQOX)k#TZgrq;cd}qg1k_tYK`=^!x?S{loRswY*-R&vn1=dx;<-u(en=PIfjP(Y+J5 zK9p{8R7K`l6?0tn&OQH;<)rIqS5iX`?+6O&(CU1D+af-bQa^2_c*rdg^PEX0>%W(+ z3n~~&wbwh?_b^cw|2b8rS7*CpIW^!U3$pS>jDPfN zn=I!q_@j^>X`D8?Hv&KehV<-D=j?6ngsFYD_daL9A**|BK@9Bnry76|d0jv0M1X*s zM|BO+V;2t4q#uSbQLrFbqRGnn_N_qS*EcwzB;^2fBh79euq?R+hcK>)^D)2&Q*lC< z=M+aBhD&f^eypXi&@0ENJ7j}*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