Bugfix #17830
authorTon Roosendaal <ton@blender.org>
Tue, 14 Oct 2008 10:44:22 +0000 (10:44 +0000)
committerTon Roosendaal <ton@blender.org>
Tue, 14 Oct 2008 10:44:22 +0000 (10:44 +0000)
Index OB pass didn't support FSA for Ztransp.
Also made buttons to set black/white for non-RGBA images hide in Image Window,
the Curves color code only supports 4 channels atm.

source/blender/render/intern/include/zbuf.h
source/blender/render/intern/source/zbuf.c
source/blender/src/drawimage.c

index 346ed653977dc43ba022a566ea1b259f589afb14..b6d0c656f636411d98f7e4fb09a2ae06224bc92d 100644 (file)
@@ -53,7 +53,6 @@ void zbuffer_shadow(struct Render *re, float winmat[][4], struct LampRen *lar, i
 void zbuffer_solid(struct RenderPart *pa, struct RenderLayer *rl, void (*fillfunc)(struct RenderPart*, struct ZSpan*, int, void*), void *data);
 
 unsigned short *zbuffer_transp_shade(struct RenderPart *pa, struct RenderLayer *rl, float *pass, struct ListBase *psmlist);
-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));
 int zbuffer_strands_abuf(struct Render *re, struct RenderPart *pa, struct RenderLayer *rl, struct APixstrand *apixbuf, struct ListBase *apsmbase, struct StrandShadeCache *cache);
 
index 0ddcf78b8f04ccd8195a90a45aec087b4fcd87d8..509ac81c58b7d8f824d4fcc80c3bc064a4e60be2 100644 (file)
@@ -3570,19 +3570,15 @@ void add_transp_speed(RenderLayer *rl, int offset, float *speed, float alpha, in
        }
 }
 
-static void add_transp_obindex(RenderLayer *rl, int offset, int obi)
+static void add_transp_obindex(RenderLayer *rl, int offset, Object *ob)
 {
-       ObjectRen *obr= R.objectinstance[obi].obr;
-
-       if(obr->ob) {
-               RenderPass *rpass;
-               
-               for(rpass= rl->passes.first; rpass; rpass= rpass->next) {
-                       if(rpass->passtype == SCE_PASS_INDEXOB) {
-                               float *fp= rpass->rect + offset;
-                               *fp= (float)obr->ob->index;
-                               break;
-                       }
+       RenderPass *rpass;
+       
+       for(rpass= rl->passes.first; rpass; rpass= rpass->next) {
+               if(rpass->passtype == SCE_PASS_INDEXOB) {
+                       float *fp= rpass->rect + offset;
+                       *fp= (float)ob->index;
+                       break;
                }
        }
 }
@@ -4009,10 +4005,11 @@ unsigned short *zbuffer_transp_shade(RenderPart *pa, RenderLayer *rl, float *pas
        ShadeResult samp_shr[16];               /* MAX_OSA */
        ZTranspRow zrow[MAX_ZROW];
        StrandShadeCache *sscache= NULL;
+       RenderLayer *rlpp[RE_MAX_OSA];
        float sampalpha, alpha, *passrect= pass;
        intptr_t *rdrect;
-       int x, y, crop=0, a, b, totface, totsample, doztra;
-       int addpassflag, offs= 0, od, addzbuf, osa = (R.osa? R.osa: 1);
+       int x, y, crop=0, a, b, totface, totfullsample, totsample, doztra;
+       int addpassflag, offs= 0, od, osa = (R.osa? R.osa: 1);
        unsigned short *ztramask= NULL, filled;
 
        /* looks nicer for calling code */
@@ -4034,7 +4031,6 @@ unsigned short *zbuffer_transp_shade(RenderPart *pa, RenderLayer *rl, float *pas
        /* general shader info, passes */
        shade_sample_initialize(&ssamp, pa, rl);
        addpassflag= rl->passflag & ~(SCE_PASS_COMBINED);
-       addzbuf= rl->passflag & SCE_PASS_Z;
        
        if(R.osa)
                sampalpha= 1.0f/(float)R.osa;
@@ -4062,6 +4058,9 @@ unsigned short *zbuffer_transp_shade(RenderPart *pa, RenderLayer *rl, float *pas
        aprect= APixbuf;
        aprectstrand= APixbufstrand;
        rdrect= pa->rectdaps;
+
+       /* needed for correct zbuf/index pass */
+       totfullsample= get_sample_layers(pa, rl, rlpp);
        
        /* irregular shadowb buffer creation */
        if(R.r.mode & R_SHADOW)
@@ -4164,13 +4163,14 @@ unsigned short *zbuffer_transp_shade(RenderPart *pa, RenderLayer *rl, float *pas
                                        qsort(zrow, totface, sizeof(ZTranspRow), vergzvlak);
                                }
                                
-                               /* zbuffer and index pass for transparent, no AA or filters */
-                               if(addzbuf)
-                                       if(pa->rectz[od]>zrow[totface-1].z)
-                                               pa->rectz[od]= zrow[totface-1].z;
-                               
-                               if(addpassflag & SCE_PASS_INDEXOB)
-                                       add_transp_obindex(rl, od, zrow[totface-1].obi);
+                               /* front face does index pass for transparent, no AA or filters, but yes FSA */
+                               if(addpassflag & SCE_PASS_INDEXOB) {
+                                       ObjectRen *obr= R.objectinstance[zrow[totface-1].obi].obr;
+                                       if(obr->ob) {
+                                               for(a= 0; a<totfullsample; a++)
+                                                       add_transp_obindex(rlpp[a], od, obr->ob);
+                                       }
+                               }
                                
                                /* for each mask-sample we alpha-under colors. then in end it's added using filter */
                                memset(samp_shr, 0, sizeof(ShadeResult)*osa);
@@ -4287,45 +4287,6 @@ unsigned short *zbuffer_transp_shade(RenderPart *pa, RenderLayer *rl, float *pas
        return ztramask;
 }
 
-/* *************** */
-
-/* uses part zbuffer values to convert into distances from camera in renderlayer */
-void convert_zbuf_to_distbuf(RenderPart *pa, RenderLayer *rl)
-{
-       RenderPass *rpass;
-       float *rectzf, zco;
-       int a, *rectz, ortho= R.r.mode & R_ORTHO;
-       
-       if(pa->rectz==NULL) return;
-       for(rpass= rl->passes.first; rpass; rpass= rpass->next)
-               if(rpass->passtype==SCE_PASS_Z)
-                       break;
-       
-       if(rpass==NULL) {
-               printf("called convert zbuf wrong...\n");
-               return;
-       }
-       
-       rectzf= rpass->rect;
-       rectz= pa->rectz;
-       
-       for(a=pa->rectx*pa->recty; a>0; a--, rectz++, rectzf++) {
-               if(*rectz>=0x7FFFFFF0)
-                       *rectzf= 10e10;
-               else {
-                       /* inverse of zbuf calc: zbuf = MAXZ*hoco_z/hoco_w */
-                       /* or: (R.winmat[3][2] - zco*R.winmat[3][3])/(R.winmat[2][2] - R.winmat[2][3]*zco); */
-                       /* if ortho [2][3] is zero, else [3][3] is zero */
-                       
-                       zco= ((float)*rectz)/2147483647.0f;
-                       if(ortho)
-                               *rectzf= (R.winmat[3][2] - zco*R.winmat[3][3])/(R.winmat[2][2]);
-                       else
-                               *rectzf= (R.winmat[3][2])/(R.winmat[2][2] - R.winmat[2][3]*zco);
-               }
-       }
-}
-
 
 /* end of zbuf.c */
 
index 8707e75cb09074c91096a71e7cbe00e6369f27c3..84236a0701a024093a6c93fcb5309fbe3b96eef8 100644 (file)
@@ -1616,19 +1616,21 @@ static void image_panel_curves(short cntrl)     // IMAGE_HANDLER_CURVES
                rect.ymin= 10; rect.ymax= 200;
                curvemap_buttons(block, G.sima->cumap, 'c', B_SIMACURVES, B_REDR, &rect);
                
-               bt=uiDefBut(block, BUT, B_SIMARANGE, "Reset",   10, 160, 90, 19, NULL, 0.0f, 0.0f, 0, 0, "Reset Black/White point and curves");
-               uiButSetFunc(bt, image_panel_curves_reset, G.sima->cumap, ibuf);
-               
-               uiBlockBeginAlign(block);
-               uiDefButF(block, NUM, B_SIMARANGE, "Min R:",    10, 120, 90, 19, G.sima->cumap->black, -1000.0f, 1000.0f, 10, 2, "Black level");
-               uiDefButF(block, NUM, B_SIMARANGE, "Min G:",    10, 100, 90, 19, G.sima->cumap->black+1, -1000.0f, 1000.0f, 10, 2, "Black level");
-               uiDefButF(block, NUM, B_SIMARANGE, "Min B:",    10, 80, 90, 19, G.sima->cumap->black+2, -1000.0f, 1000.0f, 10, 2, "Black level");
-               
-               uiBlockBeginAlign(block);
-               uiDefButF(block, NUM, B_SIMARANGE, "Max R:",    10, 50, 90, 19, G.sima->cumap->white, -1000.0f, 1000.0f, 10, 2, "White level");
-               uiDefButF(block, NUM, B_SIMARANGE, "Max G:",    10, 30, 90, 19, G.sima->cumap->white+1, -1000.0f, 1000.0f, 10, 2, "White level");
-               uiDefButF(block, NUM, B_SIMARANGE, "Max B:",    10, 10, 90, 19, G.sima->cumap->white+2, -1000.0f, 1000.0f, 10, 2, "White level");
+               /* curvemap min/max only works for RGBA */
+               if(ibuf->channels==4) {
+                       bt=uiDefBut(block, BUT, B_SIMARANGE, "Reset",   10, 160, 90, 19, NULL, 0.0f, 0.0f, 0, 0, "Reset Black/White point and curves");
+                       uiButSetFunc(bt, image_panel_curves_reset, G.sima->cumap, ibuf);
                
+                       uiBlockBeginAlign(block);
+                       uiDefButF(block, NUM, B_SIMARANGE, "Min R:",    10, 120, 90, 19, G.sima->cumap->black, -1000.0f, 1000.0f, 10, 2, "Black level");
+                       uiDefButF(block, NUM, B_SIMARANGE, "Min G:",    10, 100, 90, 19, G.sima->cumap->black+1, -1000.0f, 1000.0f, 10, 2, "Black level");
+                       uiDefButF(block, NUM, B_SIMARANGE, "Min B:",    10, 80, 90, 19, G.sima->cumap->black+2, -1000.0f, 1000.0f, 10, 2, "Black level");
+                       
+                       uiBlockBeginAlign(block);
+                       uiDefButF(block, NUM, B_SIMARANGE, "Max R:",    10, 50, 90, 19, G.sima->cumap->white, -1000.0f, 1000.0f, 10, 2, "White level");
+                       uiDefButF(block, NUM, B_SIMARANGE, "Max G:",    10, 30, 90, 19, G.sima->cumap->white+1, -1000.0f, 1000.0f, 10, 2, "White level");
+                       uiDefButF(block, NUM, B_SIMARANGE, "Max B:",    10, 10, 90, 19, G.sima->cumap->white+2, -1000.0f, 1000.0f, 10, 2, "White level");
+               }
        }
 }