[Bf-blender-cvs] [b3472b67ea2] temp-ssr: Eevee: SSR: Use noise to dither the stride banding.

Clément Foucault noreply at git.blender.org
Mon Jul 24 15:25:34 CEST 2017


Commit: b3472b67ea203fe740ef2bd41b77829ae33baf09
Author: Clément Foucault
Date:   Sat Jul 22 00:22:39 2017 +0200
Branches: temp-ssr
https://developer.blender.org/rBb3472b67ea203fe740ef2bd41b77829ae33baf09

Eevee: SSR: Use noise to dither the stride banding.

===================================================================

M	source/blender/draw/engines/eevee/shaders/effect_ssr_frag.glsl
M	source/blender/draw/engines/eevee/shaders/raytrace_lib.glsl

===================================================================

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++) {




More information about the Bf-blender-cvs mailing list