From bd3fbb71cdef1cda0e4db5efa14c632ae72859d6 Mon Sep 17 00:00:00 2001 From: Valentin Popov Date: Wed, 2 Dec 2026 21:55:24 +0400 Subject: fix(ui): restore native cockpit miniature lighting --- .../fparkan-render-vulkan/src/ffi/smoke_types.rs | 21 +++++++++++++++++++-- 1 file changed, 19 insertions(+), 2 deletions(-) (limited to 'adapters/fparkan-render-vulkan/src/ffi') diff --git a/adapters/fparkan-render-vulkan/src/ffi/smoke_types.rs b/adapters/fparkan-render-vulkan/src/ffi/smoke_types.rs index d7f5932c..a741e6f5 100644 --- a/adapters/fparkan-render-vulkan/src/ffi/smoke_types.rs +++ b/adapters/fparkan-render-vulkan/src/ffi/smoke_types.rs @@ -89,17 +89,21 @@ pub struct VulkanModelPreview { pub eye: [f32; 3], /// Directional lights belonging to the model viewport. pub lights: [VulkanDirectionalLight; VULKAN_DIRECTIONAL_LIGHT_COUNT], + /// Overrides the default per-channel minimum light in this viewport. + pub lighting_floor: Option<[f32; 3]>, } impl VulkanModelPreview { pub(super) fn frame_uniforms(&self) -> VulkanFrameUniforms { + let defaults = VulkanFrameUniforms::from_camera(self.camera); VulkanFrameUniforms { directional_lights: self.lights, camera_position: self.eye, fog_start: 0.0, fog_end: 0.0, world_point_lights: false, - ..VulkanFrameUniforms::from_camera(self.camera) + lighting_floor: self.lighting_floor.unwrap_or(defaults.lighting_floor), + ..defaults } } } @@ -173,6 +177,8 @@ pub struct VulkanDirectionalLight { pub active: bool, /// Whether this light contributes a material specular highlight. pub specular_enabled: bool, + /// Preserve the direction's magnitude in the lighting dot products. + pub preserve_direction_length: bool, } impl Default for VulkanDirectionalLight { @@ -183,6 +189,7 @@ impl Default for VulkanDirectionalLight { coefficients: [0.0, 0.0, 1.0], active: false, specular_enabled: true, + preserve_direction_length: false, } } } @@ -291,6 +298,7 @@ impl VulkanFrameUniforms { coefficients: [0.0, 0.0, 1.0], active: true, specular_enabled: true, + preserve_direction_length: false, }; Self { clip_from_world: camera.clip_from_world, @@ -353,7 +361,11 @@ impl VulkanFrameUniforms { light.direction[0], light.direction[1], light.direction[2], - if light.active { 1.0 } else { 0.0 }, + match (light.active, light.preserve_direction_length) { + (false, _) => 0.0, + (true, false) => 1.0, + (true, true) => 2.0, + }, ]); let rgb_offset = 32 + index * 4; values[rgb_offset..rgb_offset + 4].copy_from_slice(&[ @@ -912,6 +924,7 @@ mod static_mesh_tests { coefficients: [7.0, 8.0, 9.0], active: true, specular_enabled: true, + preserve_direction_length: false, }, VulkanDirectionalLight::default(), VulkanDirectionalLight::default(), @@ -974,9 +987,11 @@ mod static_mesh_tests { viewport: [0.1, 0.1, 0.4, 0.6], camera: VulkanStaticCamera::default(), eye: [-1.0, 0.0, 0.5], + lighting_floor: Some([0.1; 3]), lights: [VulkanDirectionalLight { rgb: [2.0; 3], active: true, + preserve_direction_length: true, ..Default::default() }; VULKAN_DIRECTIONAL_LIGHT_COUNT], }; @@ -984,6 +999,8 @@ mod static_mesh_tests { assert_eq!(frame.directional_lights, preview.lights); assert!(!frame.point_light.active); let bytes = frame.to_ne_bytes(); + assert_eq!(frame.lighting_floor, [0.1; 3]); + assert_eq!(&bytes[76..80], &2.0_f32.to_ne_bytes()); assert_eq!(&bytes[316..320], &1.0_f32.to_ne_bytes()); } -- cgit v1.2.3