Files
texturecraft/crates/render/src/bake_visualization.rs
T
Rebornim dafbdf3ec7 Bake mode: the Baking Visualization panel and neutral material, as in the reference
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.
2026-11-12 04:33:37 +00:00

59 lines
2.3 KiB
Rust

//! What bake mode's 3D view draws while a bake is set up: the high poly, the cage, the missing seams and the low poly
use crate::bake_overlay::BakeOverlay;
use crate::neutral_material::NeutralMaterial;
/// Default overlay colors, linear RGB
const HIGH_POLY_COLOR: [f32; 3] = [0.0, 0.216, 0.521];
const MATCHING_ERROR_COLOR: [f32; 3] = [1.0, 0.0, 0.0];
const CAGE_SURFACE_COLOR: [f32; 3] = [0.604, 0.451, 0.216];
const CAGE_WIRE_COLOR: [f32; 3] = [0.604, 0.604, 0.604];
const MISSING_SEAM_COLOR: [f32; 3] = [0.451, 0.0, 0.451];
const LOW_POLY_COLOR: [f32; 3] = [0.216, 0.216, 0.216];
/// Which parts of the bake setup the 3D view draws, and how
#[derive(Clone, Copy, Debug, PartialEq)]
pub struct BakeVisualization {
pub high_poly: BakeOverlay,
/// Tints the high poly where the bake's rays miss it
pub matching_error: BakeOverlay,
pub cage_surface: BakeOverlay,
pub cage_wire: BakeOverlay,
/// The low poly's hard edges that are not UV seams
pub missing_seams: BakeOverlay,
/// The low poly; its color is the neutral material's color
pub low_poly: BakeOverlay,
/// Shade the low poly with this plain material instead of its painted one
pub neutral: Option<NeutralMaterial>,
/// Draw the cage and high poly of only this texture set (the high poly's vertices of other sets come marked hidden)
pub only_set: Option<usize>,
}
impl Default for BakeVisualization {
/// Every part hidden, in its default color, the low poly with its painted material
fn default() -> Self {
Self {
high_poly: BakeOverlay::hidden(HIGH_POLY_COLOR),
matching_error: BakeOverlay::hidden(MATCHING_ERROR_COLOR),
cage_surface: BakeOverlay::hidden(CAGE_SURFACE_COLOR),
cage_wire: BakeOverlay::hidden(CAGE_WIRE_COLOR),
missing_seams: BakeOverlay::hidden(MISSING_SEAM_COLOR),
low_poly: BakeOverlay::hidden(LOW_POLY_COLOR),
neutral: None,
only_set: None,
}
}
}
impl BakeVisualization {
/// Whether any part of the cage shows
pub fn cage_shown(&self) -> bool {
self.cage_surface.shown || self.cage_wire.shown
}
/// The neutral material while the low poly shows with it
pub fn shown_neutral(&self) -> Option<NeutralMaterial> {
self.neutral.filter(|_| self.low_poly.shown)
}
}