[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [17731] branches/soc-2007-joeedh/source/ blender/render/intern/source: fixed some strand issues

Joseph Eagar joeedh at gmail.com
Sat Dec 6 19:23:38 CET 2008


Revision: 17731
          http://projects.blender.org/plugins/scmsvn/viewcvs.php?view=rev&root=bf-blender&revision=17731
Author:   joeedh
Date:     2008-12-06 19:23:38 +0100 (Sat, 06 Dec 2008)

Log Message:
-----------
fixed some strand issues

Modified Paths:
--------------
    branches/soc-2007-joeedh/source/blender/render/intern/source/dsm.c
    branches/soc-2007-joeedh/source/blender/render/intern/source/shadeinput.c
    branches/soc-2007-joeedh/source/blender/render/intern/source/zbuf.c
    branches/soc-2007-joeedh/source/blender/render/intern/source/zbuf_dsm.c

Modified: branches/soc-2007-joeedh/source/blender/render/intern/source/dsm.c
===================================================================
--- branches/soc-2007-joeedh/source/blender/render/intern/source/dsm.c	2008-12-06 17:53:08 UTC (rev 17730)
+++ branches/soc-2007-joeedh/source/blender/render/intern/source/dsm.c	2008-12-06 18:23:38 UTC (rev 17731)
@@ -926,26 +926,10 @@
 		APixbufstrand= MEM_mapallocN(pa.rectx*pa.recty*sizeof(APixstrand), "APixbuf");
 
 	/* fill the Apixbuf */
-	if(0 == zbuffer_dsm(re, &pa, projmat, (APixstr**)dbuf->lastbuf[threadnr], 
-		                (APixstr**)dbuf->lastbufstrand[threadnr], APixbuf, 
-						APixbufstrand, &apsmbase, lay, shb, btile, sscache)) {
-		printf("nothing filled in!\n");
+	zbuffer_dsm(re, &pa, projmat, (APixstr**)dbuf->lastbuf[threadnr], 
+	           (APixstr**)dbuf->lastbufstrand[threadnr], APixbuf, 
+	            APixbufstrand, &apsmbase, lay, shb, btile, sscache);
 
-		/* nothing filled in */
-		MEM_freeN(APixbuf);
-		if(APixbufstrand) MEM_freeN(APixbufstrand);
-		MEM_freeN(pa.rectz);
-		MEM_freeN(pa.rectdaps);
-		MEM_freeN(pa.rectp);
-		dsm_freepsA(&apsmbase);
-		strand_shade_cache_free(sscache);
-
-		if (pa.clipflag) MEM_freeN(pa.clipflag);
-		return;
-	}
-	
-	printf("done zbuffering!\n");
-
 	if (pa.clipflag) MEM_freeN(pa.clipflag);
 
 	aprect= APixbuf;
@@ -1017,7 +1001,7 @@
 						/*add polygon "step" to the transmittance function,
 						  if the last sample in this transmittance function is
 						  a polygon sample*/
-						if (lastsamples[row2[a].samplenr]->type) {
+						if (ELEM(lastsamples[row2[a].samplenr]->type, DSM_FACE, DSM_STRAND)) {
 							for (c=0; c<3; c++) {
 								row[totface] = *lastsamples[row2[a].samplenr];
 								row[totface].index = c;
@@ -1173,7 +1157,6 @@
 								fac= 1.0f + mat->filter*(clr[b]-1.0f);
 								fac = clr[3]*clr[b] + fac*(1.0f-clr[3]);
 								accum[row[a].samplenr][b] *= (1.0f-clr[3])*fac;
-
 							} else {
 								row[a].value = row[a].prev->value;
 							}
@@ -1469,9 +1452,9 @@
 	}
 
 	newbias = bias;
-	//if (G.rt == 14) {
+	if (G.rt != 14) {
 		alpha = dsm_bsearch(func, zs, newbias);
-	/*} else {
+	} else {
 		for (i=0; i<func->totsamples; i++) {
 			if (zs > sample[i].depth+newbias) {
 				if (i != func->totsamples-1) {
@@ -1485,7 +1468,7 @@
 				}
 			} else break;
 		}
-	}*/
+	}
 
 	if (alpha > 1.0001) printf("alpha was greater then 1.0!! alpha: %f\n", alpha);
 

Modified: branches/soc-2007-joeedh/source/blender/render/intern/source/shadeinput.c
===================================================================
--- branches/soc-2007-joeedh/source/blender/render/intern/source/shadeinput.c	2008-12-06 17:53:08 UTC (rev 17730)
+++ branches/soc-2007-joeedh/source/blender/render/intern/source/shadeinput.c	2008-12-06 18:23:38 UTC (rev 17731)
@@ -144,10 +144,6 @@
 		set_node_shader_lamp_loop(shade_material_loop);
 	}
 	else {
-		/* copy all relevant material vars, note, keep this synced with render_types.h */
-		memcpy(&shi->r, &shi->mat->r, 23*sizeof(float));
-		shi->har= shi->mat->har;
-		
 		shade_color(shi, shr);
 	}
 }

Modified: branches/soc-2007-joeedh/source/blender/render/intern/source/zbuf.c
===================================================================
--- branches/soc-2007-joeedh/source/blender/render/intern/source/zbuf.c	2008-12-06 17:53:08 UTC (rev 17730)
+++ branches/soc-2007-joeedh/source/blender/render/intern/source/zbuf.c	2008-12-06 18:23:38 UTC (rev 17731)
@@ -1466,8 +1466,8 @@
 	if (co[1] > maxy) maxy = co[1];}
 
 #define FINDBOUNDS(minx, miny, maxx, maxy, ho1, ho2, ho3, ho4, vlr) {\
-	minx = miny = 50000.0f;\
-	maxx = maxy = -50000.0f;\
+	minx = miny = 500000.0f;\
+	maxx = maxy = -500000.0f;\
 	hoco_to_zco(zspan, co, ho1);\
 	FINDMINMAX(minx, miny, maxx, maxy, co)\
 	hoco_to_zco(zspan, co, ho2);\
@@ -1479,8 +1479,8 @@
 			FINDMINMAX(minx, miny, maxx, maxy, co) } }
 
 #define FINDBOUNDSTRAND(minx, miny, maxx, maxy) {\
-	minx = miny = 232634.0f;\
-	maxx = maxy = -2342343.0f;\
+	minx = miny = 500000.0f;\
+	maxx = maxy = -500000.0f;\
 	hoco_to_zco(zspan, co, ho1);\
 	FINDMINMAX(minx, miny, maxx, maxy, co)\
 	hoco_to_zco(zspan, co, ho2);\
@@ -1645,10 +1645,10 @@
 					sseg.v[2]= svert+1;
 					sseg.v[3]= (b < strand->totvert-2)? svert+2: svert+1;
 					
-					c1= zbuf_bucketpart_project(sseg.v[0]-strand->vert, obwinmat, bounds, sseg.v[0]->co, ho1);
-					c2= zbuf_bucketpart_project(sseg.v[1]-strand->vert, obwinmat, bounds, sseg.v[1]->co, ho2);
-					c3= zbuf_bucketpart_project(sseg.v[2]-strand->vert, obwinmat, bounds, sseg.v[2]->co, ho3);
-					c4= zbuf_bucketpart_project(sseg.v[3]-strand->vert, obwinmat, bounds, sseg.v[3]->co, ho4);
+					c1= zbuf_bucketpart_project((b > 0)? (b-1): b, obwinmat, bounds, sseg.v[0]->co, ho1);
+					c2= zbuf_bucketpart_project(b, obwinmat, bounds, sseg.v[1]->co, ho2);
+					c3= zbuf_bucketpart_project(b+1, obwinmat, bounds, sseg.v[2]->co, ho3);
+					c4= zbuf_bucketpart_project((b < strand->totvert-2)? b+2: b+1, obwinmat, bounds, sseg.v[3]->co, ho4);
 
 					if(!(c1 & c2 & c3 & c4)) {
 						FINDBOUNDSTRAND(minx, miny, maxx, maxy)
@@ -1662,11 +1662,11 @@
 				sminy -= bordery;
 				smaxx += borderx;
 				smaxy += bordery;
-				if (smaxx == minx) {
+				if (smaxx == sminx) {
 					smaxx += 1;
 					sminx -= 1;
 				}
-				if (smaxy == miny) {
+				if (smaxy == sminy) {
 					smaxy += 1;
 					sminy -= 1;
 				}

Modified: branches/soc-2007-joeedh/source/blender/render/intern/source/zbuf_dsm.c
===================================================================
--- branches/soc-2007-joeedh/source/blender/render/intern/source/zbuf_dsm.c	2008-12-06 17:53:08 UTC (rev 17730)
+++ branches/soc-2007-joeedh/source/blender/render/intern/source/zbuf_dsm.c	2008-12-06 18:23:38 UTC (rev 17731)
@@ -529,7 +529,7 @@
 							VECCOPY(vec, v1->co);
 							/* z is negative, otherwise its being clipped */
 							vec[2]-= ma->zoffs;
-							projectverto(vec, shb->persmat, hoco);
+							projectverto(vec, obwinmat, hoco);
 							fval= mul*(1.0+hoco[2]/hoco[3]);
 
 							polygon_offset= (int) fabs(zval - fval );
@@ -601,11 +601,6 @@
 			sseg.strand= strand;
 			sseg.shadow_mode = 1;
 			
-			if (G.rt == 94) {
-				Mat4CpyMat4(strand->buffer->winmat, re->winmat);
-				strand->buffer->winx = strand->buffer->winy = shb->size;
-			}
-
 			// note, these conditions are copied in shadowbuf_autoclip()
 			if(sseg.buffer->ma!= ma) {
 				ma= sseg.buffer->ma;
@@ -618,37 +613,32 @@
 
 			svert= strand->vert;
 			for(b=0; b<strand->totvert-1; b += 1, svert += 1) {
-					//sseg.v[0]= svert;
-					//sseg.v[1]= svert+1;
-					//sseg.v[2]= b < strand->totvert-2 ? svert+2 : svert+1;
-					//sseg.v[3]= b < strand->totvert-3 ? svert+3 : sseg.v[2];
+					/*
+					sseg.v[0]= svert;
+					sseg.v[1]= svert+1;
+					sseg.v[2]= b < strand->totvert-2 ? svert+2 : svert+1;
+					sseg.v[3]= b < strand->totvert-3 ? svert+3 : sseg.v[2];
+					//*/
+					//*
 					sseg.v[0]= (b > 0)? (svert-1): svert;
 					sseg.v[1]= svert;
 					sseg.v[2]= svert+1;
 					sseg.v[3]= (b < strand->totvert-2)? svert+2: svert+1;
+					//*/
 					sseg.shaded = 0;
 
 					oldwinx = strand->buffer->winx;
 					oldwiny = strand->buffer->winy;
 					strand->buffer->winx = re->winx;
 					strand->buffer->winy = re->winy;
-					strand->buffer->winmat = re->winmat;
+					strand->buffer->winmat = winmat;
 
-					c1= zbuf_part_project(cache, sseg.v[0]-strand->vert, obwinmat, bounds, sseg.v[0]->co, ho1);
-					c2= zbuf_part_project(cache, sseg.v[1]-strand->vert, obwinmat, bounds, sseg.v[1]->co, ho2);
-					c3= zbuf_part_project(cache, sseg.v[2]-strand->vert, obwinmat, bounds, sseg.v[2]->co, ho3);
-					c4= zbuf_part_project(cache, sseg.v[3]-strand->vert, obwinmat, bounds, sseg.v[3]->co, ho4);
-
-					if(!(c1 & c2 & c3 & c4)) {
-						for(zsample=0; zsample<samples; zsample++) {
-							zspan= &zspans[zsample];
-							zspan->last_apixbuf = lastbufstrand;
-							spart.zspan = &zspans[zsample];
-							//zspan->apixbuf = APixbuf;
-							//zspan->last_apixbuf = lastbuf;
-							spart.sample = zsample;
-							render_strand_segment(re, winmat, &spart, zspan, 1, &sseg);	
-						}
+					for(zsample=0; zsample<samples; zsample++) {
+						zspan= &zspans[zsample];
+						zspan->last_apixbuf = lastbufstrand;
+						spart.zspan = zspan;
+						spart.sample = zsample;
+						render_strand_segment(re, winmat, &spart, zspan, 1, &sseg);	
 					}
 					strand->buffer->winx = oldwinx;
 					strand->buffer->winy = oldwiny;
@@ -668,5 +658,5 @@
 	}
 	MEM_freeN(spart.totapixbuf);
 
-	return zvlnr;
+	return 1;
 }





More information about the Bf-blender-cvs mailing list