diff options
author | Silas Bartha <silas@exvacuum.dev> | 2024-06-13 20:40:46 -0400 |
---|---|---|
committer | Silas Bartha <silas@exvacuum.dev> | 2024-06-13 20:40:46 -0400 |
commit | 294e8bb07ab5635118e9428901c1e92a478c29b0 (patch) | |
tree | fbd1a1e94a6695127a301c3523a60f530c7a85cb /assets | |
parent | ac37b21edddd0be6e49da32edf12f4484b480179 (diff) |
Adaptive Outlinev0.2.0
Diffstat (limited to 'assets')
-rw-r--r-- | assets/shaders/outline_post_process.wgsl | 10 |
1 files changed, 6 insertions, 4 deletions
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<f32>, -#endif + adaptive: u32, } @group(0) @binding(0) var screen_texture: texture_2d<f32>; @@ -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; } |