[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [13186] branches/soc-2007-joeedh/source/ blender: Pre-merge commit.
Joseph Eagar
joeedh at gmail.com
Wed Jan 9 23:57:24 CET 2008
Revision: 13186
http://projects.blender.org/plugins/scmsvn/viewcvs.php?view=rev&root=bf-blender&revision=13186
Author: joeedh
Date: 2008-01-09 23:57:23 +0100 (Wed, 09 Jan 2008)
Log Message:
-----------
Pre-merge commit. For once, everything works :) Most of the
bugs for basic DSM are fixed now, including the color accumulation
problem (thought of it while waking up this morning) and a missing
sample bug I found. YAY!
Now to integrate the strand renderer.
Modified Paths:
--------------
branches/soc-2007-joeedh/source/blender/blenkernel/BKE_dsm.h
branches/soc-2007-joeedh/source/blender/render/intern/source/dsm.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 2008-01-09 22:32:36 UTC (rev 13185)
+++ branches/soc-2007-joeedh/source/blender/blenkernel/BKE_dsm.h 2008-01-09 22:57:23 UTC (rev 13186)
@@ -98,7 +98,7 @@
#define DSM_FINAL_TILESIZE 32
#define DSM_TILE_MEMARENASIZE (1<<18)
#define DSM_AASAMPLES (shb->samp) //(G.rt>8 ? 1 : (G.rt==0 ? 1 : G.rt))
-#define DSM_AAWIDTH 3.0f
+#define DSM_AAWIDTH (shb->soft)
/*little bit smaller memarena buffer size for the final diced
25x25 tiles*/
Modified: branches/soc-2007-joeedh/source/blender/render/intern/source/dsm.c
===================================================================
--- branches/soc-2007-joeedh/source/blender/render/intern/source/dsm.c 2008-01-09 22:32:36 UTC (rev 13185)
+++ branches/soc-2007-joeedh/source/blender/render/intern/source/dsm.c 2008-01-09 22:57:23 UTC (rev 13186)
@@ -372,7 +372,7 @@
}
#endif /*#if 0*/
-void DSM_CreateBuffer(Render *re, ShadBuf *buf, int tilesize)
+void DSM_CreateBuffer(Render *re, ShadBuf *shb, int tilesize)
{
DSMBuffer *dbuf = MEM_mapallocN(sizeof(DSMBuffer), "DSMBuffer");
DSMTile *tile;
@@ -395,7 +395,7 @@
rowscratch = MEM_mallocN(sizeof(_ClrEntry)*dbuf->max_depth, "_ClrEntry");
mergescratch = MEM_mapallocN(mergescratchlen, "mergescratch in zbuf.c");
- if (tilesize > buf->size) tilesize = buf->size;
+ if (tilesize > shb->size) tilesize = shb->size;
rfac = (int)(125.0f / (float)tilesize + 0.5f);
@@ -407,15 +407,15 @@
if (deepbuffer_pool == NULL) printf("oh EVVVIL!\n");
dbuf->tsizex = dbuf->tsizey = tilesize;
- dbuf->sizex = dbuf->sizey = buf->size;
- dbuf->tilex = dbuf->tiley = buf->size / tilesize;
+ dbuf->sizex = dbuf->sizey = shb->size;
+ dbuf->tilex = dbuf->tiley = shb->size / tilesize;
/*add extra tiles if necassary.
python tests indicated the + 0.000001 is needed; I have no idea why,
some sort of numerical error I assume. of course python uses doubles and
not floats, but I rather doubt that floats are going to behave any better.*/
- fac = ((float)buf->size/(float)tilesize) + 0.0000001;
+ fac = ((float)shb->size/(float)tilesize) + 0.0000001;
if ((int)((fac - (int)fac)*(float)tilesize) > 0.000001) {
dbuf->tilex += 1;
@@ -423,19 +423,18 @@
}
- dbuf->buckets = DSM_FillZbufferBuckets(re, buf, dbuf->sizex, dbuf->sizey,
+ dbuf->buckets = DSM_FillZbufferBuckets(re, shb, dbuf->sizex, dbuf->sizey,
dbuf->tsizex, dbuf->tsizey, dbuf->tilex,
dbuf->tiley, DSM_AAWIDTH*2.0, DSM_AAWIDTH*2.0);
dbuf->vfunc_rect = MEM_mapallocN(sizeof(DSMTile)*dbuf->tilex*dbuf->tiley, "dsm tiles");
- buf->dsmbuffer = dbuf;
+ shb->dsmbuffer = dbuf;
//if (G.rt==44) *((int*)0L) = 0;
for (y=0; y<dbuf->tiley; y++) {
for (x=0; x<dbuf->tilex; x++) {
- if (re->test_break && re->test_break()) break;
tile = &dbuf->vfunc_rect[y*dbuf->tilex+x];
/*right and top border tiles arn't always the same size as the others*/
@@ -455,8 +454,10 @@
tile->b_rect = BLI_memarena_alloc(tile->arena, sizeof(void*)*tile->sizex*tile->sizey);
printf("Rendering a dsm shadow tile! Tile %d of %d\n", y*dbuf->tilex+x, dbuf->tilex*dbuf->tiley);
- DSM_DoTile(re, buf, tile, dbuf, mergescratch, rowscratch);
- _DSM_maketile((TCS_TileBuffer*)dbuf, deepbuffer_pool, (TCS_Tile*)tile);
+ if (!(re->test_break && re->test_break())) {
+ DSM_DoTile(re, shb, tile, dbuf, mergescratch, rowscratch);
+ _DSM_maketile((TCS_TileBuffer*)dbuf, deepbuffer_pool, (TCS_Tile*)tile);
+ }
DSM_FreeZbufferBucket(&dbuf->buckets[tile->y*dbuf->tilex+tile->x]);
}
}
@@ -497,7 +498,7 @@
{
DSMLayerSample *samp = func->samples, *cursamp, *newsamp;
/*start and end are slopes*/
- double start, end, ostartpoint, oendpoint, startpoint = -1, endpoint = -1, err=error; ///2.0;
+ double start, end, ostartpoint, oendpoint, startpoint = -1, endpoint = -1, err=error; // /2.0;
int totface=0, a=0, count=0;
cursamp = func->samples;
@@ -698,7 +699,6 @@
DSMLayerSample *samp;
_ClrEntry *csamp, *lastcsamp=NULL;
double slope, accum, s1, s2;
- int samplesqr = samplewid*samplewid;
int i;
func = BLI_memarena_alloc(arena, sizeof(DSMFunction));
@@ -711,8 +711,6 @@
slope = 0.0;
samp=func->samples;
for (i=0, csamp=row; i<totface; i++, csamp++, samp++) {
- if (accum < 0.005) break;
-
/*we've hit a sample in one of the other rgb color component
visibility functions, or we've hit an excluded sample, so continue*/
if (csamp->index != cindex || !csamp->srclist) {
@@ -998,14 +996,8 @@
note the sample order follows a r-sample, g-sample, b-sample, (repeat)
component order.
+ */
- ignore the next paragraph:
- one note, while I did manage to get the visibility function
- merging function to work with vertical steps in the input
- functions, theres still some annoying bug with that causing
- visual artifacts. so steps are made so theres a 3-depth
- distance between step points. this seems to work.*/
-
row = rowscratch;
b = totface;
totface = 0;
@@ -1035,6 +1027,7 @@
for (c=0; c<3; c++) {
row[totface] = *lastsamples[row2[a].samplenr];
row[totface].index = c;
+ row[totface].ispolygon = 2;
row[totface].depth = row2[a].depth;
row[totface].next = row[totface].prev = NULL;
row[totface].srclist = NULL;
@@ -1120,6 +1113,7 @@
/*clear shr, shi*/
vlak = RE_findOrAddVlak(re, (row[a].p-1) & RE_QUAD_MASK);
+
memset(&shi, 0, sizeof(shi));
memset(&shr, 0, sizeof(shr));
shi.mat = vlak->mat;
@@ -1156,17 +1150,19 @@
//clr[3] *= 2.0;
for (b=0; b<3; b++) {
float fac;
-
+
BASSERT(b == row[a].index);
BASSERT(b >= 0 && b <= 3);
BLI_addtail(&transfuncs[row[a].samplenr][b], &row[a]);
row[a].srclist = &transfuncs[row[a].samplenr][b];
-
- /*this stuff taken from rayshade.c code*/
- fac= 1.0f + vlak->mat->filter*(clr[b]-1.0f);
- accum[row[a].samplenr][b] = clr[3]*clr[b] + fac*(1.0f-clr[3])*accum[row[a].samplenr][b];
- accum[row[a].samplenr][b] *= (1.0f - clr[3])*1.2; //((float)G.rt/500.0f);
+ /*this stuff taken from rayshade.c code*/
+ if (row[a].ispolygon != 2) {
+ fac= 1.0f + vlak->mat->filter*(clr[b]-1.0f);
+ accum[row[a].samplenr][b] = clr[3]*clr[b] + fac*(1.0f-clr[3])*accum[row[a].samplenr][b];
+ accum[row[a].samplenr][b] *= (1.0f - clr[3]);
+ }
+
//accum[row[a].samplenr][b] *= (1.0f - clr[3])*((float)G.rt/500.0f); //clr[b]*(1.0f - clr[3]*2.0);
row[a].value = accum[row[a].samplenr][b];
@@ -1179,22 +1175,17 @@
}
}
- /**** final processing of subpixel visibility samples, add a header
- sample of 1.0f visibility to each one. also cleanup any
- non-visible samples that may be left in the main combined array.
- ****/
-
/*compute the final visibility function by averaging the subpixel functions
together*/
tile->r_rect[y*tile->sizex+x] = DSM_MergeLayerList(tile->arena, row, transfuncs, totface,
- mergescratch, mergescratchlen, shb->weight, DSM_AASAMPLES, 0.13f/sqrt(DSM_AASAMPLES*DSM_AASAMPLES), 0);
+ mergescratch, mergescratchlen, shb->weight, DSM_AASAMPLES, 0.2f/sqrt(DSM_AASAMPLES*DSM_AASAMPLES), 0);
tile->g_rect[y*tile->sizex+x] = DSM_MergeLayerList(tile->arena, row, transfuncs, totface,
- mergescratch, mergescratchlen, shb->weight, DSM_AASAMPLES, 0.13f/sqrt(DSM_AASAMPLES*DSM_AASAMPLES), 1);
+ mergescratch, mergescratchlen, shb->weight, DSM_AASAMPLES, 0.2f/sqrt(DSM_AASAMPLES*DSM_AASAMPLES), 1);
tile->b_rect[y*tile->sizex+x] = DSM_MergeLayerList(tile->arena, row, transfuncs, totface,
- mergescratch, mergescratchlen, shb->weight, DSM_AASAMPLES, 0.13f/sqrt(DSM_AASAMPLES*DSM_AASAMPLES), 2);
+ mergescratch, mergescratchlen, shb->weight, DSM_AASAMPLES, 0.2f/sqrt(DSM_AASAMPLES*DSM_AASAMPLES), 2);
}
}
Modified: branches/soc-2007-joeedh/source/blender/render/intern/source/zbuf.c
===================================================================
--- branches/soc-2007-joeedh/source/blender/render/intern/source/zbuf.c 2008-01-09 22:32:36 UTC (rev 13185)
+++ branches/soc-2007-joeedh/source/blender/render/intern/source/zbuf.c 2008-01-09 22:57:23 UTC (rev 13186)
@@ -3161,7 +3161,7 @@
}
if(re->test_break && re->test_break()) break;
- if(zvlnr==0) break;
+ //if(zvlnr==0) break;
}
printf("vcount: %d\n", vcount);
More information about the Bf-blender-cvs
mailing list