Bugfix: approximate AO with pixel cache & osa now should have fewer

black pixels.
This commit is contained in:
Brecht Van Lommel 2008-02-13 10:44:12 +00:00
parent 0f68741217
commit 5c7f41118c

@ -1671,7 +1671,8 @@ void cache_occ_samples(Render *re, RenderPart *pa, ShadeSample *ssamp)
OcclusionCacheSample *sample;
OccFace exclude;
ShadeInput *shi;
int *ro, *rp, *rz, onlyshadow;
long *rd=NULL;
int *ro=NULL, *rp=NULL, *rz=NULL, onlyshadow;
int x, y, step = CACHE_STEP;
if(!tree->cache)
@ -1686,27 +1687,43 @@ void cache_occ_samples(Render *re, RenderPart *pa, ShadeSample *ssamp)
cache->sample= MEM_callocN(sizeof(OcclusionCacheSample)*cache->w*cache->h, "OcclusionCacheSample");
sample= cache->sample;
if(re->osa) {
rd= pa->rectdaps;
}
else {
/* fake pixel struct for non-osa */
ps.next= NULL;
ps.mask= (1<<re->osa);
ps.mask= 0xFFFF;
ro= pa->recto;
rp= pa->rectp;
rz= pa->rectz;
}
/* compute a sample at every step pixels */
for(y=pa->disprect.ymin; y<pa->disprect.ymax; y++) {
for(x=pa->disprect.xmin; x<pa->disprect.xmax; x++, ro++, rp++, rz++, sample++) {
if((((x - pa->disprect.xmin + step) % step) == 0 || x == pa->disprect.xmax-1) && (((y - pa->disprect.ymin + step) % step) == 0 || y == pa->disprect.ymax-1)) {
if(*rp) {
for(x=pa->disprect.xmin; x<pa->disprect.xmax; x++, sample++, rd++, ro++, rp++, rz++) {
if(!(((x - pa->disprect.xmin + step) % step) == 0 || x == pa->disprect.xmax-1))
continue;
if(!(((y - pa->disprect.ymin + step) % step) == 0 || y == pa->disprect.ymax-1))
continue;
if(re->osa) {
if(!*rd) continue;
shade_samples_fill_with_ps(ssamp, (PixStr *)(*rd), x, y);
}
else {
if(!*rp) continue;
ps.obi= *ro;
ps.facenr= *rp;
ps.z= *rz;
shade_samples_fill_with_ps(ssamp, &ps, x, y);
shi= ssamp->shi;
if(!shi->vlr)
continue;
}
shi= ssamp->shi;
if(shi->vlr) {
onlyshadow= (shi->mat->mode & MA_ONLYSHADOW);
exclude.obi= shi->obi - re->objectinstance;
exclude.facenr= shi->vlr->index;
@ -1726,7 +1743,6 @@ void cache_occ_samples(Render *re, RenderPart *pa, ShadeSample *ssamp)
break;
}
}
}
}
void free_occ_samples(Render *re, RenderPart *pa)