Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: global opacity #115

Merged
merged 1 commit into from
Oct 16, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions src/gaussian/settings.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -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,
Expand Down
1 change: 1 addition & 0 deletions src/render/bindings.wgsl
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@

struct GaussianUniforms {
transform: mat4x4<f32>,
global_opacity: f32,
global_scale: f32,
count: u32,
count_root_ceil: u32,
Expand Down
2 changes: 1 addition & 1 deletion src/render/gaussian.wgsl
Original file line number Diff line number Diff line change
Expand Up @@ -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<f32>(
rgb,
get_opacity(splat_index),
get_opacity(splat_index) * gaussian_uniforms.global_opacity,
);

#ifdef HIGHLIGHT_SELECTED
Expand Down
2 changes: 2 additions & 0 deletions src/render/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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,
Expand Down
Loading