From 294e8bb07ab5635118e9428901c1e92a478c29b0 Mon Sep 17 00:00:00 2001 From: Silas Bartha Date: Thu, 13 Jun 2024 20:40:46 -0400 Subject: Adaptive Outline --- assets/shaders/outline_post_process.wgsl | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) (limited to 'assets') diff --git a/assets/shaders/outline_post_process.wgsl b/assets/shaders/outline_post_process.wgsl index 79c116f..5e0bf9c 100644 --- a/assets/shaders/outline_post_process.wgsl +++ b/assets/shaders/outline_post_process.wgsl @@ -3,9 +3,7 @@ struct OutlinePostProcessSettings { weight: f32, threshold: f32, -#ifdef SIXTEEN_BYTE_ALIGNMENT - _padding: vec2, -#endif + adaptive: u32, } @group(0) @binding(0) var screen_texture: texture_2d; @@ -39,7 +37,11 @@ fn fragment( let delta_clipped = clamp((delta_raw * 2.0) - settings.threshold, 0.0, 1.0); - let outline = vec4f(delta_clipped, delta_clipped, delta_clipped, 0.0); + var outline = vec4f(delta_clipped, delta_clipped, delta_clipped, 0.0); + let luma = (0.2126 * screen_color.r + 0.7152 * screen_color.g + 0.0722 * screen_color.b); + if settings.adaptive != 0 && luma < 0.5 { + outline = outline * -1; + } return screen_color - outline; } -- cgit v1.2.3