aboutsummaryrefslogtreecommitdiff
path: root/src/components.rs
diff options
context:
space:
mode:
Diffstat (limited to 'src/components.rs')
-rw-r--r--src/components.rs22
1 files changed, 16 insertions, 6 deletions
diff --git a/src/components.rs b/src/components.rs
index 22de86c..bdce6c9 100644
--- a/src/components.rs
+++ b/src/components.rs
@@ -1,7 +1,7 @@
use bevy::{
+ core_pipeline::prepass::{DeferredPrepass, DepthPrepass, NormalPrepass},
prelude::*,
render::{extract_component::ExtractComponent, render_resource::ShaderType},
- core_pipeline::prepass::{NormalPrepass, DepthPrepass, DeferredPrepass},
};
/// Component which, when inserted into an entity with a camera and normal prepass, enables an outline effect for that
@@ -14,20 +14,29 @@ pub struct OutlinePostProcessSettings {
/// 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,
- /// Threshold of illumination for outlines to apply. Requires deferred prepass.
- light_threshold: f32,
+ /// Near plane depth of camera, used for linearization of depth buffer values
+ pub(crate) camera_near: f32,
}
impl OutlinePostProcessSettings {
/// Create a new instance with the given settings
- pub fn new(weight: f32, normal_threshold: f32, adaptive: bool, light_threshold: f32) -> Self {
+ pub fn new(
+ weight: f32,
+ normal_threshold: f32,
+ depth_threshold: f32,
+ adaptive: bool,
+ ) -> Self {
Self {
weight,
normal_threshold,
adaptive: adaptive as u32,
- light_threshold,
+ depth_threshold,
+ camera_near: 0.0,
}
}
}
@@ -38,7 +47,8 @@ impl Default for OutlinePostProcessSettings {
weight: 1.0,
normal_threshold: 0.0,
adaptive: 0,
- light_threshold: 0.0,
+ depth_threshold: 0.05,
+ camera_near: 0.0,
}
}
}