[Bf-blender-cvs] [1dbd3ae] master: Fix T38831: blender internal enabling shadow pass changes material node diffuse.

Brecht Van Lommel noreply at git.blender.org
Wed Feb 26 17:18:41 CET 2014


Commit: 1dbd3ae6291349f044c6eaa9b87b8e686f476865
Author: Brecht Van Lommel
Date:   Wed Feb 26 16:55:50 2014 +0100
https://developer.blender.org/rB1dbd3ae6291349f044c6eaa9b87b8e686f476865

Fix T38831: blender internal enabling shadow pass changes material node diffuse.

It would include/exclude shadow depending on the pass being disabled/enabled,
but that should have no influence on the combined render result. Now it always
includes shadow.

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

M	source/blender/nodes/shader/nodes/node_shader_material.c
M	source/blender/render/extern/include/RE_shader_ext.h
M	source/blender/render/intern/source/rayshade.c
M	source/blender/render/intern/source/shadeinput.c
M	source/blender/render/intern/source/shadeoutput.c
M	source/blender/render/intern/source/strand.c
M	source/blender/render/intern/source/volumetric.c

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

diff --git a/source/blender/nodes/shader/nodes/node_shader_material.c b/source/blender/nodes/shader/nodes/node_shader_material.c
index 820e0f4..79d6649 100644
--- a/source/blender/nodes/shader/nodes/node_shader_material.c
+++ b/source/blender/nodes/shader/nodes/node_shader_material.c
@@ -186,7 +186,7 @@ static void node_shader_exec_material(void *data, int UNUSED(thread), bNode *nod
 		if (node->type == SH_NODE_MATERIAL_EXT) {
 			/* Shadow, Reflect, Refract, Radiosity, Speed seem to cause problems inside
 			 * a node tree :( */
-			copy_v3_v3(out[MAT_OUT_DIFFUSE]->vec, shrnode.diff);
+			copy_v3_v3(out[MAT_OUT_DIFFUSE]->vec, shrnode.diffshad);
 			copy_v3_v3(out[MAT_OUT_SPEC]->vec, shrnode.spec);
 			copy_v3_v3(out[MAT_OUT_AO]->vec, shrnode.ao);
 		}
diff --git a/source/blender/render/extern/include/RE_shader_ext.h b/source/blender/render/extern/include/RE_shader_ext.h
index 57e52a9..70e3edc 100644
--- a/source/blender/render/extern/include/RE_shader_ext.h
+++ b/source/blender/render/extern/include/RE_shader_ext.h
@@ -50,9 +50,10 @@ typedef struct ShadeResult {
 	float col[4];
 	float alpha, mist, z;
 	float emit[3];
-	float diff[3];		/* no ramps, shadow, etc */
-	float spec[3];
-	float shad[4];		/* shad[3] is shadow intensity */
+	float diff[3];			/* diffuse with no ramps, shadow, etc */
+	float diffshad[3];		/* diffuse with shadow */
+	float spec[3];			/* specular with shadow */
+	float shad[4];			/* shad[3] is shadow intensity */
 	float ao[3];
 	float env[3];
 	float indirect[3];
diff --git a/source/blender/render/intern/source/rayshade.c b/source/blender/render/intern/source/rayshade.c
index 6807af0..6dd2692 100644
--- a/source/blender/render/intern/source/rayshade.c
+++ b/source/blender/render/intern/source/rayshade.c
@@ -563,6 +563,7 @@ void shade_ray(Isect *is, ShadeInput *shi, ShadeResult *shr)
 		
 		/* raytrace likes to separate the spec color */
 		sub_v3_v3v3(shr->diff, shr->combined, shr->spec);
+		copy_v3_v3(shr->diffshad, shr->diff);
 	}
 
 }
diff --git a/source/blender/render/intern/source/shadeinput.c b/source/blender/render/intern/source/shadeinput.c
index bc9ba34..90e5def 100644
--- a/source/blender/render/intern/source/shadeinput.c
+++ b/source/blender/render/intern/source/shadeinput.c
@@ -118,8 +118,10 @@ void shade_material_loop(ShadeInput *shi, ShadeResult *shr)
 		madd_v3_v3fl(shr->combined, shr_t.combined, fac);
 		if (shi->passflag & SCE_PASS_SPEC)
 			madd_v3_v3fl(shr->spec, shr_t.spec, fac);
-		if (shi->passflag & SCE_PASS_DIFFUSE)
+		if (shi->passflag & SCE_PASS_DIFFUSE) {
 			madd_v3_v3fl(shr->diff, shr_t.diff, fac);
+			madd_v3_v3fl(shr->diffshad, shr_t.diffshad, fac);
+		}
 		if (shi->passflag & SCE_PASS_SHADOW)
 			madd_v3_v3fl(shr->shad, shr_t.shad, fac);
 
diff --git a/source/blender/render/intern/source/shadeoutput.c b/source/blender/render/intern/source/shadeoutput.c
index 6cb34a6..4f41f27 100644
--- a/source/blender/render/intern/source/shadeoutput.c
+++ b/source/blender/render/intern/source/shadeoutput.c
@@ -937,6 +937,8 @@ void shade_color(ShadeInput *shi, ShadeResult *shr)
 		shr->diff[2] *= obcol[2];
 		if (shi->mode & MA_TRANSP) shr->alpha *= obcol[3];
 	}
+
+	copy_v3_v3(shr->diffshad, shr->diff);
 }
 
 /* ramp for at end of shade */
@@ -1874,9 +1876,11 @@ void shade_lamp_loop(ShadeInput *shi, ShadeResult *shr)
 		}
 		
 		if (shi->combinedflag & SCE_PASS_SHADOW)
-			copy_v3_v3(shr->combined, shr->shad); 	/* note, no ';' ! */
+			copy_v3_v3(shr->diffshad, shr->shad); 	/* note, no ';' ! */
 		else
-			copy_v3_v3(shr->combined, shr->diff);
+			copy_v3_v3(shr->diffshad, shr->diff);
+
+		copy_v3_v3(shr->combined, shr->diffshad);
 			
 		/* calculate shadow pass, we use a multiplication mask */
 		/* if diff = 0,0,0 it doesn't matter what the shadow pass is, so leave it as is */
diff --git a/source/blender/render/intern/source/strand.c b/source/blender/render/intern/source/strand.c
index f2d4a7a..9a6a2b8 100644
--- a/source/blender/render/intern/source/strand.c
+++ b/source/blender/render/intern/source/strand.c
@@ -216,8 +216,10 @@ static void interpolate_shade_result(ShadeResult *shr1, ShadeResult *shr2, float
 		}
 		if (addpassflag & SCE_PASS_EMIT)
 			interpolate_vec3(shr1->emit, shr2->emit, t, negt, shr->emit);
-		if (addpassflag & SCE_PASS_DIFFUSE)
+		if (addpassflag & SCE_PASS_DIFFUSE) {
 			interpolate_vec3(shr1->diff, shr2->diff, t, negt, shr->diff);
+			interpolate_vec3(shr1->diffshad, shr2->diffshad, t, negt, shr->diffshad);
+		}
 		if (addpassflag & SCE_PASS_SPEC)
 			interpolate_vec3(shr1->spec, shr2->spec, t, negt, shr->spec);
 		if (addpassflag & SCE_PASS_SHADOW)
diff --git a/source/blender/render/intern/source/volumetric.c b/source/blender/render/intern/source/volumetric.c
index 05d0eff..39950a1 100644
--- a/source/blender/render/intern/source/volumetric.c
+++ b/source/blender/render/intern/source/volumetric.c
@@ -748,6 +748,7 @@ static void volume_trace(struct ShadeInput *shi, struct ShadeResult *shr, int in
 	shr->alpha = col[3];
 	
 	copy_v3_v3(shr->diff, shr->combined);
+	copy_v3_v3(shr->diffshad, shr->diff);
 }
 
 /* Traces a shadow through the object,




More information about the Bf-blender-cvs mailing list