aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/components.rs20
-rw-r--r--src/nodes.rs6
-rw-r--r--src/resources.rs1
3 files changed, 19 insertions, 8 deletions
diff --git a/src/components.rs b/src/components.rs
index 7f572e3..285a881 100644
--- a/src/components.rs
+++ b/src/components.rs
@@ -11,28 +11,32 @@ pub struct OutlinePostProcessSettings {
weight: f32,
/// 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.
- threshold: f32,
+ normal_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,
}
impl OutlinePostProcessSettings {
/// Create a new instance with the given settings
- pub fn new(weight: f32, threshold: f32, adaptive: bool) -> Self {
+ pub fn new(weight: f32, normal_threshold: f32, adaptive: bool, light_threshold: f32) -> Self {
Self {
weight,
- threshold,
+ normal_threshold,
adaptive: adaptive as u32,
+ light_threshold,
}
- }
+ }
}
impl Default for OutlinePostProcessSettings {
fn default() -> Self {
- Self {
+ Self {
weight: 1.0,
- threshold: 0.0,
- adaptive: 0
+ normal_threshold: 0.0,
+ adaptive: 0,
+ light_threshold: 0.0,
}
}
-} \ No newline at end of file
+}
diff --git a/src/nodes.rs b/src/nodes.rs
index 22ca8d3..1c750c7 100644
--- a/src/nodes.rs
+++ b/src/nodes.rs
@@ -57,6 +57,11 @@ impl ViewNode for OutlineRenderNode {
return Ok(());
};
+ let Some(deferred_buffer_view) = view_prepass_textures.deferred_view() else {
+ error!("Failed to get deferred buffer view");
+ return Ok(());
+ };
+
let post_process = view_target.post_process_write();
let bind_group = render_context.render_device().create_bind_group(
@@ -67,6 +72,7 @@ impl ViewNode for OutlineRenderNode {
&render_pipeline.screen_sampler,
normal_buffer_view,
&render_pipeline.normal_sampler,
+ deferred_buffer_view,
uniform_binding,
)),
);
diff --git a/src/resources.rs b/src/resources.rs
index 24aeeec..ac39b8a 100644
--- a/src/resources.rs
+++ b/src/resources.rs
@@ -37,6 +37,7 @@ impl FromWorld for OutlinePostProcessPipeline {
sampler(SamplerBindingType::Filtering),
texture_2d(TextureSampleType::Float { filterable: true }),
sampler(SamplerBindingType::Filtering),
+ texture_2d(TextureSampleType::Uint),
uniform_buffer::<components::OutlinePostProcessSettings>(false),
),
),