29 lines
946 B
GLSL
29 lines
946 B
GLSL
// MinecraftPT — Temporal Noise
|
|
// Blue noise sampling with temporal interleaving, used for dithering and ray offsets.
|
|
|
|
#ifndef TEMPORAL_NOISE_GLSL
|
|
#define TEMPORAL_NOISE_GLSL
|
|
|
|
float BlueNoiseTemporal(){
|
|
vec2 coord = (gl_FragCoord.xy + 0.5) / screenSize;
|
|
coord = fract(coord * vec2(128.0, 128.0) + 0.5);
|
|
vec2 texel = coord * vec2(127.0 / 128.0) + vec2(0.5 / 128.0);
|
|
float noise = textureLod(noisetex, texel, 0.0).r;
|
|
return fract(noise + frameCounter * 0.03125);
|
|
}
|
|
|
|
vec2 BlueNoiseTemporal2(){
|
|
vec2 coord = (gl_FragCoord.xy + 0.5) / screenSize;
|
|
coord = fract(coord * vec2(128.0, 128.0) + 0.5);
|
|
vec2 texel = coord * vec2(127.0 / 128.0) + vec2(0.5 / 128.0);
|
|
vec2 noise = textureLod(noisetex, texel, 0.0).rg;
|
|
return fract(noise + frameCounter * 0.03125);
|
|
}
|
|
|
|
// Interleaved gradient noise
|
|
float InterleavedNoise(vec2 pos){
|
|
vec3 magic = vec3(0.06711056, 0.00583715, 52.9829189);
|
|
return fract(magic.z * fract(dot(pos, magic.xy)));
|
|
}
|
|
|
|
#endif |