aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorLibravatar Silas Bartha <silas@exvacuum.dev>2024-06-04 13:01:27 -0400
committerLibravatar Silas Bartha <silas@exvacuum.dev>2024-06-04 13:01:27 -0400
commitd98878f3135bffb412dce9436c3b81cbe595a7a9 (patch)
tree05ea73f265236ebce4370ecbfd3efd268ddb07ec /src
parenta294ec442b91e1006a28049cda9fcb82b52d0dc0 (diff)
Removed toolchain config
Diffstat (limited to 'src')
-rw-r--r--src/components.rs7
-rw-r--r--src/lib.rs41
-rw-r--r--src/nodes.rs19
-rw-r--r--src/resources.rs67
4 files changed, 91 insertions, 43 deletions
diff --git a/src/components.rs b/src/components.rs
index 837ccd9..cc6c471 100644
--- a/src/components.rs
+++ b/src/components.rs
@@ -1,9 +1,10 @@
-use bevy::{prelude::*, render::{render_resource::ShaderType, extract_component::ExtractComponent}};
+use bevy::{
+ prelude::*,
+ render::{extract_component::ExtractComponent, render_resource::ShaderType},
+};
#[derive(Component, ShaderType, ExtractComponent, PartialEq, Clone, Default)]
pub struct OutlinePostProcessSettings {
pub weight: f32,
pub threshold: f32,
- #[cfg(feature = "webgl2")]
- _padding: Vec2,
}
diff --git a/src/lib.rs b/src/lib.rs
index 12dd5bb..144dfe8 100644
--- a/src/lib.rs
+++ b/src/lib.rs
@@ -1,12 +1,23 @@
-use bevy::{prelude::*, render::{RenderApp, extract_component::{UniformComponentPlugin, ExtractComponentPlugin}, render_graph::{RenderGraphApp, ViewNodeRunner}}, asset::embedded_asset, core_pipeline::core_3d::graph::{Core3d, Node3d}};
+#![warn(missing_docs)]
+
+use bevy::{
+ asset::embedded_asset,
+ core_pipeline::core_3d::graph::{Core3d, Node3d},
+ prelude::*,
+ render::{
+ extract_component::{ExtractComponentPlugin, UniformComponentPlugin},
+ render_graph::{RenderGraphApp, ViewNodeRunner},
+ RenderApp,
+ },
+};
pub use nodes::OutlineRenderLabel;
pub struct OutlinePostProcessPlugin;
pub mod components;
-mod resources;
mod nodes;
+mod resources;
impl Plugin for OutlinePostProcessPlugin {
fn build(&self, app: &mut App) {
@@ -16,24 +27,26 @@ impl Plugin for OutlinePostProcessPlugin {
UniformComponentPlugin::<components::OutlinePostProcessSettings>::default(),
ExtractComponentPlugin::<components::OutlinePostProcessSettings>::default(),
));
-
+
let Ok(render_app) = app.get_sub_app_mut(RenderApp) else {
return;
};
- render_app.add_render_graph_node::<ViewNodeRunner<nodes::OutlineRenderNode>>(
- Core3d,
- nodes::OutlineRenderLabel,
- ).add_render_graph_edges(
- Core3d,
- (
- Node3d::Tonemapping,
+ render_app
+ .add_render_graph_node::<ViewNodeRunner<nodes::OutlineRenderNode>>(
+ Core3d,
nodes::OutlineRenderLabel,
- Node3d::EndMainPassPostProcessing,
- ),
- );
+ )
+ .add_render_graph_edges(
+ Core3d,
+ (
+ Node3d::Tonemapping,
+ nodes::OutlineRenderLabel,
+ Node3d::EndMainPassPostProcessing,
+ ),
+ );
}
-
+
fn finish(&self, app: &mut App) {
let Ok(render_app) = app.get_sub_app_mut(RenderApp) else {
return;
diff --git a/src/nodes.rs b/src/nodes.rs
index 56769e1..292c16d 100644
--- a/src/nodes.rs
+++ b/src/nodes.rs
@@ -1,4 +1,18 @@
-use bevy::{prelude::*, render::{render_graph::{ViewNode, NodeRunError, RenderGraphContext, RenderLabel}, view::ViewTarget, renderer::RenderContext, render_resource::{PipelineCache, BindGroupEntries, RenderPassDescriptor, RenderPassColorAttachment, Operations}, extract_component::ComponentUniforms}, core_pipeline::prepass::ViewPrepassTextures, ecs::query::QueryItem};
+use bevy::{
+ core_pipeline::prepass::ViewPrepassTextures,
+ ecs::query::QueryItem,
+ prelude::*,
+ render::{
+ extract_component::ComponentUniforms,
+ render_graph::{NodeRunError, RenderGraphContext, RenderLabel, ViewNode},
+ render_resource::{
+ BindGroupEntries, Operations, PipelineCache, RenderPassColorAttachment,
+ RenderPassDescriptor,
+ },
+ renderer::RenderContext,
+ view::ViewTarget,
+ },
+};
use super::components;
use super::resources;
@@ -30,7 +44,8 @@ impl ViewNode for OutlineRenderNode {
return Ok(());
};
- let uniforms = world.resource::<ComponentUniforms<components::OutlinePostProcessSettings>>();
+ let uniforms =
+ world.resource::<ComponentUniforms<components::OutlinePostProcessSettings>>();
let Some(uniform_binding) = uniforms.uniforms().binding() else {
error!("Failed to get settings uniform binding");
return Ok(());
diff --git a/src/resources.rs b/src/resources.rs
index d755dc2..24aeeec 100644
--- a/src/resources.rs
+++ b/src/resources.rs
@@ -1,4 +1,18 @@
-use bevy::{prelude::*, render::{render_resource::{Sampler, BindGroupLayout, BindGroupLayoutEntries, ShaderStages, binding_types::{texture_2d, sampler, uniform_buffer}, TextureSampleType, SamplerBindingType, SamplerDescriptor, PipelineCache, RenderPipelineDescriptor, CachedRenderPipelineId, PrimitiveState, MultisampleState, FragmentState, ColorTargetState, TextureFormat, ColorWrites}, renderer::RenderDevice, texture::BevyDefault}, core_pipeline::fullscreen_vertex_shader::fullscreen_shader_vertex_state};
+use bevy::{
+ core_pipeline::fullscreen_vertex_shader::fullscreen_shader_vertex_state,
+ prelude::*,
+ render::{
+ render_resource::{
+ binding_types::{sampler, texture_2d, uniform_buffer},
+ BindGroupLayout, BindGroupLayoutEntries, CachedRenderPipelineId, ColorTargetState,
+ ColorWrites, FragmentState, MultisampleState, PipelineCache, PrimitiveState,
+ RenderPipelineDescriptor, Sampler, SamplerBindingType, SamplerDescriptor, ShaderStages,
+ TextureFormat, TextureSampleType,
+ },
+ renderer::RenderDevice,
+ texture::BevyDefault,
+ },
+};
use super::components;
@@ -19,9 +33,9 @@ impl FromWorld for OutlinePostProcessPipeline {
&BindGroupLayoutEntries::sequential(
ShaderStages::FRAGMENT,
(
- texture_2d(TextureSampleType::Float{ filterable: true }),
+ texture_2d(TextureSampleType::Float { filterable: true }),
sampler(SamplerBindingType::Filtering),
- texture_2d(TextureSampleType::Float{ filterable: true }),
+ texture_2d(TextureSampleType::Float { filterable: true }),
sampler(SamplerBindingType::Filtering),
uniform_buffer::<components::OutlinePostProcessSettings>(false),
),
@@ -31,27 +45,32 @@ impl FromWorld for OutlinePostProcessPipeline {
let screen_sampler = render_device.create_sampler(&SamplerDescriptor::default());
let normal_sampler = render_device.create_sampler(&SamplerDescriptor::default());
- let shader = world.resource::<AssetServer>().load::<Shader>("embedded://grex_outline_post_process/../assets/shaders/outline_post_process.wgsl");
-
- let pipeline_id = world.resource_mut::<PipelineCache>().queue_render_pipeline(RenderPipelineDescriptor {
- label: Some("outline_post_process_render_pipeline".into()),
- layout: vec![layout.clone()],
- push_constant_ranges: vec![],
- vertex: fullscreen_shader_vertex_state(),
- primitive: PrimitiveState::default(),
- depth_stencil: None,
- multisample: MultisampleState::default(),
- fragment: Some(FragmentState {
- shader,
- shader_defs: vec![],
- entry_point: "fragment".into(),
- targets: vec![Some(ColorTargetState {
- format: TextureFormat::bevy_default(),
- blend: None,
- write_mask: ColorWrites::ALL,
- })],
- }),
- });
+ let shader = world.resource::<AssetServer>().load::<Shader>(
+ "embedded://bevy_outline_post_process/../assets/shaders/outline_post_process.wgsl",
+ );
+
+ let pipeline_id =
+ world
+ .resource_mut::<PipelineCache>()
+ .queue_render_pipeline(RenderPipelineDescriptor {
+ label: Some("outline_post_process_render_pipeline".into()),
+ layout: vec![layout.clone()],
+ push_constant_ranges: vec![],
+ vertex: fullscreen_shader_vertex_state(),
+ primitive: PrimitiveState::default(),
+ depth_stencil: None,
+ multisample: MultisampleState::default(),
+ fragment: Some(FragmentState {
+ shader,
+ shader_defs: vec![],
+ entry_point: "fragment".into(),
+ targets: vec![Some(ColorTargetState {
+ format: TextureFormat::bevy_default(),
+ blend: None,
+ write_mask: ColorWrites::ALL,
+ })],
+ }),
+ });
Self {
layout,