[Bf-blender-cvs] [b6a2d255c38] blender2.8: Eevee: Fix Shadow Map bug: fix T51924

Clément Foucault noreply at git.blender.org
Wed Jun 28 17:22:02 CEST 2017


Commit: b6a2d255c38f3fd72f56f758dbc6e8070b300478
Author: Clément Foucault
Date:   Wed Jun 28 17:21:57 2017 +0200
Branches: blender2.8
https://developer.blender.org/rBb6a2d255c38f3fd72f56f758dbc6e8070b300478

Eevee: Fix Shadow Map bug: fix T51924

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

M	source/blender/draw/engines/eevee/shaders/lamps_lib.glsl
M	source/blender/draw/engines/eevee/shaders/lit_surface_frag.glsl

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

diff --git a/source/blender/draw/engines/eevee/shaders/lamps_lib.glsl b/source/blender/draw/engines/eevee/shaders/lamps_lib.glsl
index b031b45d1c4..eeb1e225abe 100644
--- a/source/blender/draw/engines/eevee/shaders/lamps_lib.glsl
+++ b/source/blender/draw/engines/eevee/shaders/lamps_lib.glsl
@@ -31,12 +31,12 @@ layout(std140) uniform light_block {
 #define HEMI     3.0
 #define AREA     4.0
 
-float shadow_cubemap(float shid, vec3 l_vector, vec3 W)
+float shadow_cubemap(float shid, vec4 l_vector)
 {
 	ShadowCubeData scd = shadows_cube_data[int(shid)];
 
-	vec3 cubevec = W - l_vector;
-	float dist = length(cubevec) - scd.sh_cube_bias;
+	vec3 cubevec = -l_vector.xyz / l_vector.w;
+	float dist = l_vector.w - scd.sh_cube_bias;
 
 	float z = texture_octahedron(shadowCubes, vec4(cubevec, shid)).r;
 
@@ -86,13 +86,13 @@ float shadow_cascade(float shid, vec3 W)
 	return texture(shadowCascades, vec4(shpos.xy, shid * float(MAX_CASCADE_NUM) + cascade, shpos.z));
 }
 
-float light_visibility(LightData ld, vec3 W, vec3 l_vector)
+float light_visibility(LightData ld, vec3 W, vec4 l_vector)
 {
 	float vis = 1.0;
 
 	if (ld.l_type == SPOT) {
-		float z = dot(ld.l_forward, l_vector);
-		vec3 lL = l_vector / z;
+		float z = dot(ld.l_forward, l_vector.xyz);
+		vec3 lL = l_vector.xyz / z;
 		float x = dot(ld.l_right, lL) / ld.l_sizex;
 		float y = dot(ld.l_up, lL) / ld.l_sizey;
 
@@ -101,10 +101,10 @@ float light_visibility(LightData ld, vec3 W, vec3 l_vector)
 		float spotmask = smoothstep(0.0, 1.0, (ellipse - ld.l_spot_size) / ld.l_spot_blend);
 
 		vis *= spotmask;
-		vis *= step(0.0, -dot(l_vector, ld.l_forward));
+		vis *= step(0.0, -dot(l_vector.xyz, ld.l_forward));
 	}
 	else if (ld.l_type == AREA) {
-		vis *= step(0.0, -dot(l_vector, ld.l_forward));
+		vis *= step(0.0, -dot(l_vector.xyz, ld.l_forward));
 	}
 
 	/* shadowing */
@@ -112,7 +112,7 @@ float light_visibility(LightData ld, vec3 W, vec3 l_vector)
 		vis *= shadow_cascade(ld.l_shadowid, W);
 	}
 	else if (ld.l_shadowid >= 0.0) {
-		vis *= shadow_cubemap(ld.l_shadowid, l_vector, W);
+		vis *= shadow_cubemap(ld.l_shadowid, l_vector);
 	}
 
 	return vis;
diff --git a/source/blender/draw/engines/eevee/shaders/lit_surface_frag.glsl b/source/blender/draw/engines/eevee/shaders/lit_surface_frag.glsl
index 6ee87641e1f..3dc20d536c7 100644
--- a/source/blender/draw/engines/eevee/shaders/lit_surface_frag.glsl
+++ b/source/blender/draw/engines/eevee/shaders/lit_surface_frag.glsl
@@ -48,7 +48,7 @@ vec3 eevee_surface_lit(vec3 world_normal, vec3 albedo, vec3 f0, float roughness,
 		l_vector.xyz = ld.l_position - worldPosition;
 		l_vector.w = length(l_vector.xyz);
 
-		vec3 l_color_vis = ld.l_color * light_visibility(ld, worldPosition, l_vector.xyz);
+		vec3 l_color_vis = ld.l_color * light_visibility(ld, worldPosition, l_vector);
 
 #ifdef HAIR_SHADER
 		vec3 norm_lamp, view_vec;




More information about the Bf-blender-cvs mailing list