这是indexloc提供的服务,不要输入任何密码
Skip to content
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,894 changes: 1,783 additions & 1,111 deletions Cargo.lock

Large diffs are not rendered by default.

39 changes: 21 additions & 18 deletions Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
[package]
name = "bevy_gaussian_splatting"
description = "bevy gaussian splatting render pipeline plugin"
version = "4.6.1"
edition = "2021"
version = "5.0.1"
edition = "2024"
rust-version = "1.85.0"
authors = ["mosure <mitchell@mosure.me>"]
license = "MIT OR Apache-2.0"
keywords = [
Expand Down Expand Up @@ -119,13 +120,13 @@ headless = [
]

viewer = [
"bevy/png",
"bevy-inspector-egui",
"bevy_panorbit_camera",
# "bevy_transform_gizmo",
"bevy/multi_threaded", # bevy screenshot functionality requires bevy/multi_threaded as of 0.12.1
"bevy/bevy_gizmos",
"bevy/bevy_ui",
"bevy/multi_threaded", # bevy screenshot functionality requires bevy/multi_threaded as of 0.12.1
"bevy/png",
]

web = [
Expand Down Expand Up @@ -154,22 +155,22 @@ webgpu = ["bevy/webgpu"]

[dependencies]
base64 = { version = "0.22", optional = true }
bevy_args = "~1.7.1"
bevy-inspector-egui = { version = "0.28", optional = true }
bevy_interleave = { version = "0.6.1" }
bevy_args = "~1.8"
bevy-inspector-egui = { version = "0.31", optional = true }
bevy_interleave = { version = "0.7.2" }
# bevy_panorbit_camera = { git = "https://github.com/mosure/bevy_panorbit_camera.git", optional = true, features = ["bevy_egui"] }
bevy_panorbit_camera = { version = "0.21", optional = true, features = ["bevy_egui"] }
bevy_panorbit_camera = { version = "0.26", optional = true, features = ["bevy_egui"] }
bevy_transform_gizmo = { version = "0.12", optional = true }
bevy_file_asset = { version = "0.1", optional = true }
bevy_web_asset = { version = "0.10", optional = true }
bevy_file_asset = { version = "0.2", optional = true }
bevy_web_asset = { version = "0.11", optional = true }
bincode2 = { version = "2.0", optional = true }
byte-unit = { version = "5.1", optional = true }
bytemuck = "1.21"
bytemuck = "1.23"
clap = { version = "4.5", features = ["derive"] }
flate2 = { version = "1.0", optional = true }
flexbuffers = { version = "24.12.23", optional = true }
half = { version = "2.3", features = ["serde"] }
image = { version = "0.25.5", default-features = false, features = ["png"] }
flate2 = { version = "1.1", optional = true }
flexbuffers = { version = "25.2", optional = true }
half = { version = "2.6", features = ["serde"] }
# image = { version = "0.25.6", default-features = false, features = ["png"] }
kd-tree = { version = "0.6", optional = true }
noise = { version = "0.9.0", optional = true }
ply-rs = { version = "0.1", optional = true }
Expand All @@ -178,8 +179,8 @@ rayon = { version = "1.8", optional = true }
serde = "1.0"
serde_json = "1.0"
static_assertions = "1.1"
typenum = "1.17"
wgpu = "23.0.1"
typenum = "1.18"
wgpu = "24"


[target.'cfg(target_arch = "wasm32")'.dependencies]
Expand All @@ -188,15 +189,17 @@ wasm-bindgen = "0.2"


[dependencies.bevy]
version = "0.15"
version = "0.16"
default-features = false
features = [
"bevy_asset",
"bevy_core_pipeline",
"bevy_log",
"bevy_pbr",
"bevy_render",
"bevy_winit",
"serialize",
"std",
"x11",
]

Expand Down
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,7 @@ the following tools are compatible with `bevy_gaussian_splatting`:

| `bevy_gaussian_splatting` | `bevy` |
| :-- | :-- |
| `5.0` | `0.16` |
| `3.0` | `0.15` |
| `2.3` | `0.14` |
| `2.1` | `0.13` |
Expand Down
23 changes: 11 additions & 12 deletions examples/headless.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
use bevy::{
prelude::*,
app::ScheduleRunnerPlugin,
core::Name,
core_pipeline::tonemapping::Tonemapping,
render::renderer::RenderDevice,
};
Expand Down Expand Up @@ -37,10 +36,10 @@ mod frame_capture {

use bevy::render::render_resource::{
Buffer, BufferDescriptor, BufferUsages, CommandEncoderDescriptor, Extent3d,
ImageCopyBuffer, ImageDataLayout, MapMode,
MapMode,
};
use pollster::FutureExt;
use wgpu::Maintain;
use wgpu::{Maintain, TexelCopyBufferInfo, TexelCopyBufferLayout};

use std::sync::atomic::{AtomicBool, Ordering};

Expand Down Expand Up @@ -68,7 +67,7 @@ mod frame_capture {
render_device.poll(Maintain::Wait);
rx.receive().await.unwrap().unwrap();
if let Some(image) = images.get_mut(&image_copier.dst_image) {
image.data = buffer_slice.get_mapped_range().to_vec();
image.data = buffer_slice.get_mapped_range().to_vec().into();
}

image_copier.buffer.unmap();
Expand Down Expand Up @@ -174,21 +173,21 @@ mod frame_capture {
let block_size = src_image.texture_format.block_copy_size(None).unwrap();

let padded_bytes_per_row = RenderDevice::align_copy_bytes_per_row(
(src_image.size.x as usize / block_dimensions.0 as usize)
(src_image.size.width as usize / block_dimensions.0 as usize)
* block_size as usize,
);

let texture_extent = Extent3d {
width: src_image.size.x as u32,
height: src_image.size.y as u32,
width: src_image.size.width as u32,
height: src_image.size.height as u32,
depth_or_array_layers: 1,
};

encoder.copy_texture_to_buffer(
src_image.texture.as_image_copy(),
ImageCopyBuffer {
TexelCopyBufferInfo {
buffer: &image_copier.buffer,
layout: ImageDataLayout {
layout: TexelCopyBufferLayout {
offset: 0,
bytes_per_row: Some(
std::num::NonZeroU32::new(padded_bytes_per_row as u32)
Expand Down Expand Up @@ -325,7 +324,7 @@ mod frame_capture {

scene_controller.state = SceneState::Render(pre_roll_frames);
scene_controller.name = scene_name;
RenderTarget::Image(render_target_image_handle)
RenderTarget::Image(render_target_image_handle.into())
}

fn update(
Expand Down Expand Up @@ -354,7 +353,7 @@ mod frame_capture {
};
}
if scene_controller.single_image {
app_exit_writer.send(AppExit::Success);
app_exit_writer.write(AppExit::Success);
}
} else {
scene_controller.state = SceneState::Render(n - 1);
Expand Down Expand Up @@ -448,7 +447,7 @@ fn headless_app() {
app.add_plugins(frame_capture::scene::CaptureFramePlugin);

app.add_plugins(ScheduleRunnerPlugin::run_loop(
std::time::Duration::from_secs_f64(1.0 / 60.0),
core::time::Duration::from_secs_f64(1.0 / 60.0),
));

// setup for gaussian splatting
Expand Down
10 changes: 7 additions & 3 deletions examples/multi_camera.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,10 @@ use bevy_args::{
BevyArgsPlugin,
parse_args,
};
use bevy_inspector_egui::quick::WorldInspectorPlugin;
use bevy_inspector_egui::{
bevy_egui::EguiPlugin,
quick::WorldInspectorPlugin,
};
use bevy_panorbit_camera::{
PanOrbitCamera,
PanOrbitCameraPlugin,
Expand Down Expand Up @@ -57,6 +60,7 @@ fn multi_camera_app() {
app.add_plugins(PanOrbitCameraPlugin);

if config.editor {
app.add_plugins(EguiPlugin { enable_multipass_for_primary_context: true });
app.add_plugins(WorldInspectorPlugin::new());
}

Expand Down Expand Up @@ -221,7 +225,7 @@ fn press_s_to_spawn_camera(
windows: Query<&Window>,
) {
if keys.just_pressed(KeyCode::KeyS) {
let window = windows.single();
let window = windows.single().unwrap();
let size = window.physical_size() / UVec2::new(2, 1);
let pos = UVec2::new(1, 0);

Expand Down Expand Up @@ -282,7 +286,7 @@ fn esc_close(
mut exit: EventWriter<AppExit>
) {
if keys.just_pressed(KeyCode::Escape) {
exit.send(AppExit::Success);
exit.write(AppExit::Success);
}
}

Expand Down
33 changes: 25 additions & 8 deletions src/gaussian/cloud.rs
Original file line number Diff line number Diff line change
@@ -1,11 +1,18 @@
use bevy::{
prelude::*,
ecs::{
component::HookContext,
world::DeferredWorld,
},
render::{
primitives::Aabb,
view::visibility::{
check_visibility,
NoFrustumCulling,
VisibilitySystems,
view::{
visibility::{
add_visibility_class,
NoFrustumCulling,
VisibilitySystems,
},
VisibilityClass,
},
},
};
Expand All @@ -15,21 +22,31 @@ use crate::gaussian::interface::CommonCloud;


#[derive(Default)]
pub struct CloudPlugin<R: PlanarStorage> {
pub struct CloudPlugin<R: PlanarSync> {
_phantom: std::marker::PhantomData<R>,
}

impl<R: PlanarStorage + Reflect + TypePath> Plugin for CloudPlugin<R>
pub struct CloudVisibilityClass;

fn add_planar_class(world: DeferredWorld, ctx: HookContext) {
add_visibility_class::<CloudVisibilityClass>(world, ctx);
}

impl<R: PlanarSync + Reflect + TypePath> Plugin for CloudPlugin<R>
where
R::PlanarType: CommonCloud,
R::PlanarTypeHandle: FromReflect + bevy::reflect::Typed,
{
fn build(&self, app: &mut App) {
app.register_required_components::<R::PlanarTypeHandle, VisibilityClass>();
app.world_mut()
.register_component_hooks::<R::PlanarTypeHandle>()
.on_add(add_planar_class);

app.add_systems(
PostUpdate,
(
calculate_bounds::<R>.in_set(VisibilitySystems::CalculateBounds),
check_visibility::<With<R::PlanarTypeHandle>>.in_set(VisibilitySystems::CheckVisibility),
)
);
}
Expand All @@ -38,7 +55,7 @@ where

// TODO: handle aabb updates (e.g. gaussian particle movements)
#[allow(clippy::type_complexity)]
pub fn calculate_bounds<R: PlanarStorage>(
pub fn calculate_bounds<R: PlanarSync>(
mut commands: Commands,
gaussian_clouds: Res<Assets<R::PlanarType>>,
without_aabb: Query<
Expand Down
2 changes: 1 addition & 1 deletion src/gaussian/formats/planar_3d.rs
Original file line number Diff line number Diff line change
Expand Up @@ -186,7 +186,7 @@ pub fn random_gaussians_3d(n: usize) -> PlanarGaussian3d {
let mut gaussians: Vec<Gaussian3d> = Vec::with_capacity(n);

for _ in 0..n {
gaussians.push(rng.gen());
gaussians.push(rng.r#gen());
}

PlanarGaussian3d::from_interleaved(gaussians)
Expand Down
2 changes: 1 addition & 1 deletion src/gaussian/formats/planar_4d.rs
Original file line number Diff line number Diff line change
Expand Up @@ -302,7 +302,7 @@ pub fn random_gaussians_4d(n: usize) -> PlanarGaussian4d {
let mut gaussians: Vec<Gaussian4d> = Vec::with_capacity(n);

for _ in 0..n {
gaussians.push(rng.gen());
gaussians.push(rng.r#gen());
}

PlanarGaussian4d::from_interleaved(gaussians)
Expand Down
8 changes: 2 additions & 6 deletions src/io/gcloud/flexbuffers.rs
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,7 @@ impl CloudCodec for PlanarGaussian3d {

fn decode(data: &[u8]) -> Self {
let reader = Reader::get_root(data).expect("failed to read flexbuffer");
let cloud = Self::deserialize(reader).expect("deserialization failed");

cloud
Self::deserialize(reader).expect("deserialization failed")
}
}

Expand All @@ -43,8 +41,6 @@ impl CloudCodec for PlanarGaussian4d {

fn decode(data: &[u8]) -> Self {
let reader = Reader::get_root(data).expect("failed to read flexbuffer");
let cloud = Self::deserialize(reader).expect("deserialization failed");

cloud
Self::deserialize(reader).expect("deserialization failed")
}
}
4 changes: 2 additions & 2 deletions src/material/classification.rs
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
use bevy::{
prelude::*,
asset::load_internal_asset,
asset::{load_internal_asset, weak_handle},
};


const CLASSIFICATION_SHADER_HANDLE: Handle<Shader> = Handle::weak_from_u128(61436234324);
const CLASSIFICATION_SHADER_HANDLE: Handle<Shader> = weak_handle!("8b453dba-5095-47f2-9c60-ae369fe51579");


pub struct ClassificationMaterialPlugin;
Expand Down
4 changes: 2 additions & 2 deletions src/material/depth.rs
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
use bevy::{
prelude::*,
asset::load_internal_asset,
asset::{load_internal_asset, weak_handle},
};


const DEPTH_SHADER_HANDLE: Handle<Shader> = Handle::weak_from_u128(51234253);
const DEPTH_SHADER_HANDLE: Handle<Shader> = weak_handle!("72e596c7-6226-4366-af26-2acceb34c8a4");


pub struct DepthMaterialPlugin;
Expand Down
4 changes: 2 additions & 2 deletions src/material/optical_flow.rs
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
use bevy::{
prelude::*,
asset::load_internal_asset,
asset::{load_internal_asset, weak_handle},
};


const OPTICAL_FLOW_SHADER_HANDLE: Handle<Shader> = Handle::weak_from_u128(1451151234);
const OPTICAL_FLOW_SHADER_HANDLE: Handle<Shader> = weak_handle!("e25fefbf-dd95-46f2-89bb-91175f6bb4a6");


pub struct OpticalFlowMaterialPlugin;
Expand Down
4 changes: 2 additions & 2 deletions src/material/position.rs
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
use bevy::{
prelude::*,
asset::load_internal_asset,
asset::{load_internal_asset, weak_handle},
};


const POSITION_SHADER_HANDLE: Handle<Shader> = Handle::weak_from_u128(62346645534);
const POSITION_SHADER_HANDLE: Handle<Shader> = weak_handle!("91ad4ad8-5e95-4f30-a262-7d3de4abd5a8");


pub struct PositionMaterialPlugin;
Expand Down
4 changes: 2 additions & 2 deletions src/material/spherical_harmonics.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ use std::marker::Copy;

use bevy::{
prelude::*,
asset::load_internal_asset,
asset::{load_internal_asset, weak_handle},
render::render_resource::ShaderType,
};
use bytemuck::{
Expand All @@ -22,7 +22,7 @@ use serde::{
use crate::math::pad_4;


const SPHERICAL_HARMONICS_SHADER_HANDLE: Handle<Shader> = Handle::weak_from_u128(834667312);
const SPHERICAL_HARMONICS_SHADER_HANDLE: Handle<Shader> = weak_handle!("879b9cd3-ba20-4030-a8f3-adda0a042ffe");


pub struct SphericalHarmonicCoefficientsPlugin;
Expand Down
Loading