Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTon Roosendaal <ton@blender.org>2006-02-08 19:51:09 +0300
committerTon Roosendaal <ton@blender.org>2006-02-08 19:51:09 +0300
commit839b338be35dd11d30231d1dee1a3454b952ab55 (patch)
tree6bb9375175ad26f7135adef188a9ca7358b667b5 /source/blender/render/intern
parent10acbf00abc679855184da750d295d1115bb515c (diff)
New:
- ZTransp render now also delivers Z values and Speed vectors in passes Note that speed vectors accumulate within a pixel to store the minimum, so rendering ztransp on top of a non-moving plane won't give speed... Best results you get is by rendering it in a separate layer. The Z value stored is the closest visible transparent face in the pixel. Fixes: - Render to 'spare page' has been enabled again. Because of the strict separation of Render and UI, but especially because a 'render result' now can consist of unlimited images, I've not made this a Render feature. Instead, the render-window itself stores the 'spare' image... I also had to change the convention for it a bit. Now, instead of having two "render buffers" (which was a render feature), the RenderWindow will store each previous frame on a re-render. This storing will only start after you've pressed 'Jkey' once, but then always will happen for as long the rendered image is same size as previously. For clarity, I've also renamed the window title, to 'previous frame'. - RenderWindow shows alpha again on Akey - Display of the Zvalues in ImageWindow has been tweaked. White now denotes closest, and the color range goes from camera clip-sta to clip-end. - Bugfix: on splitting/merging/duplicating windows, the 3D Previewrender was not always freed correctly, potentially causing crashes or memory leaks.
Diffstat (limited to 'source/blender/render/intern')
-rw-r--r--source/blender/render/intern/include/renderpipeline.h1
-rw-r--r--source/blender/render/intern/include/zbuf.h2
-rw-r--r--source/blender/render/intern/source/pipeline.c2
-rw-r--r--source/blender/render/intern/source/rendercore.c34
-rw-r--r--source/blender/render/intern/source/zbuf.c142
5 files changed, 151 insertions, 30 deletions
diff --git a/source/blender/render/intern/include/renderpipeline.h b/source/blender/render/intern/include/renderpipeline.h
index 5ccb2f318dc..400420c7081 100644
--- a/source/blender/render/intern/include/renderpipeline.h
+++ b/source/blender/render/intern/include/renderpipeline.h
@@ -36,6 +36,7 @@ void *RE_mallocN(int len, char *name);
void *RE_callocN(int len, char *name);
void RE_freeN(void *poin);
+#define PASS_VECTOR_MAX 10000.0f
#endif /* PIPELINE_H */
diff --git a/source/blender/render/intern/include/zbuf.h b/source/blender/render/intern/include/zbuf.h
index 82455088565..3a9a9113fe2 100644
--- a/source/blender/render/intern/include/zbuf.h
+++ b/source/blender/render/intern/include/zbuf.h
@@ -49,7 +49,7 @@ int testclip(float *v);
void set_part_zbuf_clipflag(struct RenderPart *pa);
void zbuffer_shadow(struct Render *re, struct LampRen *lar, int *rectz, int size);
void zbuffer_solid(struct RenderPart *pa, unsigned int layer, short layflag);
-void zbuffer_transp_shade(struct RenderPart *pa, float *pass, unsigned int layer, short layflag);
+void zbuffer_transp_shade(struct RenderPart *pa, struct RenderLayer *rl, float *pass);
void convert_zbuf_to_distbuf(struct RenderPart *pa, struct RenderLayer *rl);
typedef struct APixstr {
diff --git a/source/blender/render/intern/source/pipeline.c b/source/blender/render/intern/source/pipeline.c
index 431df31279e..c6b14ad0037 100644
--- a/source/blender/render/intern/source/pipeline.c
+++ b/source/blender/render/intern/source/pipeline.c
@@ -189,7 +189,7 @@ static void render_layer_add_pass(RenderLayer *rl, int rectsize, int passtype, c
/* initialize to max speed */
rect= rpass->rect= RE_mallocN(sizeof(float)*rectsize, mallocstr);
for(x= rectsize-1; x>=0; x--)
- rect[x]= 10000.0f;
+ rect[x]= PASS_VECTOR_MAX;
}
else
rpass->rect= RE_callocN(sizeof(float)*rectsize, mallocstr);
diff --git a/source/blender/render/intern/source/rendercore.c b/source/blender/render/intern/source/rendercore.c
index b3ecb92a12d..d7fdc15e4e4 100644
--- a/source/blender/render/intern/source/rendercore.c
+++ b/source/blender/render/intern/source/rendercore.c
@@ -2687,6 +2687,30 @@ static void edge_enhance_add(RenderPart *pa, float *rectf, float *arect)
/* ********************* MAINLOOPS ******************** */
+static void reset_sky_speedvectors(RenderPart *pa, RenderLayer *rl)
+{
+
+ /* speed vector exception... if solid render was done, sky pixels are set to zero already */
+ /* for all pixels with alpha zero, we re-initialize speed again then */
+ if(rl->layflag & SCE_LAY_SOLID) {
+ float *fp, *col;
+ int a;
+
+ fp= RE_RenderLayerGetPass(rl, SCE_PASS_VECTOR);
+ if(fp==NULL) return;
+ col= rl->rectf+3;
+
+ for(a= 4*pa->rectx*pa->recty -4; a>=0; a-=4) {
+ if(col[a]==0.0f) {
+ fp[a]= PASS_VECTOR_MAX;
+ fp[a+1]= PASS_VECTOR_MAX;
+ fp[a+2]= PASS_VECTOR_MAX;
+ fp[a+3]= PASS_VECTOR_MAX;
+ }
+ }
+ }
+}
+
/* osa version */
static void add_filt_passes(RenderLayer *rl, int curmask, int rectx, int offset, ShadeResult *shr)
{
@@ -3050,9 +3074,12 @@ void zbufshadeDA_tile(RenderPart *pa)
float *fcol= rl->rectf, *acol= acolrect;
int x;
+ if(rl->passflag & SCE_PASS_VECTOR)
+ reset_sky_speedvectors(pa, rl);
+
/* swap for live updates */
SWAP(float *, acolrect, rl->rectf);
- zbuffer_transp_shade(pa, rl->rectf, rl->lay, rl->layflag);
+ zbuffer_transp_shade(pa, rl, rl->rectf);
SWAP(float *, acolrect, rl->rectf);
for(x=pa->rectx*pa->recty; x>0; x--, acol+=4, fcol+=4) {
@@ -3151,9 +3178,12 @@ void zbufshade_tile(RenderPart *pa)
float *fcol= rl->rectf, *acol= acolrect;
int x;
+ if(addpassflag & SCE_PASS_VECTOR)
+ reset_sky_speedvectors(pa, rl);
+
/* swap for live updates */
SWAP(float *, acolrect, rl->rectf);
- zbuffer_transp_shade(pa, rl->rectf, rl->lay, rl->layflag);
+ zbuffer_transp_shade(pa, rl, rl->rectf);
SWAP(float *, acolrect, rl->rectf);
for(x=pa->rectx*pa->recty; x>0; x--, acol+=4, fcol+=4) {
diff --git a/source/blender/render/intern/source/zbuf.c b/source/blender/render/intern/source/zbuf.c
index aa935e1815a..bc77813d59a 100644
--- a/source/blender/render/intern/source/zbuf.c
+++ b/source/blender/render/intern/source/zbuf.c
@@ -2258,7 +2258,7 @@ void RE_zbuf_accumulate_vecblur(NodeBlurData *nbd, int xsize, int ysize, float *
v3[0]= speedfac*dz2[5]+fx+1.0f; v3[1]= speedfac*dz2[6]+fy+1.0f; v3[2]= dz2[z+5];
v4[0]= speedfac*dz2[0]+fx; v4[1]= speedfac*dz2[1]+fy+1.0f; v4[2]= dz2[z];
- zbuf_fill_in_rgba(&zspan, dimg, alpha, v1, v2, v3, v4);
+ zbuf_fill_in_rgba(&zspan, dimg, alpha*dimg[3], v1, v2, v3, v4);
}
}
dz1+=5;
@@ -2346,7 +2346,7 @@ static void copyto_abufz(RenderPart *pa, int *arectz, int sample)
* Do accumulation z buffering.
*/
-static void zbuffer_abuf(RenderPart *pa, APixstr *APixbuf, ListBase *apsmbase, unsigned int lay, short layflag)
+static void zbuffer_abuf(RenderPart *pa, APixstr *APixbuf, ListBase *apsmbase, unsigned int lay)
{
ZSpan zspan;
Material *ma=NULL;
@@ -2451,6 +2451,72 @@ static void zbuffer_abuf(RenderPart *pa, APixstr *APixbuf, ListBase *apsmbase, u
}
+/* different rules for transparent pass... */
+/* if shr is zero, we clear winspeed if it's initialized to max still */
+static void add_transp_passes(RenderLayer *rl, int offset, ShadeResult *shr)
+{
+ RenderPass *rpass;
+
+ for(rpass= rl->passes.first; rpass; rpass= rpass->next) {
+ float *fp, *col= NULL;
+ int a, pixsize= 3;
+
+ switch(rpass->passtype) {
+ case SCE_PASS_RGBA:
+ if(shr) col= shr->col;
+ pixsize= 4;
+ break;
+ case SCE_PASS_DIFFUSE:
+ if(shr) col= shr->diff;
+ break;
+ case SCE_PASS_SPEC:
+ if(shr) col= shr->spec;
+ break;
+ case SCE_PASS_SHADOW:
+ if(shr) col= shr->shad;
+ break;
+ case SCE_PASS_AO:
+ if(shr) col= shr->ao;
+ break;
+ case SCE_PASS_RAY:
+ if(shr) col= shr->ray;
+ break;
+ case SCE_PASS_NORMAL:
+ if(shr) col= shr->nor;
+ break;
+ case SCE_PASS_VECTOR:
+ {
+ fp= rpass->rect + 4*offset;
+ if(shr) {
+ /* add minimum speed in pixel */
+ if( (ABS(shr->winspeed[0]) + ABS(shr->winspeed[1]))< (ABS(fp[0]) + ABS(fp[1])) ) {
+ fp[0]= shr->winspeed[0];
+ fp[1]= shr->winspeed[1];
+ }
+ if( (ABS(shr->winspeed[2]) + ABS(shr->winspeed[3]))< (ABS(fp[2]) + ABS(fp[3])) ) {
+ fp[2]= shr->winspeed[2];
+ fp[3]= shr->winspeed[3];
+ }
+ }
+ else {
+ /* clear */
+ if(fp[0]==PASS_VECTOR_MAX) fp[0]= 0.0f;
+ if(fp[1]==PASS_VECTOR_MAX) fp[1]= 0.0f;
+ if(fp[2]==PASS_VECTOR_MAX) fp[2]= 0.0f;
+ if(fp[3]==PASS_VECTOR_MAX) fp[3]= 0.0f;
+ }
+ }
+ break;
+ }
+ if(col) {
+ fp= rpass->rect + pixsize*offset;
+ for(a=0; a<pixsize; a++)
+ fp[a]= col[a];
+ }
+ }
+}
+
+
static int vergzvlak(const void *a1, const void *a2)
{
const int *x1=a1, *x2=a2;
@@ -2463,7 +2529,7 @@ static int vergzvlak(const void *a1, const void *a2)
/**
* Shade this face at this location in SCS.
*/
-static void shadetrapixel(ShadePixelInfo *shpi, float x, float y, int z, int facenr, int mask, float *fcol)
+static void shadetrapixel(ShadePixelInfo *shpi, float x, float y, int z, int facenr, int mask)
{
float rco[3];
@@ -2488,22 +2554,20 @@ static void shadetrapixel(ShadePixelInfo *shpi, float x, float y, int z, int fac
}
}
tot= 1.0/tot;
- fcol[0]= accumcol[0]*tot;
- fcol[1]= accumcol[1]*tot;
- fcol[2]= accumcol[2]*tot;
- fcol[3]= accumcol[3]*tot;
+ shpi->shr.combined[0]= accumcol[0]*tot;
+ shpi->shr.combined[1]= accumcol[1]*tot;
+ shpi->shr.combined[2]= accumcol[2]*tot;
+ shpi->shr.combined[3]= accumcol[3]*tot;
}
else {
int b= R.samples->centmask[mask];
x= x+R.samples->centLut[b & 15];
y= y+R.samples->centLut[b>>4];
shadepixel(shpi, x, y, z, facenr, mask, rco);
- QUATCOPY(fcol, shpi->shr.combined);
}
}
else {
shadepixel(shpi, x, y, z, facenr, mask, rco);
- QUATCOPY(fcol, shpi->shr.combined);
}
}
@@ -2522,17 +2586,17 @@ static int addtosampcol(float *sampcol, float *fcol, int mask)
#define MAX_ZROW 1000
/* main render call to fill in pass the full transparent layer */
-void zbuffer_transp_shade(RenderPart *pa, float *pass, unsigned int lay, short layflag)
+void zbuffer_transp_shade(RenderPart *pa, RenderLayer *rl, float *pass)
{
RenderResult *rr= pa->result;
ShadePixelInfo shpi;
APixstr *APixbuf; /* Zbuffer: linked list of face samples */
APixstr *ap, *aprect, *apn;
ListBase apsmbase={NULL, NULL};
- float fcol[4], sampcol[16*4];
+ float sampcol[16*4];
float fac, alpha[32], *passrect= pass;
int x, y, crop=0, a, zrow[MAX_ZROW][3], totface;
- int sval;
+ int sval, addpassflag, offs= 0, od, addzbuf;
/* looks nicer for calling code */
if(R.test_break())
@@ -2548,9 +2612,14 @@ void zbuffer_transp_shade(RenderPart *pa, float *pass, unsigned int lay, short l
/* fill shadepixel info struct */
shpi.thread= pa->thread;
- shpi.lay= lay;
+ shpi.lay= rl->lay;
shpi.passflag= 0;
+ if(rl->passflag & ~(SCE_PASS_Z|SCE_PASS_NORMAL|SCE_PASS_VECTOR|SCE_PASS_COMBINED))
+ shpi.passflag= rl->passflag;
+ addpassflag= rl->passflag & ~(SCE_PASS_Z|SCE_PASS_COMBINED);
+ addzbuf= rl->passflag & SCE_PASS_Z;
+
/* alpha LUT */
if(R.osa) {
fac= (1.0/(float)R.osa);
@@ -2560,7 +2629,7 @@ void zbuffer_transp_shade(RenderPart *pa, float *pass, unsigned int lay, short l
}
/* fill the Apixbuf */
- zbuffer_abuf(pa, APixbuf, &apsmbase, lay, layflag);
+ zbuffer_abuf(pa, APixbuf, &apsmbase, rl->lay);
aprect= APixbuf;
/* filtered render, for now we assume only 1 filter size */
@@ -2568,6 +2637,7 @@ void zbuffer_transp_shade(RenderPart *pa, float *pass, unsigned int lay, short l
crop= 1;
passrect+= 4*(pa->rectx + 1);
aprect+= pa->rectx + 1;
+ offs= pa->rectx + 1;
}
/* init scanline updates */
@@ -2579,10 +2649,15 @@ void zbuffer_transp_shade(RenderPart *pa, float *pass, unsigned int lay, short l
for(y=pa->disprect.ymin+crop; y<pa->disprect.ymax-crop; y++, rr->renrect.ymax++) {
pass= passrect;
ap= aprect;
-
- for(x=pa->disprect.xmin+crop; x<pa->disprect.xmax-crop; x++, ap++, pass+=4) {
-
- if(ap->p[0]) {
+ od= offs;
+
+ for(x=pa->disprect.xmin+crop; x<pa->disprect.xmax-crop; x++, ap++, pass+=4, od++) {
+
+ if(ap->p[0]==NULL) {
+ if(addpassflag)
+ add_transp_passes(rl, od, NULL);
+ }
+ else {
/* sort in z */
totface= 0;
apn= ap;
@@ -2602,14 +2677,19 @@ void zbuffer_transp_shade(RenderPart *pa, float *pass, unsigned int lay, short l
if(totface==1) {
- shadetrapixel(&shpi, (float)x, (float)y, zrow[0][0], zrow[0][1], zrow[0][2], fcol);
+ shadetrapixel(&shpi, (float)x, (float)y, zrow[0][0], zrow[0][1], zrow[0][2]);
if(R.osa) {
- add_filt_fmask(zrow[0][2], fcol, pass, rr->rectx);
+ add_filt_fmask(zrow[0][2], shpi.shr.combined, pass, rr->rectx);
}
else {
- QUATCOPY(pass, fcol);
+ QUATCOPY(pass, shpi.shr.combined);
}
+ if(addpassflag)
+ add_transp_passes(rl, od, &shpi.shr);
+ if(addzbuf)
+ if(pa->rectz[od]>zrow[0][0])
+ pa->rectz[od]= zrow[0][0];
}
else {
@@ -2625,13 +2705,19 @@ void zbuffer_transp_shade(RenderPart *pa, float *pass, unsigned int lay, short l
qsort(zrow, totface, sizeof(int)*3, vergzvlak);
}
+ if(addzbuf)
+ if(pa->rectz[od]>zrow[totface-1][0])
+ pa->rectz[od]= zrow[totface-1][0];
+
if(R.osa==0) {
while(totface>0) {
totface--;
- shadetrapixel(&shpi, (float)x, (float)y, zrow[totface][0], zrow[totface][1], zrow[totface][2], fcol);
- addAlphaUnderFloat(pass, fcol);
-
+ shadetrapixel(&shpi, (float)x, (float)y, zrow[totface][0], zrow[totface][1], zrow[totface][2]);
+ addAlphaUnderFloat(pass, shpi.shr.combined);
+ if(addpassflag)
+ add_transp_passes(rl, od, &shpi.shr);
+
if(pass[3]>=0.999) break;
}
}
@@ -2642,9 +2728,12 @@ void zbuffer_transp_shade(RenderPart *pa, float *pass, unsigned int lay, short l
while(totface>0) {
totface--;
- shadetrapixel(&shpi, (float)x, (float)y, zrow[totface][0], zrow[totface][1], zrow[totface][2], fcol);
- sval= addtosampcol(sampcol, fcol, zrow[totface][2]);
+ shadetrapixel(&shpi, (float)x, (float)y, zrow[totface][0], zrow[totface][1], zrow[totface][2]);
+ sval= addtosampcol(sampcol, shpi.shr.combined, zrow[totface][2]);
+ if(addpassflag)
+ add_transp_passes(rl, od, &shpi.shr);
+
if(sval==0) break;
}
@@ -2662,6 +2751,7 @@ void zbuffer_transp_shade(RenderPart *pa, float *pass, unsigned int lay, short l
aprect+= pa->rectx;
passrect+= 4*pa->rectx;
+ offs+= pa->rectx;
}
RE_freeN(APixbuf);