diff options
| author | Valentin Popov <valentin@popov.link> | 2026-11-12 13:04:46 +0300 |
|---|---|---|
| committer | Valentin Popov <valentin@popov.link> | 2026-11-12 13:04:46 +0300 |
| commit | bcd075820a7fbe72d3c293a4e4365a349c7a9958 (patch) | |
| tree | 8041104b8eff4d9a2f190e4b866c03293dbece67 /adapters/fparkan-render-vulkan/src | |
| parent | 98d8a99bc162176919ad19593007b2a20252bf84 (diff) | |
| download | fparkan-bcd075820a7fbe72d3c293a4e4365a349c7a9958.tar.xz fparkan-bcd075820a7fbe72d3c293a4e4365a349c7a9958.zip | |
fix(render): disable specular from opposite celestial lights
Diffstat (limited to 'adapters/fparkan-render-vulkan/src')
| -rw-r--r-- | adapters/fparkan-render-vulkan/src/ffi/smoke_types.rs | 14 |
1 files changed, 13 insertions, 1 deletions
diff --git a/adapters/fparkan-render-vulkan/src/ffi/smoke_types.rs b/adapters/fparkan-render-vulkan/src/ffi/smoke_types.rs index fc8aea9f..9fcc0fa4 100644 --- a/adapters/fparkan-render-vulkan/src/ffi/smoke_types.rs +++ b/adapters/fparkan-render-vulkan/src/ffi/smoke_types.rs @@ -142,6 +142,8 @@ pub struct VulkanDirectionalLight { pub coefficients: [f32; 3], /// Whether the light participates in this frame. pub active: bool, + /// Whether this light contributes a material specular highlight. + pub specular_enabled: bool, } impl Default for VulkanDirectionalLight { @@ -151,6 +153,7 @@ impl Default for VulkanDirectionalLight { rgb: [0.0; 3], coefficients: [0.0, 0.0, 1.0], active: false, + specular_enabled: true, } } } @@ -256,6 +259,7 @@ impl VulkanFrameUniforms { rgb: [1.0; 3], coefficients: [0.0, 0.0, 1.0], active: true, + specular_enabled: true, }; Self { clip_from_world: camera.clip_from_world, @@ -324,7 +328,7 @@ impl VulkanFrameUniforms { light.rgb[0], light.rgb[1], light.rgb[2], - if light.active { 1.0 } else { 0.0 }, + if light.specular_enabled { 1.0 } else { 0.0 }, ]); let coefficient_offset = 48 + index * 4; values[coefficient_offset..coefficient_offset + 4].copy_from_slice(&[ @@ -875,6 +879,7 @@ mod static_mesh_tests { rgb: [4.0, 5.0, 6.0], coefficients: [7.0, 8.0, 9.0], active: true, + specular_enabled: true, }, VulkanDirectionalLight::default(), VulkanDirectionalLight::default(), @@ -918,6 +923,13 @@ mod static_mesh_tests { assert_eq!(read(384), 0.25); assert_eq!(read(388), 100.0); assert_eq!(read(392), 0.01); + let mut diffuse_only = frame; + diffuse_only.directional_lights[0].specular_enabled = false; + let bytes = diffuse_only.to_ne_bytes(); + let read = |offset| f32::from_ne_bytes(bytes[offset..offset + 4].try_into().unwrap()); + assert_eq!(read(76), 1.0); + assert_eq!(read(128), 4.0); + assert_eq!(read(140), 0.0); } #[test] |
