Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorClément Foucault <foucault.clem@gmail.com>2017-07-22 01:22:39 +0300
committerClément Foucault <foucault.clem@gmail.com>2017-07-22 01:22:39 +0300
commitb3472b67ea203fe740ef2bd41b77829ae33baf09 (patch)
treecf57d5fe81586775c116cdafcf57943010265050
parente785648f2e91d752773439d30a99ee22e974fab8 (diff)
Eevee: SSR: Use noise to dither the stride banding.
-rw-r--r--source/blender/draw/engines/eevee/shaders/effect_ssr_frag.glsl12
-rw-r--r--source/blender/draw/engines/eevee/shaders/raytrace_lib.glsl5
2 files changed, 10 insertions, 7 deletions
diff --git a/source/blender/draw/engines/eevee/shaders/effect_ssr_frag.glsl b/source/blender/draw/engines/eevee/shaders/effect_ssr_frag.glsl
index 4473d73c5c8..411c31118c4 100644
--- a/source/blender/draw/engines/eevee/shaders/effect_ssr_frag.glsl
+++ b/source/blender/draw/engines/eevee/shaders/effect_ssr_frag.glsl
@@ -6,12 +6,11 @@ uniform sampler2DArray utilTex;
#define BRDF_BIAS 0.7
-vec3 generate_ray(ivec2 pix, vec3 V, vec3 N, float a2, out float pdf)
+vec3 generate_ray(vec3 V, vec3 N, float a2, vec3 rand, out float pdf)
{
float NH;
vec3 T, B;
make_orthonormal_basis(N, T, B); /* Generate tangent space */
- vec3 rand = texelFetch(utilTex, ivec3(pix % LUT_SIZE, 2), 0).rba;
/* Importance sampling bias */
rand.x = mix(rand.x, 0.0, BRDF_BIAS);
@@ -66,7 +65,8 @@ void main()
/* Generate Ray */
float pdf;
- vec3 R = generate_ray(halfres_texel, V, N, a2, pdf);
+ vec3 rand = texelFetch(utilTex, ivec3(halfres_texel % LUT_SIZE, 2), 0).rba;
+ vec3 R = generate_ray(V, N, a2, rand, pdf);
/* Search for the planar reflection affecting this pixel */
/* If no planar is found, fallback to screen space */
@@ -88,7 +88,7 @@ void main()
/* Note : this still fails in some cases like with normal map.
* We should check against the geometric normal but we don't have it at this stage. */
if (dot(R, N) > 0.0001) {
- hit_dist = raycast(depthBuffer, viewPosition, R);
+ hit_dist = raycast(depthBuffer, viewPosition, R, rand.x);
}
vec2 hit_co = project_point(ProjectionMatrix, viewPosition + R * hit_dist).xy * 0.5 + 0.5;
@@ -192,8 +192,8 @@ float screen_border_mask(vec2 past_hit_co, vec3 hit)
hit_co.xy = (hit_co.xy / hit_co.w) * 0.5 + 0.5;
hit_co.zw = past_hit_co;
- const float margin = -0.02;
- const float atten = 0.02 + margin; /* Screen percentage */
+ const float margin = 0.01;
+ const float atten = 0.075 + margin; /* Screen percentage */
hit_co = smoothstep(margin, atten, hit_co) * (1 - smoothstep(1.0 - atten, 1.0 - margin, hit_co));
vec2 atten_fac = min(hit_co.xy, hit_co.zw);
diff --git a/source/blender/draw/engines/eevee/shaders/raytrace_lib.glsl b/source/blender/draw/engines/eevee/shaders/raytrace_lib.glsl
index 36787153afc..d2a9b5843c5 100644
--- a/source/blender/draw/engines/eevee/shaders/raytrace_lib.glsl
+++ b/source/blender/draw/engines/eevee/shaders/raytrace_lib.glsl
@@ -22,7 +22,7 @@ void swapIfBigger(inout float a, inout float b)
}
/* Return the length of the ray if there is a hit, and -1.0 if not hit occured */
-float raycast(sampler2D depth_texture, vec3 ray_origin, vec3 ray_dir)
+float raycast(sampler2D depth_texture, vec3 ray_origin, vec3 ray_dir, float ray_jitter)
{
float near = get_view_z_from_depth(0.0); /* TODO optimize */
@@ -95,6 +95,9 @@ float raycast(sampler2D depth_texture, vec3 ray_origin, vec3 ray_dir)
* the step direction for a signed comparison */
float end = P1.x * step_sign;
+ /* Initial offset */
+ pqk += dPQK * ray_jitter;
+
bool hit = false;
float raw_depth;
for (float hitstep = 0.0; hitstep < MAX_STEP && !hit; hitstep++) {