Compare commits
No commits in common. "master" and "v0.5.0" have entirely different histories.
@ -1,2 +0,0 @@
|
|||||||
[profile.dev.package."*"]
|
|
||||||
opt-level = 2
|
|
@ -1,25 +0,0 @@
|
|||||||
name: Build
|
|
||||||
on: [push]
|
|
||||||
|
|
||||||
jobs:
|
|
||||||
Build:
|
|
||||||
env:
|
|
||||||
RUNNER_TOOL_CACHE: /toolcache
|
|
||||||
container: rust:alpine
|
|
||||||
steps:
|
|
||||||
- name: Install node
|
|
||||||
run: apk add nodejs gcc libc-dev pkgconf libx11-dev alsa-lib-dev eudev-dev tar
|
|
||||||
- name: Check out repository code
|
|
||||||
uses: actions/checkout@v4
|
|
||||||
- name: Restore cache
|
|
||||||
uses: actions/cache@v4
|
|
||||||
with:
|
|
||||||
path: |
|
|
||||||
~/.cargo/bin/
|
|
||||||
~/.cargo/registry/index/
|
|
||||||
~/.cargo/registry/cache/
|
|
||||||
~/.cargo/git/db/
|
|
||||||
target/
|
|
||||||
key: ${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.lock') }}
|
|
||||||
- name: Build
|
|
||||||
run: cargo build --release
|
|
58
Cargo.lock
generated
58
Cargo.lock
generated
@ -572,7 +572,7 @@ dependencies = [
|
|||||||
"bevy_reflect",
|
"bevy_reflect",
|
||||||
"derive_more",
|
"derive_more",
|
||||||
"glam",
|
"glam",
|
||||||
"itertools",
|
"itertools 0.13.0",
|
||||||
"rand",
|
"rand",
|
||||||
"rand_distr",
|
"rand_distr",
|
||||||
"serde",
|
"serde",
|
||||||
@ -613,7 +613,7 @@ dependencies = [
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "bevy_outline_post_process"
|
name = "bevy_outline_post_process"
|
||||||
version = "0.5.0"
|
version = "0.4.0"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"bevy",
|
"bevy",
|
||||||
]
|
]
|
||||||
@ -829,7 +829,7 @@ dependencies = [
|
|||||||
"bitflags 2.6.0",
|
"bitflags 2.6.0",
|
||||||
"cexpr",
|
"cexpr",
|
||||||
"clang-sys",
|
"clang-sys",
|
||||||
"itertools",
|
"itertools 0.12.1",
|
||||||
"log",
|
"log",
|
||||||
"prettyplease",
|
"prettyplease",
|
||||||
"proc-macro2",
|
"proc-macro2",
|
||||||
@ -1515,7 +1515,7 @@ dependencies = [
|
|||||||
"log",
|
"log",
|
||||||
"presser",
|
"presser",
|
||||||
"thiserror",
|
"thiserror",
|
||||||
"windows",
|
"windows 0.54.0",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
@ -1587,6 +1587,15 @@ dependencies = [
|
|||||||
"hashbrown",
|
"hashbrown",
|
||||||
]
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "itertools"
|
||||||
|
version = "0.12.1"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "ba291022dbbd398a455acf126c1e341954079855bc60dfdda641363bd6922569"
|
||||||
|
dependencies = [
|
||||||
|
"either",
|
||||||
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "itertools"
|
name = "itertools"
|
||||||
version = "0.13.0"
|
version = "0.13.0"
|
||||||
@ -1673,7 +1682,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
|
|||||||
checksum = "0c2a198fb6b0eada2a8df47933734e6d35d350665a33a3593d7164fa52c75c19"
|
checksum = "0c2a198fb6b0eada2a8df47933734e6d35d350665a33a3593d7164fa52c75c19"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"cfg-if",
|
"cfg-if",
|
||||||
"windows-targets 0.52.6",
|
"windows-targets 0.48.5",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
@ -2766,8 +2775,8 @@ dependencies = [
|
|||||||
"wasm-bindgen",
|
"wasm-bindgen",
|
||||||
"web-sys",
|
"web-sys",
|
||||||
"wgpu-types",
|
"wgpu-types",
|
||||||
"windows",
|
"windows 0.58.0",
|
||||||
"windows-core",
|
"windows-core 0.58.0",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
@ -2812,13 +2821,33 @@ version = "0.4.0"
|
|||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "712e227841d057c1ee1cd2fb22fa7e5a5461ae8e48fa2ca79ec42cfc1931183f"
|
checksum = "712e227841d057c1ee1cd2fb22fa7e5a5461ae8e48fa2ca79ec42cfc1931183f"
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "windows"
|
||||||
|
version = "0.54.0"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "9252e5725dbed82865af151df558e754e4a3c2c30818359eb17465f1346a1b49"
|
||||||
|
dependencies = [
|
||||||
|
"windows-core 0.54.0",
|
||||||
|
"windows-targets 0.52.6",
|
||||||
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "windows"
|
name = "windows"
|
||||||
version = "0.58.0"
|
version = "0.58.0"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "dd04d41d93c4992d421894c18c8b43496aa748dd4c081bac0dc93eb0489272b6"
|
checksum = "dd04d41d93c4992d421894c18c8b43496aa748dd4c081bac0dc93eb0489272b6"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"windows-core",
|
"windows-core 0.58.0",
|
||||||
|
"windows-targets 0.52.6",
|
||||||
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "windows-core"
|
||||||
|
version = "0.54.0"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "12661b9c89351d684a50a8a643ce5f608e20243b9fb84687800163429f161d65"
|
||||||
|
dependencies = [
|
||||||
|
"windows-result 0.1.1",
|
||||||
"windows-targets 0.52.6",
|
"windows-targets 0.52.6",
|
||||||
]
|
]
|
||||||
|
|
||||||
@ -2830,7 +2859,7 @@ checksum = "6ba6d44ec8c2591c134257ce647b7ea6b20335bf6379a27dac5f1641fcf59f99"
|
|||||||
dependencies = [
|
dependencies = [
|
||||||
"windows-implement",
|
"windows-implement",
|
||||||
"windows-interface",
|
"windows-interface",
|
||||||
"windows-result",
|
"windows-result 0.2.0",
|
||||||
"windows-strings",
|
"windows-strings",
|
||||||
"windows-targets 0.52.6",
|
"windows-targets 0.52.6",
|
||||||
]
|
]
|
||||||
@ -2857,6 +2886,15 @@ dependencies = [
|
|||||||
"syn",
|
"syn",
|
||||||
]
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "windows-result"
|
||||||
|
version = "0.1.1"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "749f0da9cc72d82e600d8d2e44cadd0b9eedb9038f71a1c58556ac1c5791813b"
|
||||||
|
dependencies = [
|
||||||
|
"windows-targets 0.52.6",
|
||||||
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "windows-result"
|
name = "windows-result"
|
||||||
version = "0.2.0"
|
version = "0.2.0"
|
||||||
@ -2872,7 +2910,7 @@ version = "0.1.0"
|
|||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "4cd9b125c486025df0eabcb585e62173c6c9eddcec5d117d3b6e8c30e2ee4d10"
|
checksum = "4cd9b125c486025df0eabcb585e62173c6c9eddcec5d117d3b6e8c30e2ee4d10"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"windows-result",
|
"windows-result 0.2.0",
|
||||||
"windows-targets 0.52.6",
|
"windows-targets 0.52.6",
|
||||||
]
|
]
|
||||||
|
|
||||||
|
@ -1,13 +1,9 @@
|
|||||||
use bevy::{
|
use bevy::{
|
||||||
core_pipeline::prepass::{DeferredPrepass, DepthPrepass, NormalPrepass},
|
core_pipeline::prepass::{DeferredPrepass, DepthPrepass, NormalPrepass},
|
||||||
prelude::*,
|
prelude::*,
|
||||||
render::{extract_component::ExtractComponent, render_resource::{CachedRenderPipelineId, ShaderType}},
|
render::{extract_component::ExtractComponent, render_resource::ShaderType},
|
||||||
};
|
};
|
||||||
|
|
||||||
/// Stores the cached pipeline ID for the post processing pass for this camera
|
|
||||||
#[derive(Component, Deref, DerefMut)]
|
|
||||||
pub struct OutlinePostProcessPipelineId(pub CachedRenderPipelineId);
|
|
||||||
|
|
||||||
/// Component which, when inserted into an entity with a camera and normal prepass, enables an outline effect for that
|
/// Component which, when inserted into an entity with a camera and normal prepass, enables an outline effect for that
|
||||||
/// camera.
|
/// camera.
|
||||||
#[derive(Component, ShaderType, ExtractComponent, PartialEq, Clone)]
|
#[derive(Component, ShaderType, ExtractComponent, PartialEq, Clone)]
|
||||||
|
38
src/lib.rs
38
src/lib.rs
@ -11,15 +11,12 @@ use bevy::{
|
|||||||
render::{
|
render::{
|
||||||
extract_component::{ExtractComponentPlugin, UniformComponentPlugin},
|
extract_component::{ExtractComponentPlugin, UniformComponentPlugin},
|
||||||
render_graph::{RenderGraphApp, ViewNodeRunner},
|
render_graph::{RenderGraphApp, ViewNodeRunner},
|
||||||
render_resource::{PipelineCache, SpecializedRenderPipelines, TextureFormat},
|
RenderApp,
|
||||||
view::{ExtractedView, ViewTarget},
|
|
||||||
Render, RenderApp, RenderSet,
|
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
use components::{OutlinePostProcessPipelineId, OutlinePostProcessSettings};
|
use components::OutlinePostProcessSettings;
|
||||||
pub use nodes::OutlineRenderLabel;
|
pub use nodes::OutlineRenderLabel;
|
||||||
use resources::{OutlinePostProcessPipeline, OutlinePostProcessingPipelineKey};
|
|
||||||
|
|
||||||
/// Components used by this plugin.
|
/// Components used by this plugin.
|
||||||
pub mod components;
|
pub mod components;
|
||||||
@ -44,11 +41,6 @@ impl Plugin for OutlinePostProcessPlugin {
|
|||||||
};
|
};
|
||||||
|
|
||||||
render_app
|
render_app
|
||||||
.add_systems(
|
|
||||||
Render,
|
|
||||||
prepare_post_processing_pipelines.in_set(RenderSet::Prepare),
|
|
||||||
)
|
|
||||||
.init_resource::<SpecializedRenderPipelines<OutlinePostProcessPipeline>>()
|
|
||||||
.add_render_graph_node::<ViewNodeRunner<nodes::OutlineRenderNode>>(
|
.add_render_graph_node::<ViewNodeRunner<nodes::OutlineRenderNode>>(
|
||||||
Core3d,
|
Core3d,
|
||||||
nodes::OutlineRenderLabel,
|
nodes::OutlineRenderLabel,
|
||||||
@ -72,32 +64,6 @@ impl Plugin for OutlinePostProcessPlugin {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn prepare_post_processing_pipelines(
|
|
||||||
mut commands: Commands,
|
|
||||||
pipeline_cache: Res<PipelineCache>,
|
|
||||||
mut pipelines: ResMut<SpecializedRenderPipelines<OutlinePostProcessPipeline>>,
|
|
||||||
post_processing_pipeline: Res<OutlinePostProcessPipeline>,
|
|
||||||
views: Query<(Entity, &ExtractedView), With<OutlinePostProcessSettings>>,
|
|
||||||
) {
|
|
||||||
for (entity, view) in views.iter() {
|
|
||||||
let pipeline_id = pipelines.specialize(
|
|
||||||
&pipeline_cache,
|
|
||||||
&post_processing_pipeline,
|
|
||||||
OutlinePostProcessingPipelineKey {
|
|
||||||
texture_format: if view.hdr {
|
|
||||||
ViewTarget::TEXTURE_FORMAT_HDR
|
|
||||||
} else {
|
|
||||||
TextureFormat::bevy_default()
|
|
||||||
},
|
|
||||||
},
|
|
||||||
);
|
|
||||||
|
|
||||||
commands
|
|
||||||
.entity(entity)
|
|
||||||
.insert(OutlinePostProcessPipelineId(pipeline_id));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
fn update_shader_clip_planes(
|
fn update_shader_clip_planes(
|
||||||
mut settings_query: Query<(Ref<Projection>, &mut OutlinePostProcessSettings)>,
|
mut settings_query: Query<(Ref<Projection>, &mut OutlinePostProcessSettings)>,
|
||||||
) {
|
) {
|
||||||
|
20
src/nodes.rs
20
src/nodes.rs
@ -1,6 +1,6 @@
|
|||||||
use bevy::{
|
use bevy::{
|
||||||
core_pipeline::prepass::ViewPrepassTextures,
|
core_pipeline::prepass::ViewPrepassTextures,
|
||||||
ecs::{query::QueryItem, system::lifetimeless::Read},
|
ecs::query::QueryItem,
|
||||||
prelude::*,
|
prelude::*,
|
||||||
render::{
|
render::{
|
||||||
extract_component::ComponentUniforms,
|
extract_component::ComponentUniforms,
|
||||||
@ -14,8 +14,6 @@ use bevy::{
|
|||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
use crate::components::OutlinePostProcessPipelineId;
|
|
||||||
|
|
||||||
use super::components;
|
use super::components;
|
||||||
use super::resources;
|
use super::resources;
|
||||||
|
|
||||||
@ -28,27 +26,21 @@ pub struct OutlineRenderNode;
|
|||||||
|
|
||||||
impl ViewNode for OutlineRenderNode {
|
impl ViewNode for OutlineRenderNode {
|
||||||
type ViewQuery = (
|
type ViewQuery = (
|
||||||
Read<ViewTarget>,
|
&'static ViewTarget,
|
||||||
Read<ViewPrepassTextures>,
|
&'static ViewPrepassTextures,
|
||||||
Read<OutlinePostProcessPipelineId>,
|
&'static components::OutlinePostProcessSettings,
|
||||||
Read<components::OutlinePostProcessSettings>,
|
|
||||||
);
|
);
|
||||||
|
|
||||||
fn run(
|
fn run(
|
||||||
&self,
|
&self,
|
||||||
_graph: &mut RenderGraphContext,
|
_graph: &mut RenderGraphContext,
|
||||||
render_context: &mut RenderContext,
|
render_context: &mut RenderContext,
|
||||||
(
|
(view_target, view_prepass_textures, _): QueryItem<Self::ViewQuery>,
|
||||||
view_target,
|
|
||||||
view_prepass_textures,
|
|
||||||
pipeline_id,
|
|
||||||
_,
|
|
||||||
): QueryItem<Self::ViewQuery>,
|
|
||||||
world: &World,
|
world: &World,
|
||||||
) -> Result<(), NodeRunError> {
|
) -> Result<(), NodeRunError> {
|
||||||
let render_pipeline = world.resource::<resources::OutlinePostProcessPipeline>();
|
let render_pipeline = world.resource::<resources::OutlinePostProcessPipeline>();
|
||||||
let pipeline_cache = world.resource::<PipelineCache>();
|
let pipeline_cache = world.resource::<PipelineCache>();
|
||||||
let Some(pipeline) = pipeline_cache.get_render_pipeline(**pipeline_id) else {
|
let Some(pipeline) = pipeline_cache.get_render_pipeline(render_pipeline.pipeline_id) else {
|
||||||
warn!("Failed to get render pipeline from cache, skipping...");
|
warn!("Failed to get render pipeline from cache, skipping...");
|
||||||
return Ok(());
|
return Ok(());
|
||||||
};
|
};
|
||||||
|
@ -1,9 +1,13 @@
|
|||||||
use bevy::{
|
use bevy::{
|
||||||
core_pipeline::fullscreen_vertex_shader,
|
core_pipeline::fullscreen_vertex_shader::fullscreen_shader_vertex_state,
|
||||||
prelude::*,
|
prelude::*,
|
||||||
render::{
|
render::{
|
||||||
render_resource::{
|
render_resource::{
|
||||||
binding_types::{sampler, texture_2d, uniform_buffer}, BindGroupLayout, BindGroupLayoutEntries, ColorTargetState, ColorWrites, FragmentState, RenderPipelineDescriptor, Sampler, SamplerBindingType, SamplerDescriptor, ShaderStages, SpecializedRenderPipeline, TextureFormat, TextureSampleType
|
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,
|
renderer::RenderDevice,
|
||||||
},
|
},
|
||||||
@ -17,7 +21,7 @@ pub struct OutlinePostProcessPipeline {
|
|||||||
pub screen_sampler: Sampler,
|
pub screen_sampler: Sampler,
|
||||||
pub normal_sampler: Sampler,
|
pub normal_sampler: Sampler,
|
||||||
pub depth_sampler: Sampler,
|
pub depth_sampler: Sampler,
|
||||||
pub shader: Handle<Shader>,
|
pub pipeline_id: CachedRenderPipelineId,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl FromWorld for OutlinePostProcessPipeline {
|
impl FromWorld for OutlinePostProcessPipeline {
|
||||||
@ -48,47 +52,36 @@ impl FromWorld for OutlinePostProcessPipeline {
|
|||||||
"embedded://bevy_outline_post_process/../assets/shaders/outline_post_process.wgsl",
|
"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,
|
||||||
|
})],
|
||||||
|
}),
|
||||||
|
zero_initialize_workgroup_memory: false,
|
||||||
|
});
|
||||||
|
|
||||||
Self {
|
Self {
|
||||||
layout,
|
layout,
|
||||||
screen_sampler,
|
screen_sampler,
|
||||||
normal_sampler,
|
normal_sampler,
|
||||||
depth_sampler,
|
depth_sampler,
|
||||||
shader,
|
pipeline_id,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// A key that uniquely identifies a built-in postprocessing pipeline.
|
|
||||||
#[derive(Clone, Copy, PartialEq, Eq, Hash)]
|
|
||||||
pub struct OutlinePostProcessingPipelineKey {
|
|
||||||
/// The format of the source and destination textures.
|
|
||||||
pub texture_format: TextureFormat,
|
|
||||||
}
|
|
||||||
|
|
||||||
impl SpecializedRenderPipeline for OutlinePostProcessPipeline {
|
|
||||||
type Key = OutlinePostProcessingPipelineKey;
|
|
||||||
|
|
||||||
fn specialize(&self, key: Self::Key) -> RenderPipelineDescriptor {
|
|
||||||
RenderPipelineDescriptor {
|
|
||||||
label: Some("outline_post_processing".into()),
|
|
||||||
layout: vec![self.layout.clone()],
|
|
||||||
vertex: fullscreen_vertex_shader::fullscreen_shader_vertex_state(),
|
|
||||||
fragment: Some(FragmentState {
|
|
||||||
shader: self.shader.clone(),
|
|
||||||
shader_defs: vec![],
|
|
||||||
entry_point: "fragment".into(),
|
|
||||||
targets: vec![Some(ColorTargetState {
|
|
||||||
format: key.texture_format,
|
|
||||||
blend: None,
|
|
||||||
write_mask: ColorWrites::ALL,
|
|
||||||
})],
|
|
||||||
}),
|
|
||||||
primitive: default(),
|
|
||||||
depth_stencil: None,
|
|
||||||
multisample: default(),
|
|
||||||
push_constant_ranges: vec![],
|
|
||||||
zero_initialize_workgroup_memory: false,
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
Loading…
x
Reference in New Issue
Block a user