aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/components.rs17
-rw-r--r--src/lib.rs7
2 files changed, 16 insertions, 8 deletions
diff --git a/src/components.rs b/src/components.rs
index bdce6c9..05a4594 100644
--- a/src/components.rs
+++ b/src/components.rs
@@ -11,14 +11,16 @@ use bevy::{
pub struct OutlinePostProcessSettings {
/// Weight of outlines in pixels.
weight: f32,
+ /// Color of outlines.
+ color: LinearRgba,
/// A threshold for normal differences, values below this threshold will not become outlines.
/// Higher values will result in more outlines which may look better on smooth surfaces.
normal_threshold: f32,
/// A threshold for depth differences (in units), values below this threshold will not become outlines.
/// Higher values will result in more outlines which may look better on smooth surfaces.
depth_threshold: f32,
- /// Whether to use adaptive outlines. White outlines will be drawn around darker objects, while black ones will be drawn around lighter ones.
- adaptive: u32,
+ /// Luma threshold to invert outline color. A value of `1.0` means this feature is disabled.
+ adaptive_threshold: f32,
/// Near plane depth of camera, used for linearization of depth buffer values
pub(crate) camera_near: f32,
}
@@ -27,15 +29,17 @@ impl OutlinePostProcessSettings {
/// Create a new instance with the given settings
pub fn new(
weight: f32,
+ color: LinearRgba,
normal_threshold: f32,
depth_threshold: f32,
- adaptive: bool,
+ adaptive_threshold: f32,
) -> Self {
Self {
weight,
+ color,
normal_threshold,
- adaptive: adaptive as u32,
depth_threshold,
+ adaptive_threshold,
camera_near: 0.0,
}
}
@@ -45,9 +49,10 @@ impl Default for OutlinePostProcessSettings {
fn default() -> Self {
Self {
weight: 1.0,
- normal_threshold: 0.0,
- adaptive: 0,
+ color: LinearRgba::BLACK,
+ normal_threshold: 0.01,
depth_threshold: 0.05,
+ adaptive_threshold: 1.0,
camera_near: 0.0,
}
}
diff --git a/src/lib.rs b/src/lib.rs
index f189cd4..0b092f2 100644
--- a/src/lib.rs
+++ b/src/lib.rs
@@ -9,7 +9,9 @@ use bevy::{
core_pipeline::core_3d::graph::{Core3d, Node3d},
prelude::*,
render::{
- extract_component::{ExtractComponentPlugin, UniformComponentPlugin}, render_graph::{RenderGraphApp, ViewNodeRunner}, RenderApp
+ extract_component::{ExtractComponentPlugin, UniformComponentPlugin},
+ render_graph::{RenderGraphApp, ViewNodeRunner},
+ RenderApp,
},
};
@@ -31,7 +33,8 @@ impl Plugin for OutlinePostProcessPlugin {
app.add_plugins((
UniformComponentPlugin::<components::OutlinePostProcessSettings>::default(),
ExtractComponentPlugin::<components::OutlinePostProcessSettings>::default(),
- )).add_systems(Update, update_shader_clip_planes);
+ ))
+ .add_systems(Update, update_shader_clip_planes);
let Some(render_app) = app.get_sub_app_mut(RenderApp) else {
return;