fix(hatch): delay complex pattern LOD
Keep every pattern family visible until all projected spacings become sub-pixel, then switch the hatch to solid. Refs #569
This commit is contained in:
parent
fcc6e1f8e1
commit
8e2b67bfa5
3 changed files with 71 additions and 23 deletions
40
tests/hatch_shader_lod.rs
Normal file
40
tests/hatch_shader_lod.rs
Normal file
|
|
@ -0,0 +1,40 @@
|
|||
const STORAGE_SHADER: &str = include_str!("../src/shaders/hatch.wgsl");
|
||||
const TEXTURE_SHADER: &str = include_str!("../src/shaders/hatch_texture.wgsl");
|
||||
|
||||
fn assert_all_family_lod(source: &str, name: &str) {
|
||||
let module = naga::front::wgsl::parse_str(source)
|
||||
.unwrap_or_else(|error| panic!("{name} WGSL must parse: {error}"));
|
||||
naga::valid::Validator::new(
|
||||
naga::valid::ValidationFlags::all(),
|
||||
naga::valid::Capabilities::empty(),
|
||||
)
|
||||
.validate(&module)
|
||||
.unwrap_or_else(|error| panic!("{name} WGSL must validate: {error}"));
|
||||
|
||||
assert!(
|
||||
source.contains("var all_families_subpixel"),
|
||||
"{name} must track the all-family LOD transition"
|
||||
);
|
||||
assert!(
|
||||
source.contains("if all_families_subpixel"),
|
||||
"{name} must solid-fill only at the all-family transition"
|
||||
);
|
||||
assert!(
|
||||
!source.contains("if is_subpixel") && !source.contains("visible_families"),
|
||||
"{name} must not skip individual families before LOD activates"
|
||||
);
|
||||
assert!(
|
||||
!source.contains("min_spacing_world"),
|
||||
"{name} must not solid-fill a complex pattern because of one dense family"
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn storage_hatch_lod_waits_for_every_family() {
|
||||
assert_all_family_lod(STORAGE_SHADER, "storage hatch");
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn texture_hatch_lod_waits_for_every_family() {
|
||||
assert_all_family_lod(TEXTURE_SHADER, "texture hatch");
|
||||
}
|
||||
Loading…
Reference in a new issue