fix(render): use original MSH UV scale
This commit is contained in:
@@ -94,19 +94,23 @@ pub fn project_msh_to_static_mesh(
|
|||||||
let vertices = model
|
let vertices = model
|
||||||
.positions
|
.positions
|
||||||
.iter()
|
.iter()
|
||||||
.map(|position| VulkanStaticVertex {
|
.enumerate()
|
||||||
|
.map(|(index, position)| VulkanStaticVertex {
|
||||||
position: [
|
position: [
|
||||||
(position[0] - center_x) * scale,
|
(position[0] - center_x) * scale,
|
||||||
(position[2] - center_z) * scale,
|
(position[2] - center_z) * scale,
|
||||||
],
|
],
|
||||||
color: [0.82, 0.72, 0.31],
|
color: [0.82, 0.72, 0.31],
|
||||||
// The exact fixed-point normalization of Res5 is still under
|
// Iron3D stores Res5 UV0 as signed fixed point with 1/1024 units.
|
||||||
// disassembly. Until then the asset viewer uses its documented XZ
|
// Models that omit this optional stream retain the static viewer's
|
||||||
// planar projection, rather than inventing a scale for raw i16 UV0.
|
// XZ planar fallback instead of receiving fabricated raw UV values.
|
||||||
uv: [
|
uv: model.uv0.as_ref().and_then(|uv0| uv0.get(index)).map_or(
|
||||||
(position[0] - center_x) / extent + 0.5,
|
[
|
||||||
(position[2] - center_z) / extent + 0.5,
|
(position[0] - center_x) / extent + 0.5,
|
||||||
],
|
(position[2] - center_z) / extent + 0.5,
|
||||||
|
],
|
||||||
|
|uv| [f32::from(uv[0]) / 1024.0, f32::from(uv[1]) / 1024.0],
|
||||||
|
),
|
||||||
})
|
})
|
||||||
.collect();
|
.collect();
|
||||||
|
|
||||||
@@ -165,4 +169,20 @@ mod tests {
|
|||||||
assert_eq!(mesh.vertices[2].position, [0.8, -0.8]);
|
assert_eq!(mesh.vertices[2].position, [0.8, -0.8]);
|
||||||
assert_eq!(mesh.vertices[3].position, [-0.8, 0.8]);
|
assert_eq!(mesh.vertices[3].position, [-0.8, 0.8]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn projects_packed_uv0_using_documented_fixed_point_scale() {
|
||||||
|
let mut source = model(
|
||||||
|
vec![[-2.0, 0.0, -1.0], [2.0, 0.0, -1.0], [-2.0, 0.0, 3.0]],
|
||||||
|
vec![0, 1, 2],
|
||||||
|
vec![batch(0, 3, 0)],
|
||||||
|
);
|
||||||
|
source.uv0 = Some(vec![[1024, -512], [0, 2048], [-1024, 512]]);
|
||||||
|
|
||||||
|
let mesh = project_msh_to_static_mesh(&source).expect("representable MSH");
|
||||||
|
|
||||||
|
assert_eq!(mesh.vertices[0].uv, [1.0, -0.5]);
|
||||||
|
assert_eq!(mesh.vertices[1].uv, [0.0, 2.0]);
|
||||||
|
assert_eq!(mesh.vertices[2].uv, [-1.0, 0.5]);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -29,7 +29,7 @@
|
|||||||
|
|
||||||
## Current repository status
|
## Current repository status
|
||||||
|
|
||||||
- Реальный Vulkan в репозитории имеет smoke triangle path и узкий static asset bridge: `fparkan-vulkan-smoke --model-root <GOG_ROOT> --model-archive system.rlb --model-name MTCHECK.MSH --texture-root <GOG_ROOT> --texture-archive Textures.lib --texture-name DEFAULT.0` загружает validated original MSH, разворачивает batch `base_vertex`, нормализует XZ viewer plane, выполняет real indexed draw и загружает decoded TEXM mip-0 в device-local image. Image переходит в sampling layout, записывается в `set=0,binding=0` combined image sampler и sampled fragment shader-ом. Для static viewer UV сейчас XZ-planar: parser сохраняет raw packed `Res5` UV0, но его fixed-point scale ещё не доказан. Это не WEAR/MAT0, exact material, terrain или gameplay renderer.
|
- Реальный Vulkan в репозитории имеет smoke triangle path и узкий static asset bridge: `fparkan-vulkan-smoke --model-root <GOG_ROOT> --model-archive system.rlb --model-name MTCHECK.MSH --texture-root <GOG_ROOT> --texture-archive Textures.lib --texture-name DEFAULT.0` загружает validated original MSH, разворачивает batch `base_vertex`, нормализует XZ viewer plane, выполняет real indexed draw и загружает decoded TEXM mip-0 в device-local image. Image переходит в sampling layout, записывается в `set=0,binding=0` combined image sampler и sampled fragment shader-ом. `Res5` UV0 декодируется как signed fixed point `int16 / 1024.0`; XZ-planar UV остаётся только fallback для модели без optional stream. Это не WEAR/MAT0, exact material, terrain или gameplay renderer.
|
||||||
- `apps/fparkan-game` сейчас выдает `render-planning` JSON report поверх
|
- `apps/fparkan-game` сейчас выдает `render-planning` JSON report поверх
|
||||||
synthetic window descriptor и `VulkanPlanningBackend`.
|
synthetic window descriptor и `VulkanPlanningBackend`.
|
||||||
- `apps/fparkan-viewer` сейчас inspection-only CLI и не открывает live Vulkan
|
- `apps/fparkan-viewer` сейчас inspection-only CLI и не открывает live Vulkan
|
||||||
|
|||||||
Reference in New Issue
Block a user