mirror of
https://github.com/storytold/texturecraft.git
synced 2026-11-20 14:30:43 +01:00
Every overlay gets the reference's colour swatch and eyedropper: the high poly, its matching error, the cage's surface and wireframe (separate, each with an opacity), the missing seams and the project mesh. The panel opens as the reference's does at first launch; its eye hides the baking meshes and greys their rows. Show for selected texture set only filters the cage and the high poly; a hidden high poly leaves the GPU. The UV seam overlay now marks the hard edges the UV layout does not split, on the low poly and the cage, in the 3D and 2D views. The project mesh can show the neutral material, picked in the 3D view's view menu: colour, roughness, metallic, baked AO, an optional baked bent normal, and Quality as importance-sampled reflections per pixel.
59 lines
2.5 KiB
Rust
59 lines
2.5 KiB
Rust
use texturecraft_engine::bake::{HIDDEN_HIGH_POLY_VERTEX, HighPolyReach, RayStart, VertexReach, high_poly_missed};
|
|
use texturecraft_engine::geom::glam::Vec3;
|
|
|
|
fn vertex(height: f32) -> Option<VertexReach> {
|
|
Some(VertexReach {
|
|
low_position: Vec3::ZERO,
|
|
start: RayStart::Distance { up: Vec3::Y, scale: 1.0 },
|
|
high_position: Vec3::new(0.0, height, 0.0),
|
|
high_facing: Vec3::Y,
|
|
name_matches: true,
|
|
})
|
|
}
|
|
|
|
fn reach(vertices: Vec<Option<VertexReach>>) -> Option<HighPolyReach> {
|
|
Some(HighPolyReach { vertices, cage_units: 1.0, ignore_backface: false })
|
|
}
|
|
|
|
fn sets() -> Vec<Option<HighPolyReach>> {
|
|
vec![None, reach(vec![vertex(0.5), vertex(-0.25), None, None, None]), reach(vec![None, None, vertex(0.5), vertex(-0.25), None])]
|
|
}
|
|
|
|
const DISTANCES: [(f32, f32); 3] = [(9.0, 9.0), (0.25, 0.25), (0.5, 0.125)];
|
|
|
|
#[test]
|
|
fn each_owning_set_uses_its_own_frontal_and_rear_distances() {
|
|
let reaches = sets();
|
|
assert_eq!(high_poly_missed(&reaches, &DISTANCES, None, 6), vec![1.0, 0.0, 0.0, 1.0, 0.0, 0.0]);
|
|
let expanded = [(9.0, 9.0), (0.5, 0.25), (0.5, 0.25)];
|
|
assert_eq!(high_poly_missed(&reaches, &expanded, None, 6), vec![0.0; 6]);
|
|
}
|
|
|
|
#[test]
|
|
fn selected_set_filter_hides_other_sets_vertices() {
|
|
const H: f32 = HIDDEN_HIGH_POLY_VERTEX;
|
|
let reaches = sets();
|
|
assert_eq!(high_poly_missed(&reaches, &DISTANCES, Some(1), 6), vec![1.0, 0.0, H, H, H, H]);
|
|
assert_eq!(high_poly_missed(&reaches, &DISTANCES, Some(2), 6), vec![H, H, 0.0, 1.0, H, H]);
|
|
for only_set in [0, reaches.len(), usize::MAX] {
|
|
assert_eq!(high_poly_missed(&reaches, &DISTANCES, Some(only_set), 6), vec![H; 6], "a set without a reach shows none of the high poly");
|
|
}
|
|
}
|
|
|
|
#[test]
|
|
fn missing_reach_or_distances_leave_vertices_unmarked() {
|
|
assert_eq!(high_poly_missed(&[], &DISTANCES, None, 6), vec![0.0; 6]);
|
|
assert_eq!(high_poly_missed(&sets(), &[], None, 6), vec![0.0; 6]);
|
|
assert_eq!(high_poly_missed(&sets(), &DISTANCES[..2], None, 6), vec![1.0, 0.0, 0.0, 0.0, 0.0, 0.0]);
|
|
assert_eq!(high_poly_missed(&sets(), &DISTANCES, None, 1), vec![1.0]);
|
|
assert!(high_poly_missed(&sets(), &DISTANCES, None, 0).is_empty());
|
|
}
|
|
|
|
#[test]
|
|
fn a_reached_vertex_is_not_overridden_by_a_later_set() {
|
|
let reaches = [reach(vec![vertex(0.5)]), reach(vec![vertex(0.5)])];
|
|
let distances = [(0.5, 0.0), (0.25, 0.0)];
|
|
assert_eq!(high_poly_missed(&reaches, &distances, None, 1), vec![0.0]);
|
|
assert_eq!(high_poly_missed(&reaches, &distances, Some(1), 1), vec![1.0]);
|
|
}
|