From cb83bb1ae3c03fddf67dbdc9d655b2602fe177b9 Mon Sep 17 00:00:00 2001 From: Aevyrie Date: Mon, 10 Jul 2023 23:08:54 -0700 Subject: [PATCH 1/3] v0.7 --- Cargo.toml | 8 ++++---- README.md | 1 + src/polyline.rs | 5 +++-- 3 files changed, 8 insertions(+), 6 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index 0bfc918..6fc1046 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,7 +1,7 @@ [package] edition = "2021" name = "bevy_polyline" -version = "0.6.0" +version = "0.7.0" description = "Polyline Rendering for Bevy" license = "MIT OR Apache-2.0" repository = "https://github.com/ForesightMiningSoftwareCorporation/bevy_polyline" @@ -17,7 +17,7 @@ authors = [ ] [dependencies] -bitflags = "1.3" +bitflags = "2.3" bevy = { version = "0.11.0", default-features = false, features = [ "bevy_core_pipeline", "bevy_render", @@ -27,12 +27,12 @@ bevy = { version = "0.11.0", default-features = false, features = [ [dependencies.naga] features = ["glsl-in", "spv-out", "wgsl-out"] -version = "0.11" +version = "0.12" [dev-dependencies] lazy_static = "1.4.0" rand = "0.8.4" -ringbuffer = "0.12" +ringbuffer = "0.14" bevy = { version = "0.11.0", default-features = false, features = [ "bevy_winit", "x11", diff --git a/README.md b/README.md index a7dc1d3..251d9d7 100644 --- a/README.md +++ b/README.md @@ -47,6 +47,7 @@ We intend to track the `main` branch of Bevy. PRs supporting this are welcome! | bevy | bevy_polyline | | ---- | ------------- | +| 0.11 | 0.7 | | 0.10 | 0.5, 0.6 | | 0.9 | 0.4 | | 0.8 | 0.3 | diff --git a/src/polyline.rs b/src/polyline.rs index fb5885b..4d30181 100644 --- a/src/polyline.rs +++ b/src/polyline.rs @@ -300,6 +300,7 @@ impl SpecializedRenderPipeline for PolylinePipeline { bitflags::bitflags! { #[repr(transparent)] + #[derive(PartialEq, Eq, PartialOrd, Ord, Hash, Debug, Clone, Copy)] // NOTE: Apparently quadro drivers support up to 64x MSAA. // MSAA uses the highest 3 bits for the MSAA log2(sample count) to support up to 128x MSAA. pub struct PolylinePipelineKey: u32 { @@ -318,11 +319,11 @@ impl PolylinePipelineKey { pub fn from_msaa_samples(msaa_samples: u32) -> Self { let msaa_bits = (msaa_samples.trailing_zeros() & Self::MSAA_MASK_BITS) << Self::MSAA_SHIFT_BITS; - Self::from_bits(msaa_bits).unwrap() + Self::from_bits_retain(msaa_bits) } pub fn msaa_samples(&self) -> u32 { - 1 << ((self.bits >> Self::MSAA_SHIFT_BITS) & Self::MSAA_MASK_BITS) + 1 << ((self.bits() >> Self::MSAA_SHIFT_BITS) & Self::MSAA_MASK_BITS) } pub fn from_hdr(hdr: bool) -> Self { From 77d4136b5a8964027ade7102b8888e10c4e9b30d Mon Sep 17 00:00:00 2001 From: Aevyrie Date: Mon, 10 Jul 2023 23:47:26 -0700 Subject: [PATCH 2/3] remove pbr deps --- src/polyline.rs | 69 +++++-------------------------------------------- 1 file changed, 7 insertions(+), 62 deletions(-) diff --git a/src/polyline.rs b/src/polyline.rs index 4d30181..add93fe 100644 --- a/src/polyline.rs +++ b/src/polyline.rs @@ -8,7 +8,6 @@ use bevy::{ SystemParamItem, }, }, - pbr::{GlobalLightMeta, LightMeta, ViewClusterBindings, ViewShadowBindings}, prelude::*, reflect::{TypePath, TypeUuid}, render::{ @@ -370,70 +369,16 @@ pub fn queue_polyline_view_bind_groups( mut commands: Commands, render_device: Res, polyline_pipeline: Res, - light_meta: Res, - global_light_meta: Res, view_uniforms: Res, - views: Query<(Entity, &ViewShadowBindings, &ViewClusterBindings)>, + views: Query>, ) { - if let (Some(view_binding), Some(_light_binding), Some(_point_light_binding)) = ( - view_uniforms.uniforms.binding(), - light_meta.view_gpu_lights.binding(), - global_light_meta.gpu_point_lights.binding(), - ) { - for (entity, _view_shadow_bindings, _view_cluster_bindings) in views.iter() { + if let Some(view_binding) = view_uniforms.uniforms.binding() { + for entity in views.iter() { let view_bind_group = render_device.create_bind_group(&BindGroupDescriptor { - entries: &[ - BindGroupEntry { - binding: 0, - resource: view_binding.clone(), - }, - /* Can add these bindings in the future if needed - BindGroupEntry { - binding: 1, - resource: light_binding.clone(), - }, - BindGroupEntry { - binding: 2, - resource: BindingResource::TextureView( - &view_shadow_bindings.point_light_depth_texture_view, - ), - }, - BindGroupEntry { - binding: 3, - resource: BindingResource::Sampler(&shadow_pipeline.point_light_sampler), - }, - BindGroupEntry { - binding: 4, - resource: BindingResource::TextureView( - &view_shadow_bindings.directional_light_depth_texture_view, - ), - }, - BindGroupEntry { - binding: 5, - resource: BindingResource::Sampler( - &shadow_pipeline.directional_light_sampler, - ), - }, - BindGroupEntry { - binding: 6, - resource: point_light_binding.clone(), - }, - BindGroupEntry { - binding: 7, - resource: view_cluster_bindings - .cluster_light_index_lists - .binding() - .unwrap(), - }, - BindGroupEntry { - binding: 8, - resource: view_cluster_bindings - .cluster_offsets_and_counts - .binding() - .unwrap(), - }, - */ - ], + entries: &[BindGroupEntry { + binding: 0, + resource: view_binding.clone(), + }], label: Some("polyline_view_bind_group"), layout: &polyline_pipeline.view_layout, }); From 9f8c72a7381d5924d551089678a96e61b9ce30b7 Mon Sep 17 00:00:00 2001 From: Aevyrie Date: Mon, 10 Jul 2023 23:55:41 -0700 Subject: [PATCH 3/3] completely remove `bevy_pbr` dependencies --- Cargo.toml | 2 +- src/material.rs | 48 ++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 49 insertions(+), 1 deletion(-) diff --git a/Cargo.toml b/Cargo.toml index 6fc1046..e8fa50b 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -21,7 +21,6 @@ bitflags = "2.3" bevy = { version = "0.11.0", default-features = false, features = [ "bevy_core_pipeline", "bevy_render", - "bevy_pbr", "bevy_asset", ] } @@ -35,6 +34,7 @@ rand = "0.8.4" ringbuffer = "0.14" bevy = { version = "0.11.0", default-features = false, features = [ "bevy_winit", + "bevy_pbr", "x11", "tonemapping_luts", "ktx2", diff --git a/src/material.rs b/src/material.rs index 5b8aaff..ed9eab2 100644 --- a/src/material.rs +++ b/src/material.rs @@ -393,3 +393,51 @@ pub fn queue_material_polylines( } } } + +/// Sets how a material's base color alpha channel is used for transparency. +#[derive(Debug, Default, Reflect, Copy, Clone, PartialEq)] +#[reflect(Default, Debug)] +pub enum AlphaMode { + /// Base color alpha values are overridden to be fully opaque (1.0). + #[default] + Opaque, + /// Reduce transparency to fully opaque or fully transparent + /// based on a threshold. + /// + /// Compares the base color alpha value to the specified threshold. + /// If the value is below the threshold, + /// considers the color to be fully transparent (alpha is set to 0.0). + /// If it is equal to or above the threshold, + /// considers the color to be fully opaque (alpha is set to 1.0). + Mask(f32), + /// The base color alpha value defines the opacity of the color. + /// Standard alpha-blending is used to blend the fragment's color + /// with the color behind it. + Blend, + /// Similar to [`AlphaMode::Blend`], however assumes RGB channel values are + /// [premultiplied](https://en.wikipedia.org/wiki/Alpha_compositing#Straight_versus_premultiplied). + /// + /// For otherwise constant RGB values, behaves more like [`AlphaMode::Blend`] for + /// alpha values closer to 1.0, and more like [`AlphaMode::Add`] for + /// alpha values closer to 0.0. + /// + /// Can be used to avoid “border” or “outline” artifacts that can occur + /// when using plain alpha-blended textures. + Premultiplied, + /// Combines the color of the fragments with the colors behind them in an + /// additive process, (i.e. like light) producing lighter results. + /// + /// Black produces no effect. Alpha values can be used to modulate the result. + /// + /// Useful for effects like holograms, ghosts, lasers and other energy beams. + Add, + /// Combines the color of the fragments with the colors behind them in a + /// multiplicative process, (i.e. like pigments) producing darker results. + /// + /// White produces no effect. Alpha values can be used to modulate the result. + /// + /// Useful for effects like stained glass, window tint film and some colored liquids. + Multiply, +} + +impl Eq for AlphaMode {}