[Aqsis-commits] SF.net SVN: aqsis: [1865] branches/texfiltering/aqsis/texturing/texlib
Brought to you by:
ltatkinson,
pgregory
From: <c4...@us...> - 2008-01-27 13:37:13
|
Revision: 1865 http://aqsis.svn.sourceforge.net/aqsis/?rev=1865&view=rev Author: c42f Date: 2008-01-27 05:37:11 -0800 (Sun, 27 Jan 2008) Log Message: ----------- * Change the scale of texture blurring to bring it more inline with that implied by the RI spec. (Previously, we were getting excessive blurring.) Modified Paths: -------------- branches/texfiltering/aqsis/texturing/texlib/ewafilter.cpp branches/texfiltering/aqsis/texturing/texlib/ewafilter.h Modified: branches/texfiltering/aqsis/texturing/texlib/ewafilter.cpp =================================================================== --- branches/texfiltering/aqsis/texturing/texlib/ewafilter.cpp 2008-01-23 02:19:38 UTC (rev 1864) +++ branches/texfiltering/aqsis/texturing/texlib/ewafilter.cpp 2008-01-27 13:37:11 UTC (rev 1865) @@ -103,10 +103,11 @@ // recommend using 1 for these variances, but this results in excess // blurring. // - // Default reconstruction filter variance - this is the variance of the - // filter used to reconstruct a continuous image from the underlying - // discrete samples. - const TqFloat reconsVar = 1.3/(2*M_PI); + // Default standard deviation for reconstruction filter - this is the + // stddev (=sqrt(variance)) of the filter used to reconstruct a continuous + // image from the underlying discrete samples. + const TqFloat reconsStdDev = 0.454864184147; // std::sqrt(1.3/(2*M_PI)) + const TqFloat reconsVar = reconsStdDev*reconsStdDev; // "Prefilter" variance - this is the variance of the antialiasing filter // which is used immediately before resampling onto the discrete grid. // @@ -121,13 +122,28 @@ if(sBlur > 0 || tBlur > 0) { // The reconstruction variance matrix provides a very nice way of - // incorporating extra filter blurring if desired. Here we do this by - // adding the extra blur to the reconstruction variance matrix. - TqFloat sVariance = sBlur*baseResS; - sVariance = sVariance*sVariance + reconsVar; - TqFloat tVariance = tBlur*baseResT; - tVariance = tVariance*tVariance + reconsVar; - coVar += SqMatrix2D(sVariance, tVariance); + // incorporating extra filter blurring if desired, without distorting + // the filter region in a weird manner. We do this by adding the + // standard deviations of the base reconstruction filter with a scaled + // blur in the s and t directions. + // + // The RI spec (version 3.2, page 149) says that blur is "an additional + // area to be added to the texture area filtered in both the s and t + // directions, expressed in units of texture coordinates". From their + // example it seems like they meant length rather than area... + // + // Since we're working in raster units, we scale the blur by the base + // texture resolution. This gives the blur in units of number of + // pixel widths to add to the filter in the two directions. To turn + // this into a standard devation for a gaussian filter, we scale by + // 1/sqrt(12) which is the standard deviation of a box filter of width + // 1. (If we don't do this, the blur is much larger than desired, + // since the support of a gaussian of standard deviation 1 occupies + // much more than a pixel.) + const TqFloat oneOnSqrt12 = 0.288675134595; + TqFloat sStdDev = sBlur*baseResS*oneOnSqrt12 + reconsStdDev; + TqFloat tStdDev = tBlur*baseResT*oneOnSqrt12 + reconsStdDev; + coVar += SqMatrix2D(sStdDev*sStdDev, tStdDev*tStdDev); } else { Modified: branches/texfiltering/aqsis/texturing/texlib/ewafilter.h =================================================================== --- branches/texfiltering/aqsis/texturing/texlib/ewafilter.h 2008-01-23 02:19:38 UTC (rev 1864) +++ branches/texfiltering/aqsis/texturing/texlib/ewafilter.h 2008-01-27 13:37:11 UTC (rev 1865) @@ -124,7 +124,7 @@ */ inline CqEwaFilterWeights(const SqSampleQuad& sQuad, TqFloat baseResS, TqFloat baseResT, - TqFloat sBlur = -1, TqFloat tBlur = -1, + TqFloat sBlur = 0, TqFloat tBlur = 0, TqFloat logEdgeWeight = 4, TqFloat maxAspectRatio = 20); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |