[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [11438] branches/soc-2007-joeedh/source/ blender: =Working commit=

Joseph Eagar joeedh at gmail.com
Tue Jul 31 02:37:14 CEST 2007


Revision: 11438
          http://projects.blender.org/plugins/scmsvn/viewcvs.php?view=rev&root=bf-blender&revision=11438
Author:   joeedh
Date:     2007-07-31 02:37:14 +0200 (Tue, 31 Jul 2007)

Log Message:
-----------
=Working commit=

This is another nothing-works commit, done so others can look at the
current state of the code.

Modified Paths:
--------------
    branches/soc-2007-joeedh/source/blender/blenkernel/BKE_dsm.h
    branches/soc-2007-joeedh/source/blender/blenkernel/intern/tcs_dsm.c
    branches/soc-2007-joeedh/source/blender/render/intern/source/shadbuf.c
    branches/soc-2007-joeedh/source/blender/render/intern/source/zbuf.c

Modified: branches/soc-2007-joeedh/source/blender/blenkernel/BKE_dsm.h
===================================================================
--- branches/soc-2007-joeedh/source/blender/blenkernel/BKE_dsm.h	2007-07-30 20:04:23 UTC (rev 11437)
+++ branches/soc-2007-joeedh/source/blender/blenkernel/BKE_dsm.h	2007-07-31 00:37:14 UTC (rev 11438)
@@ -41,7 +41,7 @@
 	TCS_Tile tile;
 	DSMFunction **layer_rect;
 	
-	DSMLayerSample **sample_rect; /*first entry's depth is the length of the pixel array*/
+	//DSMLayerSample **sample_rect; /*first entry's depth is the length of the pixel array*/
 	
 	/*tile coordinates inside poly_rect.
 	  Note: this is *not* in image space units!

Modified: branches/soc-2007-joeedh/source/blender/blenkernel/intern/tcs_dsm.c
===================================================================
--- branches/soc-2007-joeedh/source/blender/blenkernel/intern/tcs_dsm.c	2007-07-30 20:04:23 UTC (rev 11437)
+++ branches/soc-2007-joeedh/source/blender/blenkernel/intern/tcs_dsm.c	2007-07-31 00:37:14 UTC (rev 11438)
@@ -66,9 +66,9 @@
 
 	self->arena = BLI_memarena_new(1<<18);
 	BLI_memarena_use_mapalloc(self->arena);
-	self->sample_rect = BLI_memarena_alloc(self->arena, sizeof(void*)*self->sizex*self->sizey);
+	self->layer_rect = BLI_memarena_alloc(self->arena, sizeof(void*)*self->sizex*self->sizey);
 	
-	memset(self->sample_rect, 0, sizeof(void*)*self->sizex*self->sizey);
+	memset(self->layer_rect, 0, sizeof(void*)*self->sizex*self->sizey);
 	
 	TCS_fread(&magic, sizeof(int), 1, file);
 	if (magic != DSM_MAGICNUM) {
@@ -93,7 +93,7 @@
 			//fflush(stderr);
 		//}
 		
-		sample = self->sample_rect[y*self->sizex+x] = BLI_memarena_alloc(self->arena, sizeof(DSMLayerSample)*(totdepth+1));
+		sample = self->layer_rect[y*self->sizex+x] = BLI_memarena_alloc(self->arena, sizeof(DSMLayerSample)*(totdepth+1));
 		sample[0].depth = totdepth;
 		
 		sample++;
@@ -139,10 +139,10 @@
 
 	for (y=0; y<self->sizey; y++) {
 		for (x=0; x<self->sizex; x++) {
-			if (self->sample_rect[y*self->sizex+x]) {
+			if (self->layer_rect[y*self->sizex+x]) {
 				tot++;
 				
-				first = self->sample_rect[y*self->sizex+x];
+				first = self->layer_rect[y*self->sizex+x];
 				sample = first + 1;
 				
 				TCS_fwrite(&x, sizeof(int), 1, file);
@@ -190,7 +190,7 @@
 	
 	BLI_memarena_free(self->arena);
 	self->arena = NULL;
-	self->sample_rect = NULL;
+	self->layer_rect = NULL;
 	
 	#ifdef TCSDEBUG
 		printf("----tile len of doom: %d------\n", (int)(fend - curpos));
@@ -204,7 +204,7 @@
 {
 	DSMTile *tile = (DSMTile*) tself;
 	
-	return tile->sample_rect[y*tile->sizex+x];
+	return tile->layer_rect[y*tile->sizex+x];
 }
 
 unsigned int dsm_gettilemem(TCS_Tile *tself)

Modified: branches/soc-2007-joeedh/source/blender/render/intern/source/shadbuf.c
===================================================================
--- branches/soc-2007-joeedh/source/blender/render/intern/source/shadbuf.c	2007-07-30 20:04:23 UTC (rev 11437)
+++ branches/soc-2007-joeedh/source/blender/render/intern/source/shadbuf.c	2007-07-31 00:37:14 UTC (rev 11438)
@@ -422,6 +422,7 @@
 
 		/* printf("lampbuf %d\n", sizeoflampbuf(shb)); */
 	} else if (lar->buftype == LA_SHADBUF_DEEP) {
+		R = *re;
 		shb->jit= give_jitter_tab(shb->samp);
 		make_jitter_weight_tab(shb, lar->filtertype);
 
@@ -661,23 +662,23 @@
 	//printf("2: xs: %d, ys: %d, zs: %d\n", xs, ys, zs);
 	func = tile->layer_rect[ys*tile->sizex+xs];
 	
-	if (!func || !func->totsamples) return 1.0;
+	if (!func || !func->totsamples || !func->samples) return 1.0;
 	sample = func->samples;
 
 	alpha = 1.0;
 
-	bias=bias/10.0; //odd that I have to do this :/
+	bias=bias/6.0; //odd that I have to do this :/
 	//clr = dsm_bsearch(sample, zs, bias);
 
 	for (i=0; i<func->totsamples-1; i++) {
-		if (zs < sample[i+1].depth+bias && zs > sample[i].depth+bias) {
+		if (zs > (sample[i].depth+bias) && zs < (sample[i+1].depth+bias)) {
 			BASSERT(sample[i].clr[3] >= 0);
 			BASSERT(sample[i+1].clr[3] >= 0);
 			
 			BASSERT(sample[i].depth < sample[i+1].depth);
 			BASSERT(zs > sample[i].depth+bias);
 
-			alpha = lerp(sample[i].depth, sample[i+1].depth, zs, sample[i].clr[3], sample[i+1].clr[3]);
+			alpha = sample[i].clr[3]; //lerp(sample[i].depth, sample[i+1].depth, zs, sample[i].clr[3], sample[i+1].clr[3]);
 			break;
 		}
 	}

Modified: branches/soc-2007-joeedh/source/blender/render/intern/source/zbuf.c
===================================================================
--- branches/soc-2007-joeedh/source/blender/render/intern/source/zbuf.c	2007-07-30 20:04:23 UTC (rev 11437)
+++ branches/soc-2007-joeedh/source/blender/render/intern/source/zbuf.c	2007-07-31 00:37:14 UTC (rev 11438)
@@ -410,13 +410,13 @@
 					apn= ap;
 					while(apn) {
 						if(apn->p[0]==0) {apn->p[0]= zvlnr; apn->z[0]= zverg; apn->mask[0]= mask; break; }
-						if(apn->p[0]==zvlnr) {apn->mask[0]|= mask; break; }
+						if(apn->p[0]==zvlnr && ABS(apn->z[0] - zverg) <= zspan->recombine_maxsize) {apn->mask[0]|= mask; break; }
 						if(apn->p[1]==0) {apn->p[1]= zvlnr; apn->z[1]= zverg; apn->mask[1]= mask; break; }
-						if(apn->p[1]==zvlnr) {apn->mask[1]|= mask; break; }
+						if(apn->p[1]==zvlnr && ABS(apn->z[1] - zverg) <= zspan->recombine_maxsize) {apn->mask[1]|= mask; break; }
 						if(apn->p[2]==0) {apn->p[2]= zvlnr; apn->z[2]= zverg; apn->mask[2]= mask; break; }
-						if(apn->p[2]==zvlnr) {apn->mask[2]|= mask; break; }
+						if(apn->p[2]==zvlnr && ABS(apn->z[2] - zverg) <= zspan->recombine_maxsize) {apn->mask[2]|= mask; break; }
 						if(apn->p[3]==0) {apn->p[3]= zvlnr; apn->z[3]= zverg; apn->mask[3]= mask; break; }
-						if(apn->p[3]==zvlnr) {apn->mask[3]|= mask; break; }
+						if(apn->p[3]==zvlnr && ABS(apn->z[3] - zverg) <= zspan->recombine_maxsize) {apn->mask[3]|= mask; break; }
 //						if(apn->p[i]==0) {apn->p[i]= zvlnr; apn->z[i]= zverg; apn->mask[i]= mask; break; }
 //						if(apn->p[i]==zvlnr) {apn->mask[i]|= mask; break; }
 						if(apn->next==NULL) apn->next= addpsA(zspan);
@@ -2711,15 +2711,20 @@
 	}
 }
 
-/* -----------Deep Shadow Depth Bufferer--------- */
+/* ------------------------------------------------------------------------ */
 
-/*polygon rasterizing function*/
+/**
+ * Do deep shadow buffer z buffering.  Based on zbuffer_abuf.
+ */
+
+
 static void zbuffillDc4(ZSpan *zspan, int zvlnr, float *v1, float *v2, float *v3, float *v4)
 {
 	APixstr *ap, *apofs, *apn;
 	double zxd, zyd, zy0, zverg;
 	float x0,y0,z0;
 	float x1,y1,z1,x2,y2,z2,xx1;
+	//float vd1[3], vd2[3], vd3[3], cent[3], dfac;
 	float *span1, *span2;
 	int *rz, x, y;
 	int sn1, sn2, rectx, *rectzofs, my0, my2, mask;
@@ -2745,6 +2750,24 @@
 
 	if(my2<my0) return;
 
+	 /*  //experimental face margining code
+	cent[0] = (v1[0] + v2[0] + v3[0]) / 3.0f;
+	cent[1] = (v1[1] + v2[1] + v3[1]) / 3.0f;
+	cent[2] = (v1[2] + v2[2] + v3[2]) / 3.0f;
+
+	VecSubf(vd1, v1, cent);
+	VecSubf(vd2, v2, cent);
+	VecSubf(vd3, v3, cent);
+
+	dfac = 10.0f; //(float)G.rt / 50.0f;
+	VecMulf(vd1, dfac);
+	VecMulf(vd2, dfac);
+	VecMulf(vd3, dfac);
+
+	VecAddf(vd1, vd1, cent);
+	VecAddf(vd2, vd2, cent);
+	VecAddf(vd3, vd3, cent); // */
+
 	/* ZBUF DX DY, in floats still */
 	x1= v1[0]- v2[0];
 	x2= v2[0]- v3[0];
@@ -2756,6 +2779,7 @@
 	y0= z1*x2-x1*z2;
 	z0= x1*y2-y1*x2;
 
+
 	if(z0==0.0) return;
 
 	xx1= (x0*v1[0] + y0*v1[1])/z0 + v1[2];
@@ -2800,13 +2824,16 @@
 
 			while(x>=0) {
 				if( (int)zverg < *rz) {
+//					int i= zvlnr & 3;
+
 					apn= ap;
 					while(apn) {
 						if(apn->p[0]==0) {apn->p[0]= zvlnr; apn->z[0]= zverg; apn->mask[0]= mask; break; }
 						if(apn->p[1]==0) {apn->p[1]= zvlnr; apn->z[1]= zverg; apn->mask[1]= mask; break; }
 						if(apn->p[2]==0) {apn->p[2]= zvlnr; apn->z[2]= zverg; apn->mask[2]= mask; break; }
 						if(apn->p[3]==0) {apn->p[3]= zvlnr; apn->z[3]= zverg; apn->mask[3]= mask; break; }
-						
+//						if(apn->p[i]==0) {apn->p[i]= zvlnr; apn->z[i]= zverg; apn->mask[i]= mask; break; }
+//						if(apn->p[i]==zvlnr) {apn->mask[i]|= mask; break; }
 						if(apn->next==NULL) apn->next= addpsA(zspan);
 						apn= apn->next;
 					}
@@ -2824,7 +2851,6 @@
 	}
 }
 
-/*line rasterizing function*/
 static void zbuflineDc(ZSpan *zspan, int zvlnr, float *vec1, float *vec2)
 {
 	APixstr *ap, *apn;
@@ -2888,7 +2914,6 @@
 						if(apn->p[1]==0) {apn->p[1]= zvlnr; apn->z[1]= vergz; apn->mask[1]= mask; break; }
 						if(apn->p[2]==0) {apn->p[2]= zvlnr; apn->z[2]= vergz; apn->mask[2]= mask; break; }
 						if(apn->p[3]==0) {apn->p[3]= zvlnr; apn->z[3]= vergz; apn->mask[3]= mask; break; }
-
 						if(apn->next==0) apn->next= addpsA(zspan);
 						apn= apn->next;
 					}
@@ -2953,7 +2978,6 @@
 						if(apn->p[1]==0) {apn->p[1]= zvlnr; apn->z[1]= vergz; apn->mask[1]= mask; break; }
 						if(apn->p[2]==0) {apn->p[2]= zvlnr; apn->z[2]= vergz; apn->mask[2]= mask; break; }
 						if(apn->p[3]==0) {apn->p[3]= zvlnr; apn->z[3]= vergz; apn->mask[3]= mask; break; }
-
 						if(apn->next==0) apn->next= addpsA(zspan);
 						apn= apn->next;
 					}
@@ -2968,11 +2992,6 @@
 	}
 }
 
-/**
- * Do deep shadow buffer z buffering.  Based on zbuffer_abuf.
- */
-
-/*note: can return samples with negative depths*/
 static int zbuffer_dsm(Render *re, RenderPart *pa, APixstr *APixbuf,
 					   ListBase *apsmbase, unsigned int lay, float clipend, ShadBuf *buf)
 {
@@ -3003,6 +3022,9 @@
 	//zspan.clipend = clipend;
 	//size = (0.1/((double)clipend)); // - clipstart);
 
+	/*disable abuf transp optimizaion*/
+	zspan.recombine_maxsize = G.rt*30*(G.rt/50==0?1:G.rt/50); //0x7FFFFFFF; //size*(double)0x7FFFFFFF;
+
 	dx = 0;
 	dy = 0;
 	for(zsample=0; zsample<buf->samp*buf->samp; zsample++) {
@@ -3011,8 +3033,15 @@
 		zspan.mask= zsample;
 
 		if(re->osa) {
-			zspan.zofsx= -pa->disprect.xmin - jit[2*zsample]*buf->soft;
-			zspan.zofsy= -pa->disprect.ymin - jit[2*zsample+1]*buf->soft;
+			/*if (dx >= 1.0) {
+				dx = 0;
+				dy += 1.0/((float)re->osa)/2.0;
+			}*/
+
+			zspan.zofsx= -pa->disprect.xmin - jit[2*zsample]*buf->soft; //re->jit[zsample][0]*2; //FIXMEGREP: hardcoded blur factor of three // - dx //*15.0*((float)zsample/(float)re->osa);
+			zspan.zofsy= -pa->disprect.ymin - jit[2*zsample+1]*buf->soft; //re->jit[zsample][1]*2; // - dy //*15.0*((float)zsample/(float)re->osa);
+
+			//dx += 1.0/((float)re->osa)/2.0;
 		}
 		else {
 			zspan.zofsx= -pa->disprect.xmin;
@@ -3142,12 +3171,6 @@
 	DSMTile *tile;
 	int x, y, rfac = 0; /*reduction factor*/
 
-	if (buf->samp > LA_DEEPBUF_MAXSAMPLEWID) {
-		printf("Can't have sample width of heigher then %d with deep shadow buffers!\n", LA_DEEPBUF_MAXSAMPLEWID);

@@ Diff output truncated at 10240 characters. @@




More information about the Bf-blender-cvs mailing list