Blend the hover tint with the blurred scattering light and fix the export tree test query

This commit is contained in:
vangel76 committed 2026-11-22 23:22:02 +01:00
1 parent f5e5932539
commit dd00c4e04d
3 files changed
+31 -1

No files matched your search

+5
View File
@@ -388,6 +388,11 @@ fn fs_gbuf(i: VOut, @builtin(front_facing) front: bool) -> @location(0) vec4<f32
var sss = vec3<f32>(0.0);
if (g.scatter.w > 0.5) {
sss = shade_mesh(i, front).sss;
if (i.hover == 1u) {
// fs_mesh mixes the hover tint into the color without this light; the blur pass adds it
// back unblended, so scale it by the share of the color that stays
sss = sss * (1.0 - g.set_hover.a);
}
} else if (textureSample(t_base, samp, i.uv).a < hash12(i.clip.xy)) {
discard;
}
+25
View File
@@ -1072,6 +1072,31 @@ fn subsurface_blur_spreads_only_scattering_light() {
assert!((m1 - m0).abs() < 2.0, "the blur moves light, it adds none: {m0} -> {m1}");
}
#[test]
fn the_hover_tint_covers_the_blurred_scattering_light_too() {
let Some((mut h, frame)) = setup() else { return };
let lit = shaded(&frame, |s| s.light = LIGHT);
let mask = mesh_mask(&mut h, &lit, &[0]);
fill(&mut h, &[0, 1], DisplayKind::BaseColor, &[150, 150, 150, 255]);
fill(&mut h, &[0, 1], DisplayKind::Emissive, &[0, 0, 0, 255]);
let blur = shaded(&lit, |s| s.sss_blur = Some([0.06, 0.024, 0.015]));
let hover = |f: &Frame| shaded(f, |s| s.set_hover = Some(texturecraft_render::SetHighlight { set: 0, color: [1.0, 0.5, 0.0] }));
let mean = |img: &Img| region_mean(&mask, |x, y| img.luma(x, y));
let plain = mean(&render(&mut h, &lit, "hover_sss_plain"));
let blurred = mean(&render(&mut h, &blur, "hover_sss_blur"));
let hovered_plain = mean(&render(&mut h, &hover(&lit), "hover_sss_plain_hovered"));
let hovered_blur = mean(&render(&mut h, &hover(&blur), "hover_sss_blur_hovered"));
assert!(hovered_plain != plain, "the hover tint changes the set");
// The blur only moves light around, so it must change a hovered set as little as a plain one
// (the scattering light restored by the blur pass is blended with the tint as well)
assert!(
((hovered_blur - hovered_plain) - (blurred - plain)).abs() < 3.0,
"the blur changes the plain set by {} and the hovered set by {}",
blurred - plain,
hovered_blur - hovered_plain
);
}
/// An environment that is bright only around `dir` (world space, rotation 0).
fn spot_environment(dir: texturecraft_geom::glam::Vec3) -> ImageRes {
let (w, hh) = (256u32, 128u32);
+1 -1
View File
@@ -124,7 +124,7 @@ fn the_list_is_a_tree_per_texture_set_with_the_console_beside_it() {
h.state_mut().ui.export.tab = 2;
h.run_steps(4);
let set = h.state().session.doc.project.texture_sets[0].name.clone();
assert!(h.query_by_label(&set).is_some());
assert!(h.query_by_role_and_label(egui::Role::DisclosureTriangle, &set).is_some(), "the export tree has a node for the set (the dock list row carries the same name)");
assert!(h.query_all_by_label("256x256 (Texture Set size)").next().is_some());
assert!(h.query_all_by_label("png").next().is_some() && h.query_all_by_label("16 bits").next().is_some());
assert!(h.query_by_label("Include all").is_none() && h.query_by_label("Reset all").is_none());