diff --git a/examples/dynamic_shape.rs b/examples/dynamic_shape.rs index 3d38831..2895091 100644 --- a/examples/dynamic_shape.rs +++ b/examples/dynamic_shape.rs @@ -63,7 +63,7 @@ fn setup_system(mut commands: Commands) { ..shapes::RegularPolygon::default() }; - commands.spawn_bundle(OrthographicCameraBundle::new_2d()); + commands.spawn_bundle(Camera2dBundle::default()); commands .spawn_bundle(GeometryBuilder::build_as( &shape, diff --git a/examples/path.rs b/examples/path.rs index 62eebf0..5dd2336 100644 --- a/examples/path.rs +++ b/examples/path.rs @@ -16,7 +16,7 @@ fn setup_system(mut commands: Commands) { path_builder.line_to(100.0 * Vec2::ONE); let line = path_builder.build(); - commands.spawn_bundle(OrthographicCameraBundle::new_2d()); + commands.spawn_bundle(Camera2dBundle::default()); commands.spawn_bundle(GeometryBuilder::build_as( &line, DrawMode::Stroke(StrokeMode::new(Color::BLACK, 10.0)), diff --git a/examples/readme.rs b/examples/readme.rs index 60dc36f..a9d71c9 100644 --- a/examples/readme.rs +++ b/examples/readme.rs @@ -20,7 +20,7 @@ fn setup_system(mut commands: Commands) { ..shapes::RegularPolygon::default() }; - commands.spawn_bundle(OrthographicCameraBundle::new_2d()); + commands.spawn_bundle(Camera2dBundle::default()); commands.spawn_bundle(GeometryBuilder::build_as( &shape, DrawMode::Outlined { diff --git a/examples/svg.rs b/examples/svg.rs index cb4e6cf..81edb0b 100644 --- a/examples/svg.rs +++ b/examples/svg.rs @@ -27,7 +27,7 @@ struct BuildingBundle { global_transform: GlobalTransform, } fn setup_system(mut commands: Commands) { - commands.spawn_bundle(OrthographicCameraBundle::new_2d()); + commands.spawn_bundle(Camera2dBundle::default()); commands.spawn_bundle(BuildingBundle { name: Name("Blacksmith".to_owned()), diff --git a/src/plugin.rs b/src/plugin.rs index 4b3280d..8dd7e15 100644 --- a/src/plugin.rs +++ b/src/plugin.rs @@ -144,7 +144,7 @@ fn build_mesh(buffers: &VertexBuffers) -> Mesh { .vertices .iter() .map(|v| v.color) - .collect::>(), + .collect::>(), ); mesh diff --git a/src/render/mod.rs b/src/render/mod.rs index d00df33..8ac5f93 100644 --- a/src/render/mod.rs +++ b/src/render/mod.rs @@ -3,7 +3,7 @@ use bevy::{ app::{App, Plugin}, asset::{Assets, HandleUntyped}, - core_pipeline::Transparent2d, + core_pipeline::core_2d::Transparent2d, ecs::{ component::Component, entity::Entity, @@ -64,7 +64,7 @@ impl SpecializedRenderPipeline for ShapePipeline { // Position VertexFormat::Float32x3, // Color - VertexFormat::Uint32, + VertexFormat::Float32x4, ]; let vertex_layout = diff --git a/src/render/shape.wgsl b/src/render/shape.wgsl index f08a0dd..c451782 100644 --- a/src/render/shape.wgsl +++ b/src/render/shape.wgsl @@ -1,14 +1,14 @@ // Import the standard 2d mesh uniforms and set their bind groups -#import bevy_sprite::mesh2d_view_bind_group -[[group(0), binding(0)]] -var view: View; -#import bevy_sprite::mesh2d_struct +#import bevy_sprite::mesh2d_view_bindings +//[[group(0), binding(0)]] +//var view: View; +#import bevy_sprite::mesh2d_types [[group(1), binding(0)]] var mesh: Mesh2d; // The structure of the vertex buffer is as specified in `specialize()` struct Vertex { [[location(0)]] position: vec3; - [[location(1)]] color: u32; + [[location(1)]] color: vec4; }; struct VertexOutput { // The vertex shader must set the on-screen position of the vertex @@ -22,7 +22,7 @@ fn vertex(vertex: Vertex) -> VertexOutput { var out: VertexOutput; // Project the world position of the mesh into screen position out.clip_position = view.view_proj * mesh.model * vec4(vertex.position, 1.0); - out.color = vec4((vec4(vertex.color) >> vec4(0u, 8u, 16u, 24u)) & vec4(255u)) / 255.0; + out.color = vertex.color; return out; } // The input of the fragment shader must correspond to the output of the vertex shader for all `location`s diff --git a/src/vertex.rs b/src/vertex.rs index 2d8dc12..4c9e178 100644 --- a/src/vertex.rs +++ b/src/vertex.rs @@ -13,7 +13,7 @@ pub type VertexBuffers = tess::VertexBuffers; #[derive(Debug, Clone, Copy, PartialEq)] pub struct Vertex { pub position: [f32; 2], - pub color: u32, + pub color: [f32; 4], } /// Zero-sized type used to implement various vertex construction traits from @@ -27,7 +27,7 @@ impl FillVertexConstructor for VertexConstructor { fn new_vertex(&mut self, vertex: FillVertex) -> Vertex { Vertex { position: [vertex.position().x, vertex.position().y], - color: self.color.as_linear_rgba_u32(), + color: self.color.as_linear_rgba_f32(), } } } @@ -37,7 +37,7 @@ impl StrokeVertexConstructor for VertexConstructor { fn new_vertex(&mut self, vertex: StrokeVertex) -> Vertex { Vertex { position: [vertex.position().x, vertex.position().y], - color: self.color.as_linear_rgba_u32(), + color: self.color.as_linear_rgba_f32(), } } }