From b2051767ffbee16fcb1686e4d1e4a8f18bc8dc86 Mon Sep 17 00:00:00 2001 From: Joshua Barretto Date: Wed, 31 May 2023 17:07:22 +0100 Subject: [PATCH] More experimental shaders --- assets/voxygen/shaders/clouds-frag.glsl | 4 ++++ assets/voxygen/shaders/include/random.glsl | 7 +++++++ assets/voxygen/shaders/postprocess-frag.glsl | 6 ++++++ voxygen/src/render/mod.rs | 4 ++++ 4 files changed, 21 insertions(+) diff --git a/assets/voxygen/shaders/clouds-frag.glsl b/assets/voxygen/shaders/clouds-frag.glsl index 0fbd9ebfd8..f5e31bdfc4 100644 --- a/assets/voxygen/shaders/clouds-frag.glsl +++ b/assets/voxygen/shaders/clouds-frag.glsl @@ -95,6 +95,10 @@ void main() { tgt_color = vec4(mat_colors[mat.a % 5u], 1); return; #endif + #ifdef EXPERIMENTAL_VIEWDEPTH + tgt_color = vec4(vec3(pow(clamp(depth_at(uv) / 524288.0, 0, 1), 0.3)), 1); + return; + #endif #ifdef EXPERIMENTAL_BAREMINIMUM tgt_color = vec4(color.rgb, 1); diff --git a/assets/voxygen/shaders/include/random.glsl b/assets/voxygen/shaders/include/random.glsl index c174b10c99..26ea7926bc 100644 --- a/assets/voxygen/shaders/include/random.glsl +++ b/assets/voxygen/shaders/include/random.glsl @@ -27,6 +27,13 @@ float hash_two(uvec2 q) { return float(n) * (1.0 / float(0xffffffffU)); } +float hash_three(uvec3 q) { + q *= uvec3(M1, M2, M3); + uint n = q.x ^ q.y ^ q.z; + n = n * (n ^ (n >> 15)); + return float(n) * (1.0 / float(0xffffffffU)); +} + float hash_fast(uvec3 q) { q *= uvec3(M1, M2, M3); diff --git a/assets/voxygen/shaders/postprocess-frag.glsl b/assets/voxygen/shaders/postprocess-frag.glsl index 418324c7e4..ef8df9d2b7 100644 --- a/assets/voxygen/shaders/postprocess-frag.glsl +++ b/assets/voxygen/shaders/postprocess-frag.glsl @@ -314,5 +314,11 @@ void main() { #endif #endif + #ifdef EXPERIMENTAL_NEWSPAPER + float nz = hash_three(uvec3(uvec2(uv * screen_res.xy), tick.x * dot(fract(uv * 10) + 5, vec2(1)) * 0.3)); + nz = (nz > 0.5) ? (pow(nz * 2 - 1, 1.5) * 0.5 + 0.5) : (pow(nz * 2, 1/1.5) * 0.5); + final_color.rgb = vec3(step(nz, length(final_color.rgb))) * mix(vec3(1, 0.5, 0.3), normalize(final_color.rgb), 0.05); + #endif + tgt_color = vec4(final_color.rgb, 1); } diff --git a/voxygen/src/render/mod.rs b/voxygen/src/render/mod.rs index 2432dfcae3..ba8b699c21 100644 --- a/voxygen/src/render/mod.rs +++ b/voxygen/src/render/mod.rs @@ -515,6 +515,8 @@ pub enum ExperimentalShader { ViewNormals, /// Show gbuffer materials. ViewMaterials, + /// Show gbuffer depth. + ViewDepth, /// Rather than fading out screen-space reflections at view space borders, /// smear screen space to cover the reflection vector. SmearReflections, @@ -526,4 +528,6 @@ pub enum ExperimentalShader { /// Prefer using physically-based values for various rendering parameters, /// where possible. Photorealistic, + /// A dithered newspaper effect. + Newspaper, }