Skip to content

Commit 832727c

Browse files
committed
bump to 2.1 with shader used internally
1 parent 9c620ae commit 832727c

File tree

5 files changed

+19
-10
lines changed

5 files changed

+19
-10
lines changed

Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[package]
22
name = "bevy_voxel_plot"
3-
version = "2.0.1"
3+
version = "2.1.0"
44
edition = "2021"
55
authors = ["Linus Leo Stöckli"]
66
repository = "https://github.com/hacknus/bevy_voxel_plot"

README.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,8 @@ low alpha.
4343
| 0.16 | 2.0 |
4444
| 0.15 | 1.0 |
4545

46+
Note: version 1.0 requires the shader to be copied in your directory (did only fix that from 2.1+ )
47+
4648
## Credits
4749

4850
- [Bevy](https://bevyengine.org)

examples/bevy_egui.rs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -292,7 +292,9 @@ fn main() {
292292
App::new()
293293
.add_plugins((
294294
DefaultPlugins,
295-
EguiPlugin { enable_multipass_for_primary_context: false },
295+
EguiPlugin {
296+
enable_multipass_for_primary_context: false,
297+
},
296298
VoxelMaterialPlugin,
297299
PanOrbitCameraPlugin,
298300
))

examples/bevy_pointcloud_bunny.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -49,11 +49,11 @@ fn load_pcd_file(path: &Path) -> (Vec<InstanceData>, f32, f32, f32) {
4949
let y: f32 = parts[1].parse().unwrap_or(0.0);
5050
let z: f32 = parts[2].parse().unwrap_or(0.0);
5151

52-
let (r,g,b) = jet_colormap(z*10.0);
52+
let (r, g, b) = jet_colormap(z * 10.0);
5353

5454
let instance = InstanceData {
5555
pos_scale: [x, y, z, 1.0], // position + uniform scale
56-
color: LinearRgba::from(Color::srgba(r,g,b, 0.01)).to_f32_array(), // you can set color later if needed
56+
color: LinearRgba::from(Color::srgba(r, g, b, 0.01)).to_f32_array(), // you can set color later if needed
5757
};
5858

5959
instances.push(instance);

src/bevy_voxel_plot.rs

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
//! implementation using Bevy's low level rendering API.
88
//! It's generally recommended to try the built-in instancing before going with this approach.
99
10+
use bevy::asset::{load_internal_asset, weak_handle};
1011
use bevy::{
1112
core_pipeline::core_3d::Transparent3d,
1213
ecs::{
@@ -36,9 +37,6 @@ use bevy::{
3637
};
3738
use bytemuck::{Pod, Zeroable};
3839

39-
/// Path to the WGSL shader asset used for custom instancing rendering.
40-
const SHADER_ASSET_PATH: &str = "shaders/instancing.wgsl";
41-
4240
/// Component holding per-instance data for custom rendering.
4341
#[derive(Component)]
4442
pub struct InstanceMaterialData {
@@ -61,6 +59,7 @@ impl ExtractComponent for InstanceMaterialData {
6159
/// Plugin that sets up the custom voxel material pipeline.
6260
pub struct VoxelMaterialPlugin;
6361

62+
pub const SHADER_HANDLE: Handle<Shader> = weak_handle!("123e4567-e89b-12d3-a456-426614174000");
6463
impl Plugin for VoxelMaterialPlugin {
6564
fn build(&self, app: &mut App) {
6665
app.add_plugins(ExtractComponentPlugin::<InstanceMaterialData>::default());
@@ -74,6 +73,12 @@ impl Plugin for VoxelMaterialPlugin {
7473
prepare_instance_buffers.in_set(RenderSet::PrepareResources),
7574
),
7675
);
76+
load_internal_asset!(
77+
app,
78+
SHADER_HANDLE,
79+
"../assets/shaders/instancing.wgsl",
80+
Shader::from_wgsl
81+
);
7782
}
7883

7984
fn finish(&self, app: &mut App) {
@@ -206,11 +211,11 @@ struct CustomPipeline {
206211

207212
impl FromWorld for CustomPipeline {
208213
fn from_world(world: &mut World) -> Self {
209-
let mesh_pipeline = world.resource::<MeshPipeline>();
214+
let mesh_pipeline = world.resource::<MeshPipeline>().clone();
210215

211216
CustomPipeline {
212-
shader: world.load_asset(SHADER_ASSET_PATH),
213-
mesh_pipeline: mesh_pipeline.clone(),
217+
shader: SHADER_HANDLE.clone(),
218+
mesh_pipeline,
214219
}
215220
}
216221
}

0 commit comments

Comments
 (0)