summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRĂ©mi Verschelde <rverschelde@gmail.com>2020-09-04 10:53:01 +0200
committerGitHub <noreply@github.com>2020-09-04 10:53:01 +0200
commit6a03aed5a4c6dcc2b645b90ce15ba33bf17819d2 (patch)
tree5d694ab4b1106b0439c1d1324867951bfdc77e04
parentdc8d8d1b5d4dd936cc9bb1c69414444bce0eabc3 (diff)
parentcf07a58a5f626d9e21e7beaa9667b979fe575012 (diff)
Merge pull request #40958 from clayjohn/VULKAN-shadow-noise
Improve the quick hash function for all GPUs
-rw-r--r--servers/rendering/rasterizer_rd/shaders/scene_high_end.glsl8
1 files changed, 6 insertions, 2 deletions
diff --git a/servers/rendering/rasterizer_rd/shaders/scene_high_end.glsl b/servers/rendering/rasterizer_rd/shaders/scene_high_end.glsl
index 5993e68317..2a7b73d9aa 100644
--- a/servers/rendering/rasterizer_rd/shaders/scene_high_end.glsl
+++ b/servers/rendering/rasterizer_rd/shaders/scene_high_end.glsl
@@ -681,9 +681,13 @@ LIGHT_SHADER_CODE
#ifndef USE_NO_SHADOWS
-// Produces cheap but low-quality white noise, nothing special
+// Produces cheap white noise, optmized for window-space
+// Comes from: https://www.shadertoy.com/view/4djSRW
+// Copyright: Dave Hoskins, MIT License
float quick_hash(vec2 pos) {
- return fract(sin(dot(pos * 19.19, vec2(49.5791, 97.413))) * 49831.189237);
+ vec3 p3 = fract(vec3(pos.xyx) * .1031);
+ p3 += dot(p3, p3.yzx + 33.33);
+ return fract((p3.x + p3.y) * p3.z);
}
float sample_directional_pcf_shadow(texture2D shadow, vec2 shadow_pixel_size, vec4 coord) {