Distributed Raytracing in BF-Blender <-- UPDATE!!

Well… technically this isnt blender art project… but it is coding project :-D.

Distribution raytracing allows for:

  • Blurry Reflectoins and Refractions
  • Soft Raytraced shadows on all lamps
  • A huge render time increase. :wink:
    I will post more results as I render them out:

http://f00fbug.t35.com/?section=Programming&sub=distray

http://f00fbug.t35.com/distray.jpg

the patch:
http://f00fbug.t35.com/distray.patch

Enjoy!! I’m hoping this will get into 2.34. :smiley:

I’m working on making a windows build…

more goodies:

http://img27.photobucket.com/albums/v81/f00fbug/twomonkeys.jpg

grat f00f! eh… blackmage… what ever.

very cool, but the dof blur in the second one looks a bit too localized, as if in a box.

That’s not DOF, but blurry transparency on a plane.

Roel

Distray soft shadows are also faster than area light soft shadows…

i didnt record the exact render times but i tell you even with 20 samples a distray lamp was blowing past an area lamp with 9 samples. :slight_smile:

GREAT!! At the moment when i’m uploading a critical patch my web host’s FTP goes down again.

NEVER get hosing from t35.com they royally suck.

here’s the patch that fixes an incompatibilty problem wiht Windows (i never use (nor do i have) windows so i dont usually notice when things arent exactly cross platform, windows has no drand48() [how do they live???]).

It works on Linux,
me and snargle are working on windows,
and MacOSX we’ll have to check and make sure it’ll all be fine there (which i’m sure it will since it’s standardized now).

this patch hopefully will fix it… it replaces drand48 with f_rand() [a function i made that uses rand() to generate a random value].

I believe it kinda speeded things up too.


Index: renderconverter/intern/convertBlenderScene.c
===================================================================
RCS file: /cvsroot/bf-blender/blender/source/blender/renderconverter/intern/convertBlenderScene.c,v
retrieving revision 1.72
diff -u -r1.72 convertBlenderScene.c
--- renderconverter/intern/convertBlenderScene.c	12 Jul 2004 03:20:31 -0000	1.72
+++ renderconverter/intern/convertBlenderScene.c	15 Jul 2004 08:58:32 -0000
@@ -1591,6 +1591,8 @@
 	lar-&gt;bufsize = la-&gt;bufsize;
 	lar-&gt;samp = la-&gt;samp;
 	lar-&gt;soft = la-&gt;soft;
+	lar-&gt;maxsoft = la-&gt;maxsoft;
+	lar-&gt;softsamples = la-&gt;softsamples;
 	lar-&gt;shadhalostep = la-&gt;shadhalostep;
 	lar-&gt;clipsta = la-&gt;clipsta;
 	lar-&gt;clipend = la-&gt;clipend;
Index: render/extern/include/render_types.h
===================================================================
RCS file: /cvsroot/bf-blender/blender/source/blender/render/extern/include/render_types.h,v
retrieving revision 1.16
diff -u -r1.16 render_types.h
--- render/extern/include/render_types.h	26 Apr 2004 21:38:35 -0000	1.16
+++ render/extern/include/render_types.h	15 Jul 2004 08:58:32 -0000
@@ -234,7 +234,8 @@
 	float xsp, ysp, distkw, inpr;
 	float halokw, halo;
 	float ld1,ld2;
-
+	float maxsoft;
+	int softsamples;
 	/* copied from Lamp, to decouple more rendering stuff */
 	/** Size of the shadowbuffer */
 	short bufsize;
@@ -269,4 +270,3 @@
 } LampRen;
 
 #endif /* RENDER_TYPES_H */
-
Index: render/intern/source/ray.c
===================================================================
RCS file: /cvsroot/bf-blender/blender/source/blender/render/intern/source/ray.c,v
retrieving revision 1.40
diff -u -r1.40 ray.c
--- render/intern/source/ray.c	21 Jun 2004 16:07:50 -0000	1.40
+++ render/intern/source/ray.c	15 Jul 2004 08:58:34 -0000
@@ -58,7 +58,7 @@
 #define DEPTH_SHADOW_TRA  10
 /* from float.h */
 #define FLT_EPSILON 1.19209290e-07F
-
+float f_rand(); // get this from rendercore.c
 
 /* ********** structs *************** */
 
@@ -1403,6 +1403,7 @@
 	refract[0]= index*view[0] + fac*n[0];
 	refract[1]= index*view[1] + fac*n[1];
 	refract[2]= index*view[2] + fac*n[2];
+	
 }
 
 /* orn = original face normal */
@@ -1455,6 +1456,59 @@
 #endif
 
 /* the main recursive tracer itself */
+void
+getRandomVec (float *vec, float max)
+{
+  
+  
+  
+	
+  vec[0] = (float) (f_rand () * (max*2))-max;
+  vec[1] = (float) (f_rand () * (max*2))-max;
+  vec[2] = (float) (f_rand () * (max*2))-max;
+  
+}
+void
+rotateVec (float *newvec, float *originvec, float *rotatevec, float ax,
+	   float ay, float az)
+{				// we are going to be doing this alot since the way i am sampling is based on random angles
+  float othervec[3], tempvec1[3], tempvec2[3];	// there has GOT TO BE a better way of doing this!
+
+  othervec[0] = rotatevec[0] - originvec[0];
+  othervec[1] = rotatevec[1] - originvec[1];
+  othervec[2] = rotatevec[2] - originvec[2];	// make sure this is realitivized to teh origin.. then we simply translate after rotation around the origin. THANK YOU EUCLID!!!
+
+  tempvec1[0] = othervec[0] * cos (az) + othervec[1] * sin (az);	// x1 =  x * cz +  y * sz
+  tempvec1[1] = othervec[1] * cos (ax) - othervec[0] * sin (az);	// y1 =  y * cz -  x * sz
+  tempvec1[2] = othervec[2];	// z1 = z
+
+  tempvec2[0] = tempvec1[0] * cos (ay) + tempvec1[2] * sin (ay);	// x2 = x1 * cy + z1 * sy
+  tempvec2[1] = tempvec1[2];	// y2 = z1;
+  tempvec2[2] = tempvec1[2] * cos (ay) - tempvec1[0] * sin (ay);	// z2 = z1 * cy - x1 * sy
+
+  newvec[0] = tempvec2[0];	// x3 = x2
+  newvec[1] = tempvec2[1] * cos (ax) + tempvec1[2] * sin (ax);	// y3 = y2 * cx + z1 * sx
+  newvec[2] = tempvec2[2] * cos (ax) - tempvec1[0] * sin (ax);	// z3 = z2 * cx - x1 * sx
+
+  newvec[0] += originvec[0];
+  newvec[1] += originvec[1];
+  newvec[2] += originvec[2];
+
+
+
+}
+void
+clipVec (float *vec) 
+{
+  if (vec[0] &gt; 1.0)
+    vec[0] = 1.0;
+  if (vec[1] &gt; 1.0)
+    vec[1] = 1.0;
+  if (vec[2] &gt; 1.0)
+    vec[2] = 1.0;
+}
+
+
 static void traceray(short depth, float *start, float *vec, float *col, VlakRen *vlr, int mask)
 {
 	ShadeInput shi;
@@ -1462,7 +1516,7 @@
 	Isect isec;
 	float f, f1, fr, fg, fb;
 	float ref[3];
-	
+	float norref[3];
 	VECCOPY(isec.start, start);
 	isec.end[0]= start[0]+g_oc.ocsize*vec[0];
 	isec.end[1]= start[1]+g_oc.ocsize*vec[1];
@@ -1477,10 +1531,39 @@
 		if(depth&gt;0) {
 
 			if(shi.matren-&gt;mode & MA_RAYTRANSP && shr.alpha!=1.0) {
-				float f, f1, refract[3], tracol[3];
+				float f, f1, refract[3], tracol[3], nor[3];
+				
+				
 				
-				refraction(refract, shi.vn, shi.view, shi.matren-&gt;ang);
-				traceray(depth-1, shi.co, refract, tracol, shi.vlr, shi.mask);
+				if (shi.matren-&gt;mode & MA_BLURRY) {
+					int i;
+					float ccol[3], scol[3];
+					memset (scol, 0, sizeof(scol));
+					for (i=0; i &lt; shi.matren-&gt;blursamples; i++) {
+					
+					getRandomVec(nor, shi.matren-&gt;blurfactor);
+					
+					
+					
+					
+					
+					refraction(refract, shi.vn, shi.view, shi.matren-&gt;ang);  
+					VECADD(refract,refract,nor);
+					Normalise(refract);	
+					traceray(depth-1, shi.co, refract, ccol, shi.vlr, shi.mask);
+					VECADD(scol,scol,ccol);
+					
+					}
+					scol[0]/=(float)shi.matren-&gt;blursamples;
+					scol[1]/=(float)shi.matren-&gt;blursamples;
+					scol[2]/=(float)shi.matren-&gt;blursamples;
+					VECCOPY(tracol, scol);
+					
+					}
+					else {
+					refraction(refract, shi.vn, shi.view, shi.matren-&gt;ang); 
+					traceray(depth-1, shi.co, refract, tracol, shi.vlr, shi.mask);
+				}
 				
 				f= shr.alpha; f1= 1.0-f;
 				shr.diff[0]= f*shr.diff[0] + f1*tracol[0];
@@ -1488,7 +1571,7 @@
 				shr.diff[2]= f*shr.diff[2] + f1*tracol[2];
 				shr.alpha= 1.0;
 			}
-
+		
 			if(shi.matren-&gt;mode & MA_RAYMIRROR) {
 				f= shi.matren-&gt;ray_mirror;
 				if(f!=0.0) f*= fresnel_fac(shi.view, shi.vn, shi.matren-&gt;fresnel_mir_i, shi.matren-&gt;fresnel_mir);
@@ -1497,11 +1580,35 @@
 			
 			if(f!=0.0) {
 			
+
+				if (shi.matren-&gt;mode & MA_BLURRY) {
+					float nor[3], ccol[3],scol[3];	
+					int i;
+					memset(scol,0,sizeof(scol));
+					for (i=0; i &lt; shi.matren-&gt;blursamples; i++) {
+					getRandomVec(nor, shi.matren-&gt;blurfactor);
+					VECADD(nor,nor,shi.vn);
+					Normalise(nor); // make sure norref is a normal
+					
+					// by modifiying vn we can effectively achieve blurry oversampling
+					
+					reflection(ref, nor, shi.view, NULL);  
+					traceray(depth-1, shi.co, ref, ccol, shi.vlr, shi.mask);
+					VECADD(scol,scol,ccol);
+					
+					}
+					scol[0] /= (float)shi.matren-&gt;blursamples;
+					scol[1] /= (float)shi.matren-&gt;blursamples;
+					scol[2] /= (float)shi.matren-&gt;blursamples;
+					VECCOPY(col,scol);
+					}
+					else {
 				reflection(ref, shi.vn, shi.view, NULL);			
 				traceray(depth-1, shi.co, ref, col, shi.vlr, shi.mask);
+					}
 			
 				f1= 1.0-f;
-
+				 
 				/* combine */
 				//color_combine(col, f*fr*(1.0-shr.spec[0]), f1, col, shr.diff);
 				//col[0]+= shr.spec[0];
@@ -1668,11 +1775,13 @@
 void ray_trace(ShadeInput *shi, ShadeResult *shr)
 {
 	VlakRen *vlr;
-	float i, f, f1, fr, fg, fb, vec[3], mircol[3], tracol[3];
-	int do_tra, do_mir;
+	float i, f, f1, fr, fg, fb, vec[3], mircol[3], tracol[3], plugcol[3];
+	int do_tra, do_mir,do_plugin;
 	
 	do_tra= ((shi-&gt;matren-&gt;mode & MA_RAYTRANSP) && shr-&gt;alpha!=1.0);
 	do_mir= ((shi-&gt;matren-&gt;mode & MA_RAYMIRROR) && shi-&gt;matren-&gt;ray_mirror!=0.0);
+
+	
 	vlr= shi-&gt;vlr;
 	
 	coh_test= 0;		// reset coherence optimize
@@ -1680,8 +1789,38 @@
 	if(do_tra) {
 		float refract[3];
 		
+
+		if (shi-&gt;matren-&gt;mode & MA_BLURRY) {
+					
+			float nor[3], ccol[3],scol[3];	
+				memset(scol,0,sizeof(scol));
+				int i;
+				for (i=0; i &lt; shi-&gt;matren-&gt;blursamples; i++) {
+					getRandomVec(nor, shi-&gt;matren-&gt;blurfactor);
+					//VECADD(nor,nor,shi-&gt;vn);
+					
+					
+					
+					// by modifiying vn we can effectively achieve blurry oversampling
+					
+					refraction(refract, shi-&gt;vn, shi-&gt;view, shi-&gt;matren-&gt;ang);
+					VECADD(refract, refract, nor);
+					Normalise(refract);
+					traceray(shi-&gt;matren-&gt;ray_depth_tra, shi-&gt;co, refract, ccol, shi-&gt;vlr, shi-&gt;mask);
+					VECADD(scol,scol,ccol);
+					
+			
+		}
+		scol[0] /= (float)shi-&gt;matren-&gt;blursamples;
+					scol[1] /= (float)shi-&gt;matren-&gt;blursamples;
+					scol[2] /= (float)shi-&gt;matren-&gt;blursamples;
+					VECCOPY(tracol,scol);
+	}
+		else {
 		refraction(refract, shi-&gt;vn, shi-&gt;view, shi-&gt;matren-&gt;ang);
-		traceray(shi-&gt;matren-&gt;ray_depth_tra, shi-&gt;co, refract, tracol, shi-&gt;vlr, shi-&gt;mask);
+			traceray(shi-&gt;matren-&gt;ray_depth_tra, shi-&gt;co, refract, tracol, shi-&gt;vlr, shi-&gt;mask);
+		}
+		
 		
 		f= shr-&gt;alpha; f1= 1.0-f;
 		shr-&gt;diff[0]= f*shr-&gt;diff[0] + f1*tracol[0];
@@ -1689,7 +1828,7 @@
 		shr-&gt;diff[2]= f*shr-&gt;diff[2] + f1*tracol[2];
 		shr-&gt;alpha= 1.0;
 	}
-	
+
 	if(do_mir) {
 	
 		i= shi-&gt;matren-&gt;ray_mirror*fresnel_fac(shi-&gt;view, shi-&gt;vn, shi-&gt;matren-&gt;fresnel_mir_i, shi-&gt;matren-&gt;fresnel_mir);
@@ -1697,13 +1836,40 @@
 			fr= shi-&gt;matren-&gt;mirr;
 			fg= shi-&gt;matren-&gt;mirg;
 			fb= shi-&gt;matren-&gt;mirb;
-
+			if (shi-&gt;matren-&gt;mode & MA_BLURRY) {
+				
+			
+				float nor[3], ccol[3],scol[3];	
+				int i;
+				memset(scol,0,sizeof(scol));
+				for (i=0; i &lt; shi-&gt;matren-&gt;blursamples; i++) {
+					getRandomVec(nor, shi-&gt;matren-&gt;blurfactor);
+					VECADD(nor,nor,shi-&gt;vn);
+					Normalise(nor); // make sure norref is a normal
+					
+					// by modifiying vn we can effectively achieve blurry oversampling
+					
+				if(vlr-&gt;flag & R_SMOOTH) 
+					reflection(vec, nor, shi-&gt;view, vlr-&gt;n);
+				else
+					reflection(vec, nor	, shi-&gt;view, NULL);
+				
+					traceray(shi-&gt;matren-&gt;ray_depth, shi-&gt;co, vec, ccol, shi-&gt;vlr, shi-&gt;mask);
+					VECADD(scol,scol,ccol);
+				
+					}
+						scol[0] /= (float)shi-&gt;matren-&gt;blursamples;
+					scol[1] /= (float)shi-&gt;matren-&gt;blursamples;
+					scol[2] /= (float)shi-&gt;matren-&gt;blursamples;
+					VECCOPY(mircol,scol);
+			
+		} else {
 			if(vlr-&gt;flag & R_SMOOTH) 
 				reflection(vec, shi-&gt;vn, shi-&gt;view, vlr-&gt;n);
 			else
 				reflection(vec, shi-&gt;vn, shi-&gt;view, NULL);
-	
 			traceray(shi-&gt;matren-&gt;ray_depth, shi-&gt;co, vec, mircol, shi-&gt;vlr, shi-&gt;mask);
+			}
 			
 			f= i*fr*(1.0-shr-&gt;spec[0]);	f1= 1.0-i;
 			shr-&gt;diff[0]= f*mircol[0] + f1*shr-&gt;diff[0];
@@ -2143,4 +2309,3 @@
 	
 	
 }
-
Index: render/intern/source/rendercore.c
===================================================================
RCS file: /cvsroot/bf-blender/blender/source/blender/render/intern/source/rendercore.c,v
retrieving revision 1.70
diff -u -r1.70 rendercore.c
--- render/intern/source/rendercore.c	8 Jul 2004 20:38:24 -0000	1.70
+++ render/intern/source/rendercore.c	15 Jul 2004 08:58:37 -0000
@@ -98,7 +98,9 @@
 void scanlinehalo(unsigned int *rectz, unsigned int *rectt, short ys);
 /*  void add_halo_flare(void); */
 void edge_enhance(void);
-
+float f_rand() {  // mother of all rude awakenings: Win32 has no drand48... 
+		return ((float) (rand() % 32767)) / (32767.0f);
+	}
 /* Dither with gamma table? */
 void gamtabdit(unsigned short *in, char *out)
 /*  unsigned short *in; */
@@ -1384,6 +1386,15 @@
 }
 
 /* Blinn spec */
+#if 0
+float PluginSpec(float *n, float *l, float *v, BlenderPlugin *plugin) {
+		(float) (*spec_cb ( float , float , float, unsigned char**) = PLUG_GetCallback(plugin, PLUG_AREA_SPEC);
+	    unsigned char *pushargs = NULL;
+		
+		PLUG_GetArgValues(plugin, PLUG_SHADER_SPEC, pushargs); // these are stored in some database
+		return (*spec_cb)(n,l,v,pushargs); 
+	}
+#endif
 float Blinn_Spec(float *n, float *l, float *v, float refrac, float spec_power )
 {
 	float i, nh, nv, nl, vh, h[3];
@@ -1459,8 +1470,16 @@
 	
 	return rslt;
 }
-
-/* cartoon render diffuse */
+#if 0
+// plugin diffuse
+float PluginDiff( float *n, float *l, float *v, BlenderPlugin *plugin) {
+		float (*diff_cb) (float,float,float,va_list*) = plugin-&gt;callbacks[PLUG_DIFF_CB];
+		
+		return (*diff_cb) (n,l,v,plugin-&gt;pushargs);
+	}
+#endif
+	
+	/* cartoon render diffuse */
 float Toon_Diff( float *n, float *l, float *v, float size, float smooth )
 {
 	float rslt, ang;
@@ -1947,7 +1966,65 @@
 				
 				/* single sided? */
 				if( shi-&gt;vlr-&gt;n[0]*lv[0] + shi-&gt;vlr-&gt;n[1]*lv[1] + shi-&gt;vlr-&gt;n[2]*lv[2] &gt; -0.01) {
-					ray_shadow(shi, lar, shad);
+					
+									if (lar-&gt;mode & LA_SHAD_SOFT) {
+						//printf("SOFT PLEASE!! Soft:%f Samp%d",lar-&gt;soft,lar-&gt;samp);
+//						lar-&gt;maxsoft = lar-&gt;soft;
+//						lar-&gt;softsamples= lar-&gt;samp;
+
+						
+						float oro[3];
+						if (lar-&gt;type != LA_SUN) {VECCOPY(oro,lar-&gt;co);} else {VECCOPY(oro,lar-&gt;vec);}
+						float sx,sy,sz;
+						float coolshad[3];
+						int i;
+						memset (coolshad, 0, sizeof(coolshad)); // we need to reset it
+						for (i=0; i &lt; lar-&gt;softsamples; i++) {
+						sx=(float)f_rand() * lar-&gt;maxsoft;
+						sy=(float)f_rand() *lar-&gt;maxsoft;
+						sz=(float)f_rand() *lar-&gt;maxsoft;
+						if (lar-&gt;type != LA_SUN) {
+						lar-&gt;co[0] += sx;
+						lar-&gt;co[1] += sy;
+						lar-&gt;co[2] += sz;
+						}
+						else {
+							lar-&gt;vec[0]+=sx;
+							lar-&gt;vec[1]+=sy;
+							lar-&gt;vec[2]+=sz;
+							//Normalise(lar-&gt;vec);	
+							}
+//[2[2]]						if (!onSameSide (oro, shi-&gt;co, shi-&gt;vlr-&gt;n, shi-&gt;vlr-&gt;v1-&gt;co)) {
+//							sx=-sx;
+//							sy=-sy;
+//							sz=-sz;
+//							shi-&gt;co[0] = oro[0] + sx;
+//							shi-&gt;co[1] = oro[1] + sy;
+//							shi-&gt;co[2] = oro[2]+ sz; // if we went thorugh make sure we dont this time.							
+							
+//							
+//						}
+						ray_shadow(shi,lar,shad);	
+						coolshad[0] += shad[0];
+						coolshad[1] += shad[1];
+						coolshad[2] += shad[2];
+						if (lar-&gt;type != LA_SUN) {
+						lar-&gt;co[0] = oro[0]; // reset lar-&gt;co
+						lar-&gt;co[1] = oro[1];
+						lar-&gt;co[2] = oro[2];
+						}
+						else {
+								VECCOPY(lar-&gt;vec, oro);
+							}
+						}
+						shad[0] = coolshad[0]/lar-&gt;softsamples;
+						shad[1] = coolshad[1]/lar-&gt;softsamples;
+						shad[2] = coolshad[2]/lar-&gt;softsamples;
+
+						
+					} else {
+						ray_shadow(shi, lar, shad);
+					}
 					shadfac[3]+= shad[3];
 					ir+= 1.0;
 				}
@@ -2151,9 +2228,72 @@
 						}
 						else if(lar-&gt;mode & LA_SHAD_RAY) {
 							// this extra 0.001 prevents boundary cases (shadow on smooth sphere)
-							if((shi-&gt;vlr-&gt;n[0]*lv[0] + shi-&gt;vlr-&gt;n[1]*lv[1] + shi-&gt;vlr-&gt;n[2]*lv[2]) &gt; -0.001) 
-								ray_shadow(shi, lar, shadfac);
-							else shadfac[3]= 0.0;
+							if((shi-&gt;vlr-&gt;n[0]*lv[0] + shi-&gt;vlr-&gt;n[1]*lv[1] + shi-&gt;vlr-&gt;n[2]*lv[2]) &gt; -0.001) {
+												if (lar-&gt;mode & LA_SHAD_SOFT) {
+						//printf("SOFT PLEASE!! Soft:%f Samp%d",lar-&gt;soft,lar-&gt;samp);
+//						lar-&gt;maxsoft = lar-&gt;soft;
+//						lar-&gt;softsamples= lar-&gt;samp;
+
+						
+						float oro[3];
+						if (lar-&gt;type != LA_SUN) {VECCOPY(oro, lar-&gt;co);} else {VECCOPY(oro, lar-&gt;vec);}
+						
+						float sx,sy,sz;
+						float coolshad[3];
+						int i;
+						memset (coolshad, 0, sizeof(coolshad));
+						for (i=0; i &lt; lar-&gt;softsamples; i++) {
+						sx=(float)f_rand() * lar-&gt;maxsoft;
+						sy=(float)f_rand() *lar-&gt;maxsoft;
+						sz=(float)f_rand() *lar-&gt;maxsoft;
+						if (lar-&gt;type != LA_SUN) {
+						lar-&gt;co[0] += sx;
+						lar-&gt;co[1] += sy;						
+						lar-&gt;co[2] += sz;
+						}
+						else {
+							lar-&gt;vec[0]+= sx;
+							lar-&gt;vec[1]+= sy;
+							lar-&gt;vec[2]+=sz;
+								Normalise(lar-&gt;vec);							
+							}
+							
+//[2[2]]						if (!onSameSide (oro, shi-&gt;co, shi-&gt;vlr-&gt;n, shi-&gt;vlr-&gt;v1-&gt;co)) {
+//							sx=-sx;
+//							sy=-sy;
+//							sz=-sz;
+//							shi-&gt;co[0] = oro[0] + sx;
+//							shi-&gt;co[1] = oro[1] + sy;
+//							shi-&gt;co[2] = oro[2]+ sz; // if we went thorugh make sure we dont this time.							
+							
+//							
+//						}
+						ray_shadow(shi,lar,shadfac);	
+						coolshad[0] += shadfac[0];
+						coolshad[1] += shadfac[1];
+						coolshad[2] += shadfac[2];
+						coolshad[3] += shadfac[3];
+						if (lar-&gt;type != LA_SUN) {
+							
+						lar-&gt;co[0] = oro[0]; // reset lar-&gt;co
+						lar-&gt;co[1] = oro[1];
+						lar-&gt;co[2] = oro[2];
+						}
+						else {
+							VECCOPY(lar-&gt;vec, oro);					
+							}
+						
+							}
+						shadfac[0] = coolshad[0]/lar-&gt;softsamples;
+						shadfac[1] = coolshad[1]/lar-&gt;softsamples;
+						shadfac[2] = coolshad[2]/lar-&gt;softsamples;
+						shadfac[3] = coolshad[3]/lar-&gt;softsamples;
+						
+					} else {
+						ray_shadow(shi, lar, shadfac);
+					}	
+											}
+							else{ shadfac[3]= 0.0;}
 						}
 	
 						/* warning, here it skips the loop */
@@ -2294,6 +2434,8 @@
 
 }
 
+
+
 void shade_input_set_coords(ShadeInput *shi, float u, float v, int i1, int i2, int i3)
 {
 	VertRen *v1, *v2, *v3;
@@ -3559,5 +3701,3 @@
 
 
 /* end of render.c */
-
-
Index: makesdna/DNA_lamp_types.h
===================================================================
RCS file: /cvsroot/bf-blender/blender/source/blender/makesdna/DNA_lamp_types.h,v
retrieving revision 1.10
diff -u -r1.10 DNA_lamp_types.h
--- makesdna/DNA_lamp_types.h	29 Dec 2003 16:52:49 -0000	1.10
+++ makesdna/DNA_lamp_types.h	15 Jul 2004 08:58:37 -0000
@@ -55,7 +55,8 @@
 	short bufsize, samp;
 	float clipsta, clipend, shadspotsize;
 	float bias, soft;
-	
+	float maxsoft;
+	short softsamples, schwartz;
 	short ray_samp, ray_sampy, ray_sampz, ray_samp_type;
 	short area_shape, pad;
 	float area_size, area_sizey, area_sizez;
@@ -93,6 +94,7 @@
 #define LA_NO_DIFF		2048
 #define LA_NO_SPEC		4096
 #define LA_SHAD_RAY		8192
+#define LA_SHAD_SOFT	16384
 
 /* area shape */
 #define LA_AREA_SQUARE	0
@@ -111,4 +113,3 @@
 
 
 #endif /* DNA_LAMP_TYPES_H */
-
Index: makesdna/DNA_material_types.h
===================================================================
RCS file: /cvsroot/bf-blender/blender/source/blender/makesdna/DNA_material_types.h,v
retrieving revision 1.17
diff -u -r1.17 DNA_material_types.h
--- makesdna/DNA_material_types.h	30 Jun 2004 18:54:08 -0000	1.17
+++ makesdna/DNA_material_types.h	15 Jul 2004 08:58:38 -0000
@@ -54,7 +54,7 @@
 	float specr, specg, specb;
 	float mirr, mirg, mirb;
 	float ambr, ambb, ambg;
-	
+	float blurfactor; int blursamples;
 	float amb, emit, ang, spectra, ray_mirror;
 	float alpha, ref, spec, zoffs, add;
 	float translucency;
@@ -112,6 +112,8 @@
 #define MA_YUV			2
 #define MA_HSV			3
 
+
+
 /* mode (is int) */
 #define MA_TRACEBLE		1
 #define MA_SHADOW		2
@@ -140,7 +142,7 @@
 #define MA_SHADOW_TRA	0x80000
 #define MA_RAMP_COL		0x100000
 #define MA_RAMP_SPEC	0x200000
-
+#define MA_BLURRY		0x400000
 /* diff_shader */
 #define MA_DIFF_LAMBERT		0
 #define MA_DIFF_ORENNAYAR	1
@@ -208,4 +210,3 @@
 #define MA_DARK			1
 
 #endif
-
Index: src/buttons_shading.c
===================================================================
RCS file: /cvsroot/bf-blender/blender/source/blender/src/buttons_shading.c,v
retrieving revision 1.88
diff -u -r1.88 buttons_shading.c
--- src/buttons_shading.c	10 Jul 2004 21:35:17 -0000	1.88
+++ src/buttons_shading.c	15 Jul 2004 08:58:43 -0000
@@ -2090,7 +2090,14 @@
 	uiBlockEndAlign(block);
 	
 	uiDefButS(block, TOG|BIT|5, 0,"OnlyShadow",			10,110,80,19,&la-&gt;mode, 0, 0, 0, 0, "Causes light to cast shadows only without illuminating objects");
-
+	if (la-&gt;type != LA_AREA && (la-&gt;mode & LA_SHAD_RAY)) {
+		uiBlockBeginAlign(block);
+		uiDefButS(block, TOG|BIT|14, 0, "Soft", 100,70,100,19, &la-&gt;mode, 0, 0,0,0,"Turns on distributed sampling for soft shadows");
+		
+		uiDefButF(block, NUMSLI, 0, "Softness", 100,50,200,19,&la-&gt;maxsoft,0.0,5.0,0,0,"Sets the softness factor for shadows");
+		uiDefButI(block, NUMSLI, 0, "Samples", 100, 30, 200, 19, &la-&gt;softsamples,0,100,0,0,"Soft Samples to take");
+		uiBlockEndAlign(block);
+	}
 	if(la-&gt;type==LA_SPOT) {
 		uiDefButS(block, TOG|BIT|7, B_LAMPREDRAW,"Square",	10,70,80,19,&la-&gt;mode, 0, 0, 0, 0, "Sets square spotbundles");
 		uiDefButS(block, TOG|BIT|1, 0,"Halo",				10,50,80,19,&la-&gt;mode, 0, 0, 0, 0, "Renders spotlight with a volumetric halo"); 
@@ -2573,6 +2580,16 @@
 	uiBlockSetCol(block, TH_AUTO);
 }
 
+static void material_panel_blurry(Material *ma) { 
+		uiBlock *block= uiNewBlock(&curarea-&gt;uiblocks, "material_panel_blurry", UI_EMBOSS, UI_HELV, curarea-&gt;win);
+		uiNewPanelTabbed("Mirror Transp","Material");
+		if (uiNewPanel(curarea, block, "Blurry","Material", 640, 0, 318, 204) ==0) return;
+			
+			uiDefButI(block, TOG|BIT|22, 0,"Blurry", 210,180,100,20, &(ma-&gt;mode),0,0,0,0,"Enables Blurry oversampling for raytracing");
+			uiDefButF(block, NUMSLI, 0,"BlurFactor", 10,160,200,20, &(ma-&gt;blurfactor),0.0,1.0,0.0,0.0,"The Maximum random vector");			
+			uiDefButI(block, NUM, 0, "Samples", 210, 160, 100, 20, &(ma-&gt;blursamples),2.0,100.0,0,0,"The Number of samples to take");
+
+	}
 static void material_panel_tramir(Material *ma)
 {
 	uiBlock *block;
@@ -2933,6 +2950,9 @@
 			material_panel_ramps(ma);
 			material_panel_shading(ma);
 			material_panel_tramir(ma);
+			if ((ma-&gt;mode & MA_RAYMIRROR) || (ma-&gt;mode & MA_RAYTRANSP)) {
+					material_panel_blurry(ma);
+				}
 			material_panel_texture(ma);
 			
 			mtex= ma-&gt;mtex[ ma-&gt;texact ];
@@ -3164,5 +3184,3 @@
 
 	
 }
-
-

[edit]

At last the return of soft shadows for all lamps !! Hurrah !
This would an awesome addition to 2.34 - if it gets in. :slight_smile:

Marty_D, just do it my way, take one hour of your life to do the patch by hand 8)
and finally find out that you left a “+” sign hanging somewhere preventing the compile…
well, compiling again…

I’ll keep you guys posted

Dani

Hello!

okay doing the patch by hand seems to work !

It’s very convincing, but still, isn’t there any place for speed up?
I dunnon if this is fiction, but maybe using a cone to determine for which pixels the blurring should be used…

The cone’s angle should be evalutaed for each object… (and of course a lampe can have many cones…) Then from the cameras coordinates, you see which pixels are in the cone or not, etc…

oh well, you probably know these things better than I do :smiley:

I’ll keep on testing! and patching if i have enough courage or if I understand how to patch autmatically :]

ciao
Dani

[edit]

[edit]

ROTFL :slight_smile:

Code ninja? naaah! something more like a copy-paste-edit robot :wink: just turn off your brain and let your hands run !

Anyway, I’m still interested in learning how to patch .

Well, I’ll continue with some tests… I have a fedora 2 build dynamic for glibc 2.5 I think (well, the latest glibc), Athlon Xp optimised, I may be able to place it somewhere if anybody is interested… I can try to build with windows too. Should i take off the Athlon Xp Optims?

Ciao
Dani

[edit]

Great idea man! :smiley:

Hello…

Finished building and uploading the builds…

check here:

http://dani2.chez.tiscali.fr/

Dani

[edit]

Marty_D: make sure the soft button is on and that softness and samples is nonzero.