[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [12753] branches/soc-2007-joeedh/source/ blender: working copy commit before merge.
Joseph Eagar
joeedh at gmail.com
Sun Dec 2 03:23:30 CET 2007
Revision: 12753
http://projects.blender.org/plugins/scmsvn/viewcvs.php?view=rev&root=bf-blender&revision=12753
Author: joeedh
Date: 2007-12-02 03:23:29 +0100 (Sun, 02 Dec 2007)
Log Message:
-----------
working copy commit before merge.
Modified Paths:
--------------
branches/soc-2007-joeedh/source/blender/blenkernel/BKE_dsm.h
branches/soc-2007-joeedh/source/blender/blenkernel/intern/tcs_cache.c
branches/soc-2007-joeedh/source/blender/render/intern/include/shadbuf.h
branches/soc-2007-joeedh/source/blender/render/intern/include/zbuf.h
branches/soc-2007-joeedh/source/blender/render/intern/source/dsm.c
branches/soc-2007-joeedh/source/blender/render/intern/source/rayshade.c
branches/soc-2007-joeedh/source/blender/render/intern/source/shadbuf.c
branches/soc-2007-joeedh/source/blender/render/intern/source/shadeoutput.c
branches/soc-2007-joeedh/source/blender/render/intern/source/zbuf.c
branches/soc-2007-joeedh/source/blender/src/buttons_shading.c
Modified: branches/soc-2007-joeedh/source/blender/blenkernel/BKE_dsm.h
===================================================================
--- branches/soc-2007-joeedh/source/blender/blenkernel/BKE_dsm.h 2007-12-01 23:25:00 UTC (rev 12752)
+++ branches/soc-2007-joeedh/source/blender/blenkernel/BKE_dsm.h 2007-12-02 02:23:29 UTC (rev 12753)
@@ -19,9 +19,18 @@
since tiles are set at um either 16x16 or 64x64. */
typedef struct DSMFuncQuadTree {
int zenter, zexit;
- struct DSMFuncQuadTree *nodes[4];
+ void *nodes[4];
} DSMFuncQuadTree;
+struct DSMTile;
+typedef struct DSMTileQuadMap {
+ int zenter, zexit;
+ struct DSMTile *tiles[4];
+} DSMTileQuadMap;
+
+
+/*There'll be six quadtree levels: 32, 16, 8, 4, 2, 1*/
+
/*ok heres how it works. A "layer"
is the total number of samples going from light
energy 1.0 to 0.0, then repeating.*/
@@ -53,6 +62,7 @@
DSMFunction **g_rect;
DSMFunction **b_rect;
+ DSMFuncQuadTree tree;
//DSMLayerSample **sample_rect; /*first entry's depth is the length of the pixel array*/
/*tile coordinates inside poly_rect.
@@ -67,6 +77,7 @@
typedef struct DSMBuffer {
TCS_TileBuffer buffer;
+ DSMTileQuadMap *qtree_rect;
DSMTile *vfunc_rect; /*visibility functions*/
int sizex, sizey;
int tilex, tiley; /*total number of tiles in x and y dimensions.*/
@@ -82,11 +93,11 @@
ListBase *buckets;
} DSMBuffer;
-//32 8 2
+//32 16 8 4 2 1
#define MAX_SAMPLELAYERS 32
#define DSM_FINAL_TILESIZE 32
#define DSM_TILE_MEMARENASIZE (1<<18)
-#define DSM_AASAMPLES (G.rt>8 ? 1 : (G.rt==0 ? 1 : G.rt))
+#define DSM_AASAMPLES (shb->samp) //(G.rt>8 ? 1 : (G.rt==0 ? 1 : G.rt))
#define DSM_AAWIDTH 3.0f
/*little bit smaller memarena buffer size for the final diced
Modified: branches/soc-2007-joeedh/source/blender/blenkernel/intern/tcs_cache.c
===================================================================
--- branches/soc-2007-joeedh/source/blender/blenkernel/intern/tcs_cache.c 2007-12-01 23:25:00 UTC (rev 12752)
+++ branches/soc-2007-joeedh/source/blender/blenkernel/intern/tcs_cache.c 2007-12-02 02:23:29 UTC (rev 12753)
@@ -196,10 +196,12 @@
BASSERT(tile);
if (!tile) return NULL;
-
+
+ if (tile->is_compressed == 0) return tile;
+
pool = tile->pool;
BASSERT(pool);
-
+
/*if the tile doesn't belong to a pool,
then it was never cached in the first place*/
if (!pool) return tile;
Modified: branches/soc-2007-joeedh/source/blender/render/intern/include/shadbuf.h
===================================================================
--- branches/soc-2007-joeedh/source/blender/render/intern/include/shadbuf.h 2007-12-01 23:25:00 UTC (rev 12752)
+++ branches/soc-2007-joeedh/source/blender/render/intern/include/shadbuf.h 2007-12-02 02:23:29 UTC (rev 12753)
@@ -73,7 +73,7 @@
* Deep Shadow Buffer
*/
-void DSM_getSoftShadow(ShadBuf *shb, float *rco, float *dxco, float *dyco, float inp, float *shadowclr);
+void DSM_getSoftShadow(ShadBuf *shb, struct ShadeInput *shi, LampRen *lar, float *rco, float *dxco, float *dyco, float inp, float *shadowclr);
float DSM_getShadow(ShadBuf *buf, float *rco, float *dxco, float *dyco, float inp, int component);
void DSM_CreateBuffer(Render *re, ShadBuf *buf, int tilesize);
void DSM_FreeBuffer(DSMBuffer *dbuf);
Modified: branches/soc-2007-joeedh/source/blender/render/intern/include/zbuf.h
===================================================================
--- branches/soc-2007-joeedh/source/blender/render/intern/include/zbuf.h 2007-12-01 23:25:00 UTC (rev 12752)
+++ branches/soc-2007-joeedh/source/blender/render/intern/include/zbuf.h 2007-12-02 02:23:29 UTC (rev 12753)
@@ -45,6 +45,7 @@
*/
void projectvert(float *v1, float winmat[][4], float *adr);
void projectverto(float *v1, float winmat[][4], float *adr);
+void projectvert_keepz(float *v1, float winmat[][4], float *adr);
int testclip(float *v);
void set_part_zbuf_clipflag(struct Render *re, struct RenderPart *pa, int borderx, int bordery);
Modified: branches/soc-2007-joeedh/source/blender/render/intern/source/dsm.c
===================================================================
--- branches/soc-2007-joeedh/source/blender/render/intern/source/dsm.c 2007-12-01 23:25:00 UTC (rev 12752)
+++ branches/soc-2007-joeedh/source/blender/render/intern/source/dsm.c 2007-12-02 02:23:29 UTC (rev 12753)
@@ -62,9 +62,11 @@
#include "shading.h"
#include "sss.h"
#include "zbuf.h"
+#include "qmc.h"
#include "MEM_guardedalloc.h"
+extern Render R;
static TCS_TilePool *deepbuffer_pool = NULL;
/* prototypes */
@@ -557,9 +559,9 @@
a -= 1;
break;
}
- cursamp->orig_totsamples++;
olda -= a;
+ cursamp->orig_totsamples++;
a += 1;
}
cursamp++;
@@ -753,7 +755,7 @@
/* main render call to fill in pass the full transparent layer */
/* returns a mask, only if a) transp rendered and b) solid was rendered */
-void DSM_DoTile(Render *re, ShadBuf *buf, DSMTile *tile, DSMBuffer *dbuf, char *mergescratch, _ClrEntry *rowscratch)
+void DSM_DoTile(Render *re, ShadBuf *shb, DSMTile *tile, DSMBuffer *dbuf, char *mergescratch, _ClrEntry *rowscratch)
{
VlakRen *vlak;
ShadeInput shi;
@@ -847,7 +849,7 @@
APixbuf= MEM_mapallocN(pa.rectx*pa.recty*sizeof(APixstr), "APixbuf");
/* fill the Apixbuf */
- if(0 == zbuffer_dsm(re, &pa, APixbuf, &apsmbase, lay, buf->clipend, buf, bucket)) {
+ if(0 == zbuffer_dsm(re, &pa, APixbuf, &apsmbase, lay, shb->clipend, shb, bucket)) {
printf("nothing filled in!\n");
/* nothing filled in */
@@ -912,12 +914,23 @@
if(totface >= dbuf->max_depth/6 - DSM_AASAMPLES*DSM_AASAMPLES) break;
if(apn->p[a]) {
+ float zco;
if (apn->z[a] < 0x7FFFFFFF*-1.0f) {
printf("z less then 0!: z: %d\n", apn->z[a]);
//continue;
}
- row2[totface].depth = apn->z[a];
+ if (G.rt == 31) {
+ /*use linear z. we do it here because the actual
+ rasterization code seems to rely on homogenous z
+ for clipping.*/
+ zco= ((float)apn->z[a])/2147483647.0f;
+ zco = (re->winmat[3][2])/(re->winmat[2][2] - re->winmat[2][3]*zco);
+ zco = (zco - shb->clipsta) / (shb->clipend - shb->clipsta);
+ row2[totface].depth = ((float)0x7FFFFFFF)*zco;
+ if (zco < -0.1 || zco > 1.001) printf("linear z: %f\n", zco);
+ } else row2[totface].depth = apn->z[a];
+
row2[totface].p = apn->p[a];
row2[totface].samplenr = apn->mask[a];
row2[totface].ispolygon = 1;
@@ -1120,13 +1133,13 @@
together*/
tile->r_rect[y*tile->sizex+x] = DSM_MergeLayerList(tile->arena, row, transfuncs, totface,
- mergescratch, mergescratchlen, buf->weight, DSM_AASAMPLES, 0.1f/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, buf->weight, DSM_AASAMPLES, 0.1f/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, buf->weight, DSM_AASAMPLES, 0.1f/sqrt(DSM_AASAMPLES*DSM_AASAMPLES), 2);
+ mergescratch, mergescratchlen, shb->weight, DSM_AASAMPLES, 0.2f/sqrt(DSM_AASAMPLES*DSM_AASAMPLES), 2);
}
}
@@ -1160,40 +1173,63 @@
else
*/
-#define DOIT(crect, index)
+//#define DOIT(crect, index)
+
static void DSM_ProcessPixel(DSMFunction *func, int index, int zenter, int zexit, float *shadclr, int bias)
{
DSMLayerSample *samp;
int i;
if (!func) return;
+
+ //zenter -= bias;
+ //zexit -= bias;
+
+ //bias = ((float)G.rt)*100;
- if ((zenter <= func->zmin && zexit >= func->zmin) ||
- (zenter >= func->zmin && zenter <= func->zmax)) {
+ if ((zenter <= func->zmin+bias && zexit >= func->zmin+bias) ||
+ (zenter >= func->zmin+bias && zenter <= func->zmax+bias)) {
if (zenter < func->zmin) zenter = func->zmin;
if (zexit > func->zmax) zexit = func->zmax;
samp = func->samples + 1;
for (i=1; i < func->totsamples; i++, samp++) {
- if (shadclr[index] < 0.001) return;
- if ((zenter <= (samp-1)->depth+bias && zexit >= (samp-1)->depth+bias)||
- (zenter >= (samp-1)->depth + bias && zenter <= (samp-1)->depth + bias)) {
+ if (shadclr[index] < 0.001) break;
+ //[s | e |] and ([| s | e] which includes [|s e|])
+ /*first check if the ray intersects samp-1's depth sample*/
+ if ((zenter <= (samp-1)->depth+bias && zexit >= (samp-1)->depth+bias) ||
+ //(zenter >= (samp-1)->depth-bias && zenter <= (samp-1)->depth+bias) ||
+ (zenter <= (samp)->depth+bias && zexit >= (samp)->depth+bias)) { // ||
+ //(zenter >= (samp)->depth-bias && zenter <= (samp)->depth+bias)) {
shadclr[index] *= 1.0f - ((samp-1)->value - (samp)->value);
+ } else if (samp->orig_totsamples && (zenter > (samp-1)->depth+bias && zexit < (samp)->depth-bias)) {
+ /*divide into buckets as in the paper.*/
+ int j, zs, curz = (samp-1)->depth;
+ zs = (samp->depth - (samp-1)->depth) / samp->orig_totsamples;
+ for (j=0; j<samp->orig_totsamples; j++, curz += zs) {
+ if ((zenter <= curz+bias && zexit >= curz+bias)) { // ||
+ //(zenter >= curz-bias && zenter <= curz+bias)) {
+ shadclr[index] *= 1.0f - ((samp-1)->value - (samp)->value) / samp->orig_totsamples;
+ }
+ }
}
}
}
}
-static void DSM_WalkRayPath(DSMBuffer *dbuf, int bias, float *shadclr, float *vec1,
- float *vec2, int x, int y, int z, int dz)
+static DSMTile *DSM_WalkRayPath(DSMBuffer *dbuf, int bias, float *shadclr, float *vec1,
+ float *vec2, int x, int y, int z, int dz, DSMTile *tile)
{
- DSMTile *tile;
- DSMLayerSample *samp;
- DSMFunction *func;
int zenter = z, zexit = z;
- int i;
-
- tile = TCS_GetAndLockTile(dbuf, x/dbuf->tsizex, y/dbuf->tsizey, 0);
+
+ /*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.*/
+
+// if (!tile || (tile->x != x/dbuf->tsizex || tile->y != y/dbuf->tsizey)) {
+ tile = TCS_GetAndLockTile(dbuf, x/dbuf->tsizex, y/dbuf->tsizey, 0);
+// }
+
BASSERT(tile);
- if (!tile) return;
+ if (!tile) return NULL;
/*get local offset inside the tile*/
x %= dbuf->tsizex;
@@ Diff output truncated at 10240 characters. @@
More information about the Bf-blender-cvs
mailing list