[gtk/wip/otte/dithered-gradients: 2/3] gsk: Change noise function to be more random




commit 25bebb6e73219d91c75daabcc50ea7f013e77758
Author: Benjamin Otte <otte redhat com>
Date:   Sat May 28 05:13:47 2022 +0200

    gsk: Change noise function to be more random
    
    Use the first result from shadertoy which has a noise function by
    David Hoskins that produces noise that looks less periodic than the
    previous noise function.

 gsk/gl/resources/preamble.fs.glsl | 11 ++++++-----
 1 file changed, 6 insertions(+), 5 deletions(-)
---
diff --git a/gsk/gl/resources/preamble.fs.glsl b/gsk/gl/resources/preamble.fs.glsl
index 534311f4db..189da3aee2 100644
--- a/gsk/gl/resources/preamble.fs.glsl
+++ b/gsk/gl/resources/preamble.fs.glsl
@@ -118,11 +118,12 @@ vec2 gsk_get_frag_coord() {
   return fc;
 }
 
-// from "NEXT GENERATION POST PROCESSING IN CALL OF DUTY: ADVANCED WARFARE"
-// http://advances.realtimerendering.com/s2014/index.html
-float gsk_interleaved_gradient_noise(vec2 uv) {
-    const vec3 magic = vec3(0.06711056, 0.00583715, 52.9829189);
-    return fract(magic.z * fract(dot(uv, magic.xy)));
+// hash12() from https://www.shadertoy.com/view/4djSRW
+float gsk_interleaved_gradient_noise (vec2 p)
+{
+    vec3 p3  = fract(vec3(p.xyx) * .1031);
+    p3 += dot(p3, p3.yzx + 33.33);
+    return fract((p3.x + p3.y) * p3.z);
 }
 
 vec4 gskDither(vec4 color) {


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]