Fix for bug #8910: FSA + spotlight halo not working correct together.

This commit is contained in:
Brecht Van Lommel 2008-04-29 19:51:23 +00:00
parent e7c3ff6458
commit 4be6ef5758

@ -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++;