aboutsummaryrefslogtreecommitdiff
path: root/apps/fparkan-game/src/scene_point_lights.rs
diff options
context:
space:
mode:
authorValentin Popov <valentin@popov.link>2026-12-03 13:46:31 +0300
committerValentin Popov <valentin@popov.link>2026-12-03 13:46:31 +0300
commit670aee00789e21ebe2d01932719fbce44971b089 (patch)
treed486460264c93086703da32c50d501b4a0589e28 /apps/fparkan-game/src/scene_point_lights.rs
parentb2d4de57ed7363fe30349ee443479ad4096ef048 (diff)
downloadfparkan-670aee00789e21ebe2d01932719fbce44971b089.tar.xz
fparkan-670aee00789e21ebe2d01932719fbce44971b089.zip
feat(render): omit software point lighting on low quality
Diffstat (limited to 'apps/fparkan-game/src/scene_point_lights.rs')
-rw-r--r--apps/fparkan-game/src/scene_point_lights.rs35
1 files changed, 35 insertions, 0 deletions
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::<Vec<_>>();
+ 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,
+ }
+}