[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [17056] branches/sim_physics/source/ blender: * Added support for solid objects casting shadows within a volume.

Matt Ebb matt at mke3.net
Mon Oct 13 08:46:23 CEST 2008


Revision: 17056
          http://projects.blender.org/plugins/scmsvn/viewcvs.php?view=rev&root=bf-blender&revision=17056
Author:   broken
Date:     2008-10-13 08:46:23 +0200 (Mon, 13 Oct 2008)

Log Message:
-----------
* Added support for solid objects casting shadows within a volume.

Currently it only supports solid shadows - if it's a solid object, it will cast 
100% shadow. Support for transparent shadows can potentially be added down the
track.

http://mke3.net/blender/devel/rendering/volumetrics/vol_shad_internal.jpg

Modified Paths:
--------------
    branches/sim_physics/source/blender/makesdna/DNA_material_types.h
    branches/sim_physics/source/blender/render/intern/source/volumetric.c
    branches/sim_physics/source/blender/src/buttons_shading.c

Modified: branches/sim_physics/source/blender/makesdna/DNA_material_types.h
===================================================================
--- branches/sim_physics/source/blender/makesdna/DNA_material_types.h	2008-10-13 05:22:31 UTC (rev 17055)
+++ branches/sim_physics/source/blender/makesdna/DNA_material_types.h	2008-10-13 06:46:23 UTC (rev 17056)
@@ -356,7 +356,7 @@
 /* vol_shadeflag */
 #define MA_VOL_SHADED		1
 #define MA_VOL_ATTENUATED	2
-#define MA_VOL_SHADOWED		4
+#define MA_VOL_RECVSHADOW	4
 
 /* vol_phasefunc_type */
 #define MA_VOL_PH_ISOTROPIC		0

Modified: branches/sim_physics/source/blender/render/intern/source/volumetric.c
===================================================================
--- branches/sim_physics/source/blender/render/intern/source/volumetric.c	2008-10-13 05:22:31 UTC (rev 17055)
+++ branches/sim_physics/source/blender/render/intern/source/volumetric.c	2008-10-13 06:46:23 UTC (rev 17056)
@@ -292,7 +292,8 @@
 	float p;
 	float scatter_fac;
 	float shade_stepsize = vol_get_stepsize(shi, STEPSIZE_SHADE);
-			
+	float shadfac[4];
+	
 	if (lar->mode & LA_LAYER) if((lar->lay & shi->obi->lay)==0) return;
 	if ((lar->lay & shi->lay)==0) return;
 	if (lar->energy == 0.0) return;
@@ -324,7 +325,13 @@
 		/* find minimum of volume bounds, or lamp coord */
 		if (vol_get_bounds(shi, co, lv, hitco, &is, VOL_BOUNDS_SS, 0)) {
 			float dist = VecLenf(co, hitco);
+			VlakRen *vlr = (VlakRen *)is.face;
 			
+			if (vlr->mat->material_type == MA_SOLID) {
+				lacol[0] = lacol[1] = lacol[2] = 0.0f;
+				return;
+			}
+
 			if (ELEM(lar->type, LA_SUN, LA_HEMI))
 				atten_co = hitco;
 			else if ( lampdist < dist ) {
@@ -604,7 +611,7 @@
 
 void volume_trace_shadow(struct ShadeInput *shi, struct ShadeResult *shr, struct Isect *last_is)
 {
-	float hitco[3], col[4] = {0.f,0.f,0.f,0.f};
+	float hitco[3];
 	float tr[3] = {1.0,1.0,1.0};
 	float tau[3] = {0.0,0.0,0.0};
 	Isect is;
@@ -631,7 +638,6 @@
 	/* trace to find a backface, the other side bounds of the volume */
 	/* (ray intersect ignores front faces here) */
 	else if (vol_get_bounds(shi, shi->co, shi->view, hitco, &is, VOL_BOUNDS_DEPTH, 0)) {
-		float dist = VecLenf(shi->co, hitco);
 		
 		vol_get_attenuation(shi, tau, shi->co, hitco, -1.0f, shade_stepsize);
 		tr[0] = exp(-tau[0]);

Modified: branches/sim_physics/source/blender/src/buttons_shading.c
===================================================================
--- branches/sim_physics/source/blender/src/buttons_shading.c	2008-10-13 05:22:31 UTC (rev 17055)
+++ branches/sim_physics/source/blender/src/buttons_shading.c	2008-10-13 06:46:23 UTC (rev 17056)
@@ -4371,7 +4371,7 @@
 	yco -= YSPACE;
 			
 	uiBlockBeginAlign(block);
-	uiDefButBitS(block, TOG, MA_VOL_ATTENUATED, B_MATPRV, "Shading",
+	uiDefButBitS(block, TOG, MA_VOL_ATTENUATED, B_MATPRV, "Self Shading",
 		X2CLM1, yco-=BUTH, BUTW2, BUTH, &(ma->vol_shadeflag), 0, 0, 0, 0, "Uses absorption for light attenuation");
 	uiDefButF(block, NUM, B_MATPRV, "Step Size: ",
 		X2CLM1, yco-=BUTH, BUTW2, BUTH, &(ma->vol_shade_stepsize), 0.001, 100.0, 10, 2, "Step");
@@ -4388,7 +4388,10 @@
 	}
 	uiBlockEndAlign(block);
 	
-		
+	/*uiDefButBitS(block, TOG, MA_VOL_RECVSHADOW, B_MATPRV, "Receive Shadows",
+		X2CLM1, yco-=BUTH, BUTW2, BUTH, &(ma->vol_shadeflag), 0, 0, 0, 0, "Receive shadows from external objects");
+	*/
+	
 	yco = PANEL_YMAX;
 	
 	uiBlockBeginAlign(block);





More information about the Bf-blender-cvs mailing list