[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [17367] branches/soc-2007-joeedh/source/ blender: commit of working copy (mostly code cleanup changes I think).
Joseph Eagar
joeedh at gmail.com
Sat Nov 8 15:25:08 CET 2008
Revision: 17367
http://projects.blender.org/plugins/scmsvn/viewcvs.php?view=rev&root=bf-blender&revision=17367
Author: joeedh
Date: 2008-11-08 15:25:08 +0100 (Sat, 08 Nov 2008)
Log Message:
-----------
commit of working copy (mostly code cleanup changes I think).
I think I'm going to try a merge with trunk *scary music*
Modified Paths:
--------------
branches/soc-2007-joeedh/source/blender/blenkernel/BKE_dsm.h
branches/soc-2007-joeedh/source/blender/blenkernel/intern/tcs_bucketbuffer.c
branches/soc-2007-joeedh/source/blender/render/intern/include/render_types.h
branches/soc-2007-joeedh/source/blender/render/intern/source/convertblender.c
branches/soc-2007-joeedh/source/blender/render/intern/source/dsm.c
branches/soc-2007-joeedh/source/blender/render/intern/source/dsm_soft.c
branches/soc-2007-joeedh/source/blender/render/intern/source/pipeline.c
branches/soc-2007-joeedh/source/blender/render/intern/source/rayshade.c
branches/soc-2007-joeedh/source/blender/render/intern/source/shadeoutput.c
branches/soc-2007-joeedh/source/blender/src/drawview.c
Modified: branches/soc-2007-joeedh/source/blender/blenkernel/BKE_dsm.h
===================================================================
--- branches/soc-2007-joeedh/source/blender/blenkernel/BKE_dsm.h 2008-11-08 13:39:37 UTC (rev 17366)
+++ branches/soc-2007-joeedh/source/blender/blenkernel/BKE_dsm.h 2008-11-08 14:25:08 UTC (rev 17367)
@@ -74,6 +74,7 @@
DSMTile *vfunc_rect; /*visibility functions*/
int sizex, sizey;
int tilex, tiley; /*total number of tiles in x and y dimensions.*/
+ int minz, maxz;
/*tile dimensions, isn't necassarily true for 100% of the tiles.
this is because the image might not be divisible into equally sized tiles of
@@ -108,7 +109,7 @@
#define DSM_LINEAR 1
#define DSM_SOFT 0
-#define DSM_VIS 1
+#define DSM_VIS 0
//#define DOQMCDEBUG
/*little bit smaller memarena buffer size for the final diced
Modified: branches/soc-2007-joeedh/source/blender/blenkernel/intern/tcs_bucketbuffer.c
===================================================================
--- branches/soc-2007-joeedh/source/blender/blenkernel/intern/tcs_bucketbuffer.c 2008-11-08 13:39:37 UTC (rev 17366)
+++ branches/soc-2007-joeedh/source/blender/blenkernel/intern/tcs_bucketbuffer.c 2008-11-08 14:25:08 UTC (rev 17367)
@@ -267,10 +267,14 @@
/*right and top border tiles arn't always the same size as the others*/
if (x == tilex-1) tile->sizex = sizex - tsizex*x;
else tile->sizex = tsizex;
+
+ if (tile->sizex < 0) tile->sizex *= -1;
if (y == tiley-1) tile->sizey = sizey - tsizey*y;
else tile->sizey = tsizey;
+ if (tile->sizey < 0) tile->sizey *= -1;
+
TCS_AddToPool(pool, tile);
}
TCS_RunCacher(pool);
Modified: branches/soc-2007-joeedh/source/blender/render/intern/include/render_types.h
===================================================================
--- branches/soc-2007-joeedh/source/blender/render/intern/include/render_types.h 2008-11-08 13:39:37 UTC (rev 17366)
+++ branches/soc-2007-joeedh/source/blender/render/intern/include/render_types.h 2008-11-08 14:25:08 UTC (rev 17367)
@@ -541,12 +541,12 @@
/* objectinstance->flag */
#define R_DUPLI_TRANSFORMED 1
#define R_ENV_TRANSFORMED 2
-#define R_TRANSFORMED (1|2)
+#define R_TRANSFORMED (R_DUPLI_TRANSFORMED|R_ENV_TRANSFORMED)
#define R_NEED_VECTORS 4
//set this to 1 to use the main thread
//if threads == 1, for e.g. profiling purposes.
-#define RE_USE_MAIN_THREAD 0
+#define RE_USE_MAIN_THREAD 1
#endif /* RENDER_TYPES_H */
Modified: branches/soc-2007-joeedh/source/blender/render/intern/source/convertblender.c
===================================================================
--- branches/soc-2007-joeedh/source/blender/render/intern/source/convertblender.c 2008-11-08 13:39:37 UTC (rev 17366)
+++ branches/soc-2007-joeedh/source/blender/render/intern/source/convertblender.c 2008-11-08 14:25:08 UTC (rev 17367)
@@ -3532,6 +3532,9 @@
lar= (LampRen *)MEM_callocN(sizeof(LampRen),"lampren");
BLI_addtail(&re->lampren, lar);
go->lampren= lar;
+
+ MTC_Mat4CpyMat4(lar->fullmat, ob->obmat);
+ MTC_Mat4Ortho(lar->fullmat);
MTC_Mat4MulMat4(mat, ob->obmat, re->viewmat);
MTC_Mat4Invert(ob->imat, mat);
Modified: branches/soc-2007-joeedh/source/blender/render/intern/source/dsm.c
===================================================================
--- branches/soc-2007-joeedh/source/blender/render/intern/source/dsm.c 2008-11-08 13:39:37 UTC (rev 17366)
+++ branches/soc-2007-joeedh/source/blender/render/intern/source/dsm.c 2008-11-08 14:25:08 UTC (rev 17367)
@@ -350,6 +350,9 @@
int mergescratchlen, lay = (1<<20)-1;
char rendertitle[300];
rendertitle[0] = 0;
+
+ dbuf->minz = 0x7FFFFFFF;
+ dbuf->maxz = -0x80000000;
/*use 30,000 max elements per pixel for the 4*total_threads
preallocated pixel arrays DSM_DoTile() allocates. the *6
@@ -492,9 +495,13 @@
/*right and top border tiles arn't always the same size as the others*/
if (x == dbuf->tilex-1) tile->sizex = dbuf->sizex - dbuf->tsizex*x; //dbuf->sizex - dbuf->tsizex*(x-1); //tilesize - (tilesize*x - dbuf->sizex);
else tile->sizex = dbuf->tsizex;
+
+ if (tile->sizex < 0) tile->sizex *= -1;
if (y == dbuf->tiley-1) tile->sizey = dbuf->sizey - dbuf->tsizey*y;//tilesize - (tilesize*y - dbuf->sizey);
else tile->sizey = dbuf->tsizey;
+
+ if (tile->sizey < 0) tile->sizey *= -1;
tile->x = x;
tile->y = y;
@@ -734,7 +741,7 @@
printf("bleh p: %d %d %d %d\n", apn->p[0], apn->p[1], apn->p[2], apn->p[3]);
printf("bleh obi: %d %d %d %d\n", apn->obi[0], apn->obi[1], apn->obi[2], apn->obi[3]);
}
-
+
if (apn->z[a] < 0x7FFFFFFF*-1.0f) {
printf("z less then 0!: z: %d\n", apn->z[a]);
//continue;
@@ -754,6 +761,9 @@
//if (zco < -0.001 || zco > 1.001) printf("linear z: %f\n", zco);
} else row2[totface].depth = apn->z[a];
+ if (row2[totface].depth > dbuf->maxz) dbuf->maxz = row2[totface].depth;
+ if (row2[totface].depth < dbuf->minz) dbuf->minz = row2[totface].depth;
+
row2[totface].p = apn->p[a];
row2[totface].obi = apn->obi[a];
row2[totface].mask = apn->mask[a];
@@ -826,6 +836,9 @@
//if (zco < -0.001 || zco > 1.001) printf("linear z: %f\n", zco);
} else row2[totface].depth = apn->z[a];
+ if (row2[totface].depth > dbuf->maxz) dbuf->maxz = row2[totface].depth;
+ if (row2[totface].depth < dbuf->minz) dbuf->minz = row2[totface].depth;
+
row2[totface].p = apn->p[a];
row2[totface].obi = apn->obi[a];
row2[totface].mask = apn->mask[a];
Modified: branches/soc-2007-joeedh/source/blender/render/intern/source/dsm_soft.c
===================================================================
--- branches/soc-2007-joeedh/source/blender/render/intern/source/dsm_soft.c 2008-11-08 13:39:37 UTC (rev 17366)
+++ branches/soc-2007-joeedh/source/blender/render/intern/source/dsm_soft.c 2008-11-08 14:25:08 UTC (rev 17367)
@@ -79,6 +79,31 @@
extern Render R;
static TCS_TilePool *deepbuffer_pool = NULL;
+static float dsm_linearz_to_homo(int z, float clipsta, float clipend, float winmat[][4])
+{
+ float fac;
+ //recalculate homogenous z from linear
+
+ fac = (float)z / (float)0x7FFFFFFF;
+
+ fac = fac * (clipend - clipsta) + clipsta;
+ fac = (fac * winmat[2][2] - winmat[3][2]) / (fac * winmat[2][3]);
+
+ return fac;
+}
+
+static float dsm_linearz_to_dist(int z, float clipsta, float clipend, float winmat[][4])
+{
+ float fac;
+ //recalculate homogenous z from linear
+
+ fac = (float)z / (float)0x7FFFFFFF;
+
+ fac = fac * (clipend - clipsta) + clipsta;
+
+ return fac;
+}
+
#if 0
/*backprojection based method*/
float DSM_getBPSoftShadow(Render *re, ShadBuf *shb, ShadeInput *shi, LampRen *lar,
@@ -188,12 +213,9 @@
return 1.0f;
}
- //compute the world-space depth
- startz = (float) startsamp->depth / 2147483647.0f;
- startz = startz*(shb->clipend - shb->clipsta) + shb->clipsta;
-
+ //compute the light-space depth
+ startz = dsm_linearz_to_dist(startsamp->depth, shb->clipsta, shb->clipend, shb->winmat);
-
TCS_UnlockTile(tile);
}
#endif
@@ -203,8 +225,8 @@
static void DSM_ProcessPixel(DSMFunction *func, int index, int zenter, int zexit, float *shadclr, int bias, int zthresh)
{
DSMLayerSample *samp;
- int zadd;
- int i, j, z;
+ int zsub;
+ int i, j, z, maxj;
if (!func) return;
@@ -213,52 +235,88 @@
samp = func->samples;
for (i=0; i<func->totsamples; i++, samp++) {
+ maxj = zsub==0 ? 1 : samp->orig_totsamples+1;
+
if (i == 0) {
- zadd = 0;
+ zsub = 0;
z = samp->depth;
} else {
- zadd = (samp->depth - (samp-1)->depth) / (samp->orig_totsamples+1);
+ zsub = (samp->depth - (samp-1)->depth) / maxj;
z = samp->depth;
- }
- for (j=0; j<samp->orig_totsamples+1; j++) {
+ //BASSERT(zsub >= 0);
+ }
+
+ for (j=0; j<maxj; j++) {
int min=z-zthresh, max=z+zthresh;
- min += bias;
- max += bias;
+ min += bias + zthresh;
+ max += bias + zthresh;
//check if layer-zthresh to layer+zthresh overlaps zenter, zexit
if ((max >= zenter && max <= zexit) || (min >= zenter && min <= zexit)
- || (min <= zenter && max >= zexit) || (min < zenter && max > zexit)) {
- if (i != 0) shadclr[index] *= 1.0 - ((samp-1)->value - (samp)->value);
+ || (min <= zenter && max >= zexit)) {
+
+ if (i != 0) shadclr[index] *= 1.0 - ((samp-1)->value - (samp)->value)/maxj;
else shadclr[index] *= samp->value;
BASSERT(i==0 || ((samp-1)->value - (samp)->value) >= 0);
if (i != 0 && ((samp-1)->value - (samp)->value) < 0) {
- printf("less then zero: samp: %f, samp-1: %f\n", samp->value, (samp-1)->value);
+ printf("less then zero! samp: %f, samp-1: %f\n", samp->value, (samp-1)->value);
}
-
}
- z -= zadd;
+ z -= zsub;
}
if (shadclr[index] < 0.001) break;
}
}
-static DSMTile *DSM_WalkRayPath(DSMBuffer *dbuf, int bias, int zthresh, float *shadclr, float *vec1,
- float *vec2, int x, int y, int z, int dz, DSMTile *tile)
+#define USE_BSE (G.rt == 52)
+static LampRen *current_vis_lar = NULL;
+
+static void DSM_WalkRayPath(DSMBuffer *dbuf, ShadBuf *shb, int bias, int zthresh, float *shadclr, float *vec1,
+ float *vec2, int x, int y, int z, int dz)
{
- int zenter = z, zexit = z;
+ DSMTile *tile;
+ int zenter = z, zexit;
+ float fac;
+ float invwinmat[4][4];
+ float coord[4];
- /*this optimization doesn't take into account that the tile might be cached
- by another thread, since TCS_UnlockTile is called at the end of this function.
- the idea was to cache the current tile.*/
+ tile = TCS_GetAndLockTile(dbuf, x/dbuf->tsizex, y/dbuf->tsizey, 0);
+
+ if (USE_BSE) {
+ //recalculate homogenous z for backprojection
-// if (!tile || (tile->x != x/dbuf->tsizex || tile->y != y/dbuf->tsizey)) {
- tile = TCS_GetAndLockTile(dbuf, x/dbuf->tsizex, y/dbuf->tsizey, 0);
-// }
+ fac = (float) (z + dz - bias) / (float)0x7FFFFFFF;
+
+ //fac = (fac - shb->clipsta) / (shb->clipend - shb->clipsta);
+ fac = fac * (shb->clipend - shb->clipsta) + shb->clipsta;
+ //fac = (shb->winmat[3][2])/(shb->winmat[2][2] - shb->winmat[2][3]*fac);
+ //nf = a / (b - c*f)
+ //nf*(b - c*f) = a
+ //nf*b - nf*c*f = a
+ //nf*b - a = nf*c*f
+ //(nf*b - a) / nf*c = f
+ fac = (fac * shb->winmat[2][2] - shb->winmat[3][2]) / (fac * shb->winmat[2][3]);
+
+ coord[0] = ((float)x / (float)dbuf->sizex)*2.0 - 1.0;
+ coord[1] = ((float)y / (float)dbuf->sizey)*2.0 - 1.0;
+ coord[2] = fac;
+ coord[3] = 1.0;
+
+ MTC_Mat4Invert(invwinmat, shb->winmat);
@@ Diff output truncated at 10240 characters. @@
More information about the Bf-blender-cvs
mailing list