From d0972f5f1871561684b1d06afaf5a1cc00f4b43f Mon Sep 17 00:00:00 2001 From: mosure Date: Tue, 15 Oct 2024 18:32:09 -0500 Subject: [PATCH] feat: global opacity --- src/gaussian/settings.rs | 2 ++ src/render/bindings.wgsl | 1 + src/render/gaussian.wgsl | 2 +- src/render/mod.rs | 2 ++ 4 files changed, 6 insertions(+), 1 deletion(-) diff --git a/src/gaussian/settings.rs b/src/gaussian/settings.rs index 42484c2f..51ebce2e 100644 --- a/src/gaussian/settings.rs +++ b/src/gaussian/settings.rs @@ -43,6 +43,7 @@ pub enum GaussianCloudRasterize { #[reflect(Component)] pub struct GaussianCloudSettings { pub aabb: bool, + pub global_opacity: f32, pub global_scale: f32, pub transform: Transform, pub visualize_bounding_box: bool, @@ -55,6 +56,7 @@ impl Default for GaussianCloudSettings { fn default() -> Self { Self { aabb: false, + global_opacity: 1.0, global_scale: 1.0, transform: Transform::IDENTITY, visualize_bounding_box: false, diff --git a/src/render/bindings.wgsl b/src/render/bindings.wgsl index f605d7cf..5dfbda7e 100644 --- a/src/render/bindings.wgsl +++ b/src/render/bindings.wgsl @@ -9,6 +9,7 @@ struct GaussianUniforms { transform: mat4x4, + global_opacity: f32, global_scale: f32, count: u32, count_root_ceil: u32, diff --git a/src/render/gaussian.wgsl b/src/render/gaussian.wgsl index e07a6aab..bbafd7ff 100644 --- a/src/render/gaussian.wgsl +++ b/src/render/gaussian.wgsl @@ -435,7 +435,7 @@ fn vs_points( // TODO: verify color benefit for ray_direction computed at quad verticies instead of gaussian center (same as current complexity) output.color = vec4( rgb, - get_opacity(splat_index), + get_opacity(splat_index) * gaussian_uniforms.global_opacity, ); #ifdef HIGHLIGHT_SELECTED diff --git a/src/render/mod.rs b/src/render/mod.rs index f7d7253b..b0083780 100644 --- a/src/render/mod.rs +++ b/src/render/mod.rs @@ -668,6 +668,7 @@ type DrawGaussians = ( #[derive(Component, ShaderType, Clone)] pub struct GaussianCloudUniform { pub transform: Mat4, + pub global_opacity: f32, pub global_scale: f32, pub count: u32, pub count_root_ceil: u32, @@ -716,6 +717,7 @@ pub fn extract_gaussians( let settings_uniform = GaussianCloudUniform { transform: settings.transform.compute_matrix(), + global_opacity: settings.global_opacity, global_scale: settings.global_scale, count: cloud.count as u32, count_root_ceil: (cloud.count as f32).sqrt().ceil() as u32,