aboutsummaryrefslogtreecommitdiff
path: root/assets
diff options
context:
space:
mode:
authorLibravatar Silas Bartha <[email protected]>2024-11-22 14:42:27 -0500
committerLibravatar Silas Bartha <[email protected]>2024-11-22 14:42:27 -0500
commit1242f8352a3777ae20a3a24df5fc707e3f3c1ee0 (patch)
tree0a9b90c185a31c79a8451ce89b7f51b26d858582 /assets
parent05f6f7640879ea01372107ed7198add775a08b48 (diff)
Fri Nov 22 02:42:27 PM EST 2024
Diffstat (limited to 'assets')
-rw-r--r--assets/shaders/outline_post_process.wgsl28
1 files changed, 13 insertions, 15 deletions
diff --git a/assets/shaders/outline_post_process.wgsl b/assets/shaders/outline_post_process.wgsl
index 3689bc1..e4dfacc 100644
--- a/assets/shaders/outline_post_process.wgsl
+++ b/assets/shaders/outline_post_process.wgsl
@@ -12,7 +12,7 @@ struct OutlinePostProcessSettings {
@group(0) @binding(1) var screen_sampler: sampler;
@group(0) @binding(2) var normal_texture: texture_2d<f32>;
@group(0) @binding(3) var normal_sampler: sampler;
-// @group(0) @binding(4) var deferred_texture: texture_2d<u32>;
+@group(0) @binding(4) var deferred_texture: texture_2d<u32>;
@group(0) @binding(5) var<uniform> settings: OutlinePostProcessSettings;
@fragment
@@ -20,19 +20,18 @@ fn fragment(
in: FullscreenVertexOutput
) -> @location(0) vec4<f32> {
let screen_color = textureSample(screen_texture, screen_sampler, in.uv);
- // let deferred_dimensions = textureDimensions(deferred_texture);
- // let deferred_texel = textureLoad(deferred_texture, vec2u(vec2f(deferred_dimensions) * in.uv), 0);
- // let deferred_color = vec4f(vec3f(unpack4x8unorm(deferred_texel.r).rgb), 1.0);
- // let emissive = vec4f(rgb9e5::rgb9e5_to_vec3_(deferred_texel.g), 1.0);
- // let light = screen_color / ((deferred_color) + vec4f(0.001, 0.001, 0.001, 1.0));
+ let deferred_dimensions = textureDimensions(deferred_texture);
+ let deferred_texel = textureLoad(deferred_texture, vec2u(vec2f(deferred_dimensions) * in.uv), 0);
+ let deferred_color = vec4f(vec3f(unpack4x8unorm(deferred_texel.r).rgb), 1.0);
+ let emissive = vec4f(rgb9e5::rgb9e5_to_vec3_(deferred_texel.g), 1.0);
+ let light = screen_color / ((deferred_color) + vec4f(0.001, 0.001, 0.001, 1.0));
let luma = (0.2126 * screen_color.r + 0.7152 * screen_color.g + 0.0722 * screen_color.b);
- // let light_luma = (0.2126 * light.r + 0.7152 * light.g + 0.0722 * light.b);
- // let emissive_luma = (0.2126 * emissive.r + 0.7152 * emissive.g + 0.0722 * emissive.b);
- let final_luma = luma ;
- // + light_luma + emissive_luma;
+ let light_luma = (0.2126 * light.r + 0.7152 * light.g + 0.0722 * light.b);
+ let emissive_luma = (0.2126 * emissive.r + 0.7152 * emissive.g + 0.0722 * emissive.b);
+ let final_luma = luma + light_luma + emissive_luma;
- // if final_luma > settings.light_threshold {
+ if final_luma > settings.light_threshold {
let outline_width = settings.weight / vec2f(textureDimensions(screen_texture));
let uv_top = vec2f(in.uv.x, in.uv.y - outline_width.y);
@@ -57,8 +56,7 @@ fn fragment(
if settings.adaptive != 0 && luma < 0.5 {
outline = outline * -1;
}
- return screen_color - outline;
- // + emissive;
- // }
- // return screen_color + emissive;
+ return screen_color - outline + emissive;
+ }
+ return screen_color + emissive;
}