aboutsummaryrefslogtreecommitdiff
path: root/src/components.rs
diff options
context:
space:
mode:
authorLibravatar Silas Bartha <[email protected]>2024-06-13 20:40:46 -0400
committerLibravatar Silas Bartha <[email protected]>2024-06-13 20:40:46 -0400
commit294e8bb07ab5635118e9428901c1e92a478c29b0 (patch)
treefbd1a1e94a6695127a301c3523a60f530c7a85cb /src/components.rs
parentac37b21edddd0be6e49da32edf12f4484b480179 (diff)
Adaptive Outlinev0.2.0
Diffstat (limited to 'src/components.rs')
-rw-r--r--src/components.rs29
1 files changed, 26 insertions, 3 deletions
diff --git a/src/components.rs b/src/components.rs
index 49f4684..7f572e3 100644
--- a/src/components.rs
+++ b/src/components.rs
@@ -5,11 +5,34 @@ use bevy::{
/// Component which, when inserted into an entity with a camera and normal prepass, enables an outline effect for that
/// camera.
-#[derive(Component, ShaderType, ExtractComponent, PartialEq, Clone, Default)]
+#[derive(Component, ShaderType, ExtractComponent, PartialEq, Clone)]
pub struct OutlinePostProcessSettings {
/// Weight of outlines in pixels.
- pub weight: f32,
+ 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.
- pub threshold: f32,
+ 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,
}
+
+impl OutlinePostProcessSettings {
+ /// Create a new instance with the given settings
+ pub fn new(weight: f32, threshold: f32, adaptive: bool) -> Self {
+ Self {
+ weight,
+ threshold,
+ adaptive: adaptive as u32,
+ }
+ }
+}
+
+impl Default for OutlinePostProcessSettings {
+ fn default() -> Self {
+ Self {
+ weight: 1.0,
+ threshold: 0.0,
+ adaptive: 0
+ }
+ }
+} \ No newline at end of file