 }
 
 #ifdef _JITTER_OFFSET
-#define INT_SCALE3_JITTER vec3(.1031, .1030, .0973)
-// uniform rand
-vec3 randJitter(const in vec3 p2) {
-    vec3 p3  = fract(p2.xyz * INT_SCALE3_JITTER);
-    p3 += dot(p3, p3.yzx + 19.19);
-    p3 = fract((p3.xxy + p3.yzz) * p3.zyx);
-    return p3;
+// TODO could be in a random.glsl file
+// https://github.com/EpicGames/UnrealEngine/blob/release/Engine/Shaders/Private/Random.ush#L27
+float shadowInterleavedGradientNoise(const in vec2 fragCoord, const in float frameMod) {
+    vec3 magic = vec3(0.06711056, 0.00583715, 52.9829189);
+    return fract(magic.z * fract(dot(fragCoord.xy + frameMod * vec2(47.0, 17.0) * 0.695, magic.xy)));
 }
 #endif
 

#pragma include "floatFromTex.glsl"

// simulation of texture2Dshadow glsl call on HW
// http://codeflow.org/entries/2013/feb/15/soft-shadow-mapping/


#ifdef _JITTER_OFFSET
    if (jitter > 0.0){
        centroidCoord += shadowInterleavedGradientNoise(gl_FragCoord.xy, jitter).xy;
    }
#endif

