diff options
author | Brecht Van Lommel <brechtvanlommel@pandora.be> | 2008-01-23 23:54:44 +0300 |
---|---|---|
committer | Brecht Van Lommel <brechtvanlommel@pandora.be> | 2008-01-23 23:54:44 +0300 |
commit | 4a913e00109e4cc7924a660a7683c7b4df95b4fe (patch) | |
tree | e2f40153ed7e82bb67e8b420e922fa8bf2d3cc3a | |
parent | 0adafe923a65c0a60b604887de14140a7e569763 (diff) |
Bugfix to filter strands with solid correctly.
-rw-r--r-- | source/blender/render/intern/include/rendercore.h | 3 | ||||
-rw-r--r-- | source/blender/render/intern/include/zbuf.h | 2 | ||||
-rw-r--r-- | source/blender/render/intern/source/rendercore.c | 6 | ||||
-rw-r--r-- | source/blender/render/intern/source/strand.c | 26 | ||||
-rw-r--r-- | source/blender/render/intern/source/zbuf.c | 5 |
5 files changed, 35 insertions, 7 deletions
diff --git a/source/blender/render/intern/include/rendercore.h b/source/blender/render/intern/include/rendercore.h index 600ece8ad50..f2fae7cca84 100644 --- a/source/blender/render/intern/include/rendercore.h +++ b/source/blender/render/intern/include/rendercore.h @@ -50,6 +50,7 @@ struct World; struct RenderPart; struct RenderLayer; struct ObjectRen; +struct ListBase; /* ------------------------------------------------------------------------- */ @@ -90,6 +91,8 @@ void zbufshadeDA_tile(struct RenderPart *pa); void zbufshade_sss_tile(struct RenderPart *pa); +void addps(struct ListBase *lb, long *rd, int obi, int facenr, int z, unsigned short mask); + /* -------- ray.c ------- */ extern void freeraytree(Render *re); diff --git a/source/blender/render/intern/include/zbuf.h b/source/blender/render/intern/include/zbuf.h index 4d30c1e0dfb..1d202fa45fa 100644 --- a/source/blender/render/intern/include/zbuf.h +++ b/source/blender/render/intern/include/zbuf.h @@ -50,7 +50,7 @@ int testclip(float *v); void zbuffer_shadow(struct Render *re, float winmat[][4], struct LampRen *lar, int *rectz, int size, float jitx, float jity); void zbuffer_solid(struct RenderPart *pa, unsigned int layer, short layflag, void (*fillfunc)(struct RenderPart*, struct ZSpan*, int, void*), void *data); -unsigned short *zbuffer_transp_shade(struct RenderPart *pa, struct RenderLayer *rl, float *pass); +unsigned short *zbuffer_transp_shade(struct RenderPart *pa, struct RenderLayer *rl, float *pass, struct ListBase *psmlist); unsigned short *zbuffer_strands_shade(struct Render *re, struct RenderPart *pa, struct RenderLayer *rl, float *pass); void convert_zbuf_to_distbuf(struct RenderPart *pa, struct RenderLayer *rl); void zbuffer_sss(RenderPart *pa, unsigned int lay, void *handle, void (*func)(void*, int, int, int, int, int)); diff --git a/source/blender/render/intern/source/rendercore.c b/source/blender/render/intern/source/rendercore.c index be96fe8f794..50f3142f95a 100644 --- a/source/blender/render/intern/source/rendercore.c +++ b/source/blender/render/intern/source/rendercore.c @@ -631,7 +631,7 @@ static void freeps(ListBase *lb) lb->first= lb->last= NULL; } -static void addps(ListBase *lb, long *rd, int obi, int facenr, int z, unsigned short mask) +void addps(ListBase *lb, long *rd, int obi, int facenr, int z, unsigned short mask) { PixStrMain *psm; PixStr *ps, *last= NULL; @@ -925,7 +925,7 @@ void zbufshadeDA_tile(RenderPart *pa) /* swap for live updates, and it is used in zbuf.c!!! */ SWAP(float *, rl->acolrect, rl->rectf); - ztramask= zbuffer_transp_shade(pa, rl, rl->rectf); + ztramask= zbuffer_transp_shade(pa, rl, rl->rectf, &psmlist); SWAP(float *, rl->acolrect, rl->rectf); /* zbuffer transp only returns ztramask if there's solid rendered */ @@ -1147,7 +1147,7 @@ void zbufshade_tile(RenderPart *pa) /* swap for live updates */ SWAP(float *, rl->acolrect, rl->rectf); - zbuffer_transp_shade(pa, rl, rl->rectf); + zbuffer_transp_shade(pa, rl, rl->rectf, NULL); SWAP(float *, rl->acolrect, rl->rectf); fcol= rl->rectf; acol= rl->acolrect; diff --git a/source/blender/render/intern/source/strand.c b/source/blender/render/intern/source/strand.c index a825a20c3c7..3a1d98572ca 100644 --- a/source/blender/render/intern/source/strand.c +++ b/source/blender/render/intern/source/strand.c @@ -428,6 +428,7 @@ typedef struct StrandPart { ShadeResult *result; float *pass; int *rectz, *outrectz; + long *rectdaps; unsigned short *mask; int rectx, recty; int addpassflag, addzbuf, sample; @@ -607,13 +608,33 @@ static void do_strand_blend(void *handle, int x, int y, float u, float v, float StrandBuffer *buffer= spart->segment->buffer; ShadeResult *shr; float /**pass,*/ t, s; - int offset, zverg; + int offset, zverg, bufferz; /* check again solid z-buffer */ offset = y*spart->rectx + x; zverg= (int)z; - if(zverg < spart->rectz[offset]) { + if(spart->rectdaps) { + /* find the z of the sample */ + PixStr *ps; + long *rd= spart->rectdaps + offset; + int sample= (1<<spart->sample); + + bufferz= 0x7FFFFFFF; + + if(*rd) { + for(ps= (PixStr *)(*rd); ps; ps= ps->next) { + if(sample & ps->mask) { + bufferz= ps->z; + break; + } + } + } + } + else + bufferz= spart->rectz[offset]; + + if(zverg < bufferz) { /* fill in output z-buffer if needed */ if(spart->addzbuf) if(zverg < spart->outrectz[offset]) @@ -994,6 +1015,7 @@ unsigned short *zbuffer_strands_shade(Render *re, RenderPart *pa, RenderLayer *r spart.rectx= pa->rectx; spart.recty= pa->recty; spart.rectz= pa->rectz; + spart.rectdaps= pa->rectdaps; spart.addpassflag= rl->passflag & ~(SCE_PASS_Z|SCE_PASS_COMBINED); spart.addzbuf= rl->passflag & SCE_PASS_Z; diff --git a/source/blender/render/intern/source/zbuf.c b/source/blender/render/intern/source/zbuf.c index 3dcefbfdca0..a8b6dfec667 100644 --- a/source/blender/render/intern/source/zbuf.c +++ b/source/blender/render/intern/source/zbuf.c @@ -3693,7 +3693,7 @@ void reset_sky_speedvectors(RenderPart *pa, RenderLayer *rl, float *rectf) /* main render call to fill in pass the full transparent layer */ /* returns a mask, only if a) transp rendered and b) solid was rendered */ -unsigned short *zbuffer_transp_shade(RenderPart *pa, RenderLayer *rl, float *pass) +unsigned short *zbuffer_transp_shade(RenderPart *pa, RenderLayer *rl, float *pass, ListBase *psmlist) { RenderResult *rr= pa->result; ShadeSample ssamp; @@ -3859,6 +3859,9 @@ unsigned short *zbuffer_transp_shade(RenderPart *pa, RenderLayer *rl, float *pas *sp |= zrow[totface].mask; if(filled==0) break; + + if(R.totstrand) + addps(psmlist, pa->rectdaps+od, zrow[totface].obi, zrow[totface].p, zrow[totface].z, zrow[totface].mask); } } |