From 670aee00789e21ebe2d01932719fbce44971b089 Mon Sep 17 00:00:00 2001 From: Valentin Popov Date: Thu, 3 Dec 2026 14:46:31 +0400 Subject: feat(render): omit software point lighting on low quality --- apps/fparkan-game/src/scene_point_lights.rs | 35 +++++++++++++++++++++++++++++ 1 file changed, 35 insertions(+) create mode 100644 apps/fparkan-game/src/scene_point_lights.rs (limited to 'apps/fparkan-game/src/scene_point_lights.rs') diff --git a/apps/fparkan-game/src/scene_point_lights.rs b/apps/fparkan-game/src/scene_point_lights.rs new file mode 100644 index 00000000..995879c3 --- /dev/null +++ b/apps/fparkan-game/src/scene_point_lights.rs @@ -0,0 +1,35 @@ +use fparkan_fx::environment::{EnvironmentFrame, PointLightFrame}; +use fparkan_render_vulkan::{VulkanPointLight, VulkanSmokeRenderer, VulkanSmokeRendererError}; + +pub(super) fn upload( + renderer: &mut VulkanSmokeRenderer, + enabled: bool, + environment: Option<&EnvironmentFrame>, + control_lights: &[VulkanPointLight], +) -> Result<(), VulkanSmokeRendererError> { + if !enabled { + return renderer.set_point_lights(&[]); + } + let Some(environment) = environment else { + return renderer.set_point_lights(control_lights); + }; + let lights = environment + .point_lights + .iter() + .filter(|light| light.active) + .map(environment_record) + .chain(control_lights.iter().copied()) + .collect::>(); + renderer.set_point_lights(&lights) +} + +pub(super) fn environment_record(light: &PointLightFrame) -> VulkanPointLight { + VulkanPointLight { + owner_scope: 0, + position: light.position, + rgb: [light.color[0], light.color[1], light.color[2]], + range: light.range, + coefficients: light.attenuation, + active: light.active, + } +} -- cgit v1.2.3