Eevee: Add macro to sample noise in utilTex.
Avoid future coding error.
This commit is contained in:
@@ -9,11 +9,12 @@ vec2 jitternoise = vec2(0.0);
|
||||
#ifndef UTIL_TEX
|
||||
#define UTIL_TEX
|
||||
uniform sampler2DArray utilTex;
|
||||
#define texelfetch_noise_tex(coord) texelFetch(utilTex, ivec3(ivec2(coord) % LUT_SIZE, 2.0), 0)
|
||||
#endif /* UTIL_TEX */
|
||||
|
||||
void setup_noise(void)
|
||||
{
|
||||
jitternoise = texture(utilTex, vec3(gl_FragCoord.xy / LUT_SIZE, 2.0)).rg; /* Global variable */
|
||||
jitternoise = texelfetch_noise_tex(gl_FragCoord.xy).rg; /* Global variable */
|
||||
}
|
||||
|
||||
#ifdef HAMMERSLEY_SIZE
|
||||
|
||||
@@ -5,6 +5,7 @@
|
||||
#ifndef UTIL_TEX
|
||||
#define UTIL_TEX
|
||||
uniform sampler2DArray utilTex;
|
||||
#define texelfetch_noise_tex(coord) texelFetch(utilTex, ivec3(ivec2(coord) % LUT_SIZE, 2.0), 0)
|
||||
#endif /* UTIL_TEX */
|
||||
|
||||
#define MAX_MIP 9.0
|
||||
@@ -196,7 +197,7 @@ void fallback_cubemap(
|
||||
/* Specular probes */
|
||||
vec3 spec_dir = get_specular_reflection_dominant_dir(N, V, roughnessSquared);
|
||||
|
||||
vec4 rand = texture(utilTex, vec3(gl_FragCoord.xy / LUT_SIZE, 2.0));
|
||||
vec4 rand = texelfetch_noise_tex(gl_FragCoord.xy);
|
||||
vec3 bent_normal;
|
||||
float final_ao = occlusion_compute(N, viewPosition, 1.0, rand.rg, bent_normal);
|
||||
final_ao = specular_occlusion(dot(N, V), final_ao, roughness);
|
||||
|
||||
@@ -12,7 +12,12 @@ uniform float jitterThreshold;
|
||||
uniform sampler2D depthBuffer;
|
||||
uniform sampler2D sssData;
|
||||
uniform sampler2D sssAlbedo;
|
||||
|
||||
#ifndef UTIL_TEX
|
||||
#define UTIL_TEX
|
||||
uniform sampler2DArray utilTex;
|
||||
#define texelfetch_noise_tex(coord) texelFetch(utilTex, ivec3(ivec2(coord) % LUT_SIZE, 2.0), 0)
|
||||
#endif /* UTIL_TEX */
|
||||
|
||||
out vec4 FragColor;
|
||||
|
||||
@@ -41,7 +46,7 @@ void main(void)
|
||||
vec4 sss_data = texture(sssData, uvs).rgba;
|
||||
float depth_view = get_view_z_from_depth(texture(depthBuffer, uvs).r);
|
||||
|
||||
float rand = texelFetch(utilTex, ivec3(ivec2(gl_FragCoord.xy) % LUT_SIZE, 2), 0).r;
|
||||
float rand = texelfetch_noise_tex(gl_FragCoord.xy).r;
|
||||
#ifdef FIRST_PASS
|
||||
float angle = M_2PI * rand + M_PI_2;
|
||||
vec2 dir = vec2(1.0, 0.0);
|
||||
|
||||
@@ -203,7 +203,7 @@ float light_visibility(LightData ld, vec3 W,
|
||||
vec3 T, B;
|
||||
make_orthonormal_basis(L.xyz / L.w, T, B);
|
||||
|
||||
vec4 rand = texture(utilTex, vec3(gl_FragCoord.xy / LUT_SIZE, 2.0));
|
||||
vec4 rand = texelfetch_noise_tex(gl_FragCoord.xy);
|
||||
/* WATCH THIS : This still seems to have correlation artifacts for low samples. */
|
||||
rand.zw *= fast_sqrt(rand.y) * data.sh_contact_spread;
|
||||
|
||||
@@ -310,7 +310,7 @@ vec3 light_translucent(LightData ld, vec3 W, vec3 N, vec4 l_vector, float scale)
|
||||
vec3 T, B;
|
||||
make_orthonormal_basis(L.xyz / L.w, T, B);
|
||||
|
||||
vec4 rand = texture(utilTex, vec3(gl_FragCoord.xy / LUT_SIZE, 2.0));
|
||||
vec4 rand = texelfetch_noise_tex(gl_FragCoord.xy);
|
||||
/* WATCH THIS : This still seems to have correlation artifacts for low samples. */
|
||||
rand.zw *= fast_sqrt(rand.y) * data.sh_blur;
|
||||
|
||||
|
||||
@@ -15,6 +15,7 @@ uniform float refractionDepth;
|
||||
#ifndef UTIL_TEX
|
||||
#define UTIL_TEX
|
||||
uniform sampler2DArray utilTex;
|
||||
#define texelfetch_noise_tex(coord) texelFetch(utilTex, ivec3(ivec2(coord) % LUT_SIZE, 2.0), 0)
|
||||
#endif /* UTIL_TEX */
|
||||
|
||||
in vec3 worldPosition;
|
||||
@@ -175,7 +176,7 @@ void CLOSURE_NAME(
|
||||
|
||||
vec3 V = cameraVec;
|
||||
|
||||
vec4 rand = texture(utilTex, vec3(gl_FragCoord.xy / LUT_SIZE, 2.0));
|
||||
vec4 rand = texelFetch(utilTex, ivec3(ivec2(gl_FragCoord.xy) % LUT_SIZE, 2.0), 0);
|
||||
|
||||
/* ---------------------------------------------------------------- */
|
||||
/* -------------------- SCENE LAMPS LIGHTING ---------------------- */
|
||||
|
||||
@@ -5,6 +5,7 @@
|
||||
#ifndef UTIL_TEX
|
||||
#define UTIL_TEX
|
||||
uniform sampler2DArray utilTex;
|
||||
#define texelfetch_noise_tex(coord) texelFetch(utilTex, ivec3(ivec2(coord) % LUT_SIZE, 2.0), 0)
|
||||
#endif /* UTIL_TEX */
|
||||
|
||||
/* from Real-Time Area Lighting: a Journey from Research to Production
|
||||
|
||||
Reference in New Issue
Block a user