[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [30758] branches/render25/source/blender/ render/intern/source/pixelfilter.c: Render Branch: remove centmask/ centLut lookup optimization for finding
Brecht Van Lommel
brecht at blender.org
Mon Jul 26 17:14:10 CEST 2010
Revision: 30758
http://projects.blender.org/plugins/scmsvn/viewcvs.php?view=rev&root=bf-blender&revision=30758
Author: blendix
Date: 2010-07-26 17:14:09 +0200 (Mon, 26 Jul 2010)
Log Message:
-----------
Render Branch: remove centmask/centLut lookup optimization for finding
subpixel position from a mask. It's not working correct for OSA != 16,
and can result in light leaks with raytracing in that case.
Modified Paths:
--------------
branches/render25/source/blender/render/intern/source/pixelfilter.c
Modified: branches/render25/source/blender/render/intern/source/pixelfilter.c
===================================================================
--- branches/render25/source/blender/render/intern/source/pixelfilter.c 2010-07-26 14:46:16 UTC (rev 30757)
+++ branches/render25/source/blender/render/intern/source/pixelfilter.c 2010-07-26 15:14:09 UTC (rev 30758)
@@ -50,9 +50,8 @@
typedef struct SampleTables
{
- float centLut[16];
float *fmask[FILTER_MASK_BYTES][FILTER_PIXEL_AREA];
- char cmask[256], *centmask;
+ char cmask[256];
} SampleTables;
@@ -194,18 +193,19 @@
void pxf_mask_offset(RenderSampleData *rsd, unsigned short mask, float ofs[2])
{
- if(rsd->table) {
- /* averaged offset of samples in mask inside pixel */
- SampleTables *st= rsd->table;
- short b= st->centmask[mask];
+ float sum[2], tmp[2];
+ int i;
- ofs[0]= st->centLut[b&15] + 0.5f;
- ofs[1]= st->centLut[b>>4] + 0.5f;
+ zero_v2(sum);
+
+ for(i=0; i<RE_MAX_OSA; i++) {
+ if(mask & (1<<i)) {
+ pxf_sample_offset(rsd, i, tmp);
+ add_v2_v2(sum, tmp);
+ }
}
- else {
- ofs[0]= 0.5f;
- ofs[1]= 0.5f;
- }
+
+ copy_v2_v2(ofs, sum);
}
void pxf_sample_offset(RenderSampleData *rsd, int sample, float ofs[2])
@@ -264,9 +264,8 @@
RenderSampleData *rsd= &re->sample;
SampleTables *st;
float flweight[RE_MAX_OSA], *fm;
- float *fpx[FILTER_MASK_BYTES], *fpy[FILTER_MASK_BYTES];
- float weight[RE_MAX_OSA], totw, val;
- int i, j, a, b, c, osa= re->params.osa;
+ float weight[RE_MAX_OSA], totw;
+ int i, j, a, b, c;
st= rsd->table= MEM_callocN(sizeof(SampleTables), "sample tables");
@@ -311,42 +310,6 @@
}
}
}
-
- /* centmask: the correct subpixel offset per mask */
-
- for(c=0; c<FILTER_MASK_BYTES; c++) {
- fpx[c]= MEM_callocN(256*sizeof(float), "initgauss4");
- fpy[c]= MEM_callocN(256*sizeof(float), "initgauss4");
-
- for(a=0; a<256; a++) {
- for(b=0; b<8; b++) {
- if(a & (1<<b)) {
- fpx[c][a]+= rsd->jit[b + 8*c][0];
- fpy[c][a]+= rsd->jit[b + 8*c][1];
- }
- }
- }
- }
-
- st->centmask= MEM_mallocN((1<<osa), "Initfilt3");
-
- for(a=0; a<RE_MAX_OSA; a++)
- st->centLut[a]= -0.45+((float)a)/RE_MAX_OSA;
-
- for(a= (1<<osa)-1; a>0; a--) {
- val= count_bits_u16(st, a);
- i= 8+(15.9*(fpy[0][a & 255]+fpy[1][a>>8])/val);
- CLAMP(i, 0, 15);
- j= 8+(15.9*(fpx[0][a & 255]+fpx[1][a>>8])/val);
- CLAMP(j, 0, 15);
- i= j + (i<<4);
- st->centmask[a]= i;
- }
-
- for(c=0; c<FILTER_MASK_BYTES; c++) {
- MEM_freeN(fpx[c]);
- MEM_freeN(fpy[c]);
- }
}
static void pxf_free_table(RenderSampleData *rsd)
@@ -358,7 +321,6 @@
for(b=0; b<FILTER_MASK_BYTES; b++)
MEM_freeN(rsd->table->fmask[b][a]);
- MEM_freeN(rsd->table->centmask);
MEM_freeN(rsd->table);
rsd->table= NULL;
}
More information about the Bf-blender-cvs
mailing list