[Bf-blender-cvs] [c5f4342692b] blender2.8: Eevee: SSR: Small fixes

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


Commit: c5f4342692b10110200e3494a1e9412e75270c10
Author: Clément Foucault
Date:   Mon Jul 24 15:36:22 2017 +0200
Branches: blender2.8
https://developer.blender.org/rBc5f4342692b10110200e3494a1e9412e75270c10

Eevee: SSR: Small fixes

- Encode normals for other opaque bsdf so they are not rejected by the normal facing test.
- Early out non reflective surfaces.
- Add small offset to raytrace to avoid self intersection.
- Fix fallback probes not appearing.

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

M	source/blender/draw/engines/eevee/eevee_effects.c
M	source/blender/draw/engines/eevee/shaders/effect_ssr_frag.glsl
M	source/blender/draw/engines/eevee/shaders/raytrace_lib.glsl
M	source/blender/gpu/shaders/gpu_shader_material.glsl

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

diff --git a/source/blender/draw/engines/eevee/eevee_effects.c b/source/blender/draw/engines/eevee/eevee_effects.c
index a48332f0ad4..8707de281a4 100644
--- a/source/blender/draw/engines/eevee/eevee_effects.c
+++ b/source/blender/draw/engines/eevee/eevee_effects.c
@@ -757,6 +757,8 @@ void EEVEE_effects_cache_init(EEVEE_SceneLayerData *sldata, EEVEE_Data *vedata)
 		DRW_shgroup_uniform_float(grp, "borderFadeFactor", &effects->ssr_border_fac, 1);
 		DRW_shgroup_uniform_float(grp, "lodCubeMax", &sldata->probes->lod_cube_max, 1);
 		DRW_shgroup_uniform_float(grp, "lodPlanarMax", &sldata->probes->lod_planar_max, 1);
+		DRW_shgroup_uniform_block(grp, "probe_block", sldata->probe_ubo);
+		DRW_shgroup_uniform_block(grp, "planar_block", sldata->planar_ubo);
 		DRW_shgroup_uniform_buffer(grp, "probeCubes", &sldata->probe_pool);
 		DRW_shgroup_uniform_buffer(grp, "probePlanars", &vedata->txl->planar_pool);
 		DRW_shgroup_call_add(grp, quad, NULL);
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 64ad433eb44..83f238ce782 100644
--- a/source/blender/draw/engines/eevee/shaders/effect_ssr_frag.glsl
+++ b/source/blender/draw/engines/eevee/shaders/effect_ssr_frag.glsl
@@ -59,6 +59,11 @@ void main()
 
 	/* Retrieve pixel data */
 	vec4 speccol_roughness = texelFetch(specroughBuffer, fullres_texel, 0).rgba;
+
+	/* Early out */
+	if (dot(speccol_roughness.rgb, vec3(1.0)) == 0.0)
+		discard;
+
 	float roughness = speccol_roughness.a;
 	float roughnessSquared = max(1e-3, roughness * roughness);
 	float a2 = roughnessSquared * roughnessSquared;
@@ -244,6 +249,11 @@ void main()
 	vec3 V = cameraVec;
 	vec3 N = mat3(ViewMatrixInverse) * normal_decode(texelFetch(normalBuffer, fullres_texel, 0).rg, viewCameraVec);
 	vec4 speccol_roughness = texelFetch(specroughBuffer, fullres_texel, 0).rgba;
+
+	/* Early out */
+	if (dot(speccol_roughness.rgb, vec3(1.0)) == 0.0)
+		discard;
+
 	float roughness = speccol_roughness.a;
 	float roughnessSquared = max(1e-3, roughness * roughness);
 
diff --git a/source/blender/draw/engines/eevee/shaders/raytrace_lib.glsl b/source/blender/draw/engines/eevee/shaders/raytrace_lib.glsl
index d2a9b5843c5..d0c60310a00 100644
--- a/source/blender/draw/engines/eevee/shaders/raytrace_lib.glsl
+++ b/source/blender/draw/engines/eevee/shaders/raytrace_lib.glsl
@@ -96,7 +96,7 @@ float raycast(sampler2D depth_texture, vec3 ray_origin, vec3 ray_dir, float ray_
 	float end = P1.x * step_sign;
 
 	/* Initial offset */
-	pqk += dPQK * ray_jitter;
+	pqk += dPQK * (0.01 + ray_jitter);
 
 	bool hit = false;
 	float raw_depth;
diff --git a/source/blender/gpu/shaders/gpu_shader_material.glsl b/source/blender/gpu/shaders/gpu_shader_material.glsl
index c2956011ffa..a7055d422f0 100644
--- a/source/blender/gpu/shaders/gpu_shader_material.glsl
+++ b/source/blender/gpu/shaders/gpu_shader_material.glsl
@@ -2663,8 +2663,8 @@ void node_bsdf_diffuse(vec4 color, float roughness, vec3 N, out Closure result)
 {
 #ifdef EEVEE_ENGINE
 	vec3 L = eevee_surface_diffuse_lit(N, vec3(1.0), 1.0);
-
-	result = Closure(L * color.rgb, 1.0, vec4(0.0), vec2(0.0), -1);
+	vec3 vN = normalize(mat3(ViewMatrix) * N);
+	result = Closure(L * color.rgb, 1.0, vec4(0.0), normal_encode(N, viewCameraVec), -1);
 #else
 	/* ambient light */
 	vec3 L = vec3(0.2);
@@ -2945,7 +2945,7 @@ void node_emission(vec4 color, float strength, vec3 N, out Closure result)
 #ifndef VOLUMETRICS
 	color *= strength;
 #ifdef EEVEE_ENGINE
-	result = Closure(color.rgb, color.a, vec4(0.0), vec2(0.0), -1);
+	result = Closure(color.rgb, color.a, vec4(0.0), normal_encode(N, viewCameraVec), -1);
 #else
 	result = Closure(color.rgb, color.a);
 #endif




More information about the Bf-blender-cvs mailing list