Bugfix to filter strands with solid correctly.
authorBrecht Van Lommel <brechtvanlommel@pandora.be>
Wed, 23 Jan 2008 20:54:44 +0000 (20:54 +0000)
committerBrecht Van Lommel <brechtvanlommel@pandora.be>
Wed, 23 Jan 2008 20:54:44 +0000 (20:54 +0000)
source/blender/render/intern/include/rendercore.h
source/blender/render/intern/include/zbuf.h
source/blender/render/intern/source/rendercore.c
source/blender/render/intern/source/strand.c
source/blender/render/intern/source/zbuf.c

index 600ece8ad50923a7971b3880985e68144e2782e5..f2fae7cca84b7c222ca59a67cedfd08278343221 100644 (file)
@@ -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);
index 4d30c1e0dfb87f34a989232e3c26007ccee660f8..1d202fa45fa5eb224bf246c36a8680070cfeb39d 100644 (file)
@@ -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));
index be96fe8f7945d2a7a572aef0d04e48d5897cc1f3..50f3142f95afd557c8e0237ceec6737ebf4f3d67 100644 (file)
@@ -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;
index a825a20c3c783266305c1b1af75fc60e23d8191e..3a1d98572ca11efd045b82afec771e0694933cb9 100644 (file)
@@ -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;
 
index 3dcefbfdca0ce996567ea7f9066d7476e79b55b3..a8b6dfec667d5fb1abeef16a4dba114ec05d5cb2 100644 (file)
@@ -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);
                                                }
                                        }