diff options
author | Brecht Van Lommel <brechtvanlommel@pandora.be> | 2008-04-29 23:51:23 +0400 |
---|---|---|
committer | Brecht Van Lommel <brechtvanlommel@pandora.be> | 2008-04-29 23:51:23 +0400 |
commit | 4be6ef57587d5a40fdfd205a10187788a70c5ba8 (patch) | |
tree | dc2ad2971a2d401804d2c94c5edf4e226f900b48 /source | |
parent | e7c3ff64584a68e39c7273026b6504e2fa4ced44 (diff) |
Fix for bug #8910: FSA + spotlight halo not working correct together.
Diffstat (limited to 'source')
-rw-r--r-- | source/blender/render/intern/source/rendercore.c | 88 |
1 files changed, 76 insertions, 12 deletions
diff --git a/source/blender/render/intern/source/rendercore.c b/source/blender/render/intern/source/rendercore.c index 2088ebb3674..75ff270006c 100644 --- a/source/blender/render/intern/source/rendercore.c +++ b/source/blender/render/intern/source/rendercore.c @@ -319,22 +319,27 @@ static void halo_tile(RenderPart *pa, RenderLayer *rl) static void lamphalo_tile(RenderPart *pa, RenderLayer *rl) { + RenderLayer *rlpp[RE_MAX_OSA]; ShadeInput shi; - float *pass= rl->rectf; - float fac; + float *pass; + float fac, col[4]; long *rd= pa->rectdaps; - int x, y, *rz= pa->rectz; + int *rz= pa->rectz; + int x, y, sample, totsample, fullsample, od; + totsample= get_sample_layers(pa, rl, rlpp); + fullsample= (totsample > 1); + shade_input_initialize(&shi, pa, rl, 0); /* this zero's ShadeInput for us */ - for(y=pa->disprect.ymin; y<pa->disprect.ymax; y++) { - for(x=pa->disprect.xmin; x<pa->disprect.xmax; x++, rz++, pass+=4) { + for(od=0, y=pa->disprect.ymin; y<pa->disprect.ymax; y++) { + for(x=pa->disprect.xmin; x<pa->disprect.xmax; x++, rz++, od++) { calc_view_vector(shi.view, x, y); if(rd && *rd) { PixStr *ps= (PixStr *)*rd; - int samp, totsamp= 0; + int count, totsamp= 0, mask= 0; while(ps) { if(R.r.mode & R_ORTHO) @@ -342,15 +347,64 @@ static void lamphalo_tile(RenderPart *pa, RenderLayer *rl) else calc_renderco_zbuf(shi.co, shi.view, ps->z); - totsamp+= samp= count_mask(ps->mask); - fac= ((float)samp)/(float)R.osa; - renderspothalo(&shi, pass, fac); + totsamp+= count= count_mask(ps->mask); + mask |= ps->mask; + + col[0]= col[1]= col[2]= col[3]= 0.0f; + renderspothalo(&shi, col, 1.0f); + + if(fullsample) { + for(sample=0; sample<totsample; sample++) { + if(ps->mask & (1 << sample)) { + pass= rlpp[sample]->rectf + od*4; + pass[0]+= col[0]; + pass[1]+= col[1]; + pass[2]+= col[2]; + pass[3]+= col[3]; + if(pass[3]>1.0f) pass[3]= 1.0f; + } + } + } + else { + fac= ((float)count)/(float)R.osa; + pass= rl->rectf + od*4; + pass[0]+= fac*col[0]; + pass[1]+= fac*col[1]; + pass[2]+= fac*col[2]; + pass[3]+= fac*col[3]; + if(pass[3]>1.0f) pass[3]= 1.0f; + } + ps= ps->next; } + if(totsamp<R.osa) { - fac= ((float)R.osa-totsamp)/(float)R.osa; shi.co[2]= 0.0f; - renderspothalo(&shi, pass, fac); + + col[0]= col[1]= col[2]= col[3]= 0.0f; + renderspothalo(&shi, col, 1.0f); + + if(fullsample) { + for(sample=0; sample<totsample; sample++) { + if(!(mask & (1 << sample))) { + pass= rlpp[sample]->rectf + od*4; + pass[0]+= col[0]; + pass[1]+= col[1]; + pass[2]+= col[2]; + pass[3]+= col[3]; + if(pass[3]>1.0f) pass[3]= 1.0f; + } + } + } + else { + fac= ((float)R.osa-totsamp)/(float)R.osa; + pass= rl->rectf + od*4; + pass[0]+= fac*col[0]; + pass[1]+= fac*col[1]; + pass[2]+= fac*col[2]; + pass[3]+= fac*col[3]; + if(pass[3]>1.0f) pass[3]= 1.0f; + } } } else { @@ -359,7 +413,17 @@ static void lamphalo_tile(RenderPart *pa, RenderLayer *rl) else calc_renderco_zbuf(shi.co, shi.view, *rz); - renderspothalo(&shi, pass, 1.0f); + col[0]= col[1]= col[2]= col[3]= 0.0f; + renderspothalo(&shi, col, 1.0f); + + for(sample=0; sample<totsample; sample++) { + pass= rlpp[sample]->rectf + od*4; + pass[0]+= col[0]; + pass[1]+= col[1]; + pass[2]+= col[2]; + pass[3]+= col[3]; + if(pass[3]>1.0f) pass[3]= 1.0f; + } } if(rd) rd++; |