Last active
August 25, 2016 12:59
-
-
Save inferrna/169f2dff270a4a481ac677cb36f6b87b to your computer and use it in GitHub Desktop.
sparsed AA
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
diff --git a/include/core_api/imagefilm.h b/include/core_api/imagefilm.h | |
index 445883f..afe5e4d 100644 | |
--- a/include/core_api/imagefilm.h | |
+++ b/include/core_api/imagefilm.h | |
@@ -148,6 +148,7 @@ class YAFRAYCORE_EXPORT imageFilm_t | |
protected: | |
rgba2DImage_t *image; //!< rgba color buffer | |
+ rgba2DImage_t *lastimage; //!< rgba color buffer | |
gray2DImage_t *depthMap; //!< storage for z-buffer channel | |
rgb2DImage_nw_t *densityImage; //!< storage for z-buffer channel | |
rgba2DImage_nw_t *dpimage; //!< render parameters badge image | |
diff --git a/include/utilities/image_buffers.h b/include/utilities/image_buffers.h | |
index 7b3f143..ce04e2f 100644 | |
--- a/include/utilities/image_buffers.h | |
+++ b/include/utilities/image_buffers.h | |
@@ -66,6 +66,11 @@ public: | |
data.resize(width); | |
for(int i = 0; i < width; i++) data[i].resize(height); | |
} | |
+ generic2DBuffer_t(const generic2DBuffer_t& copy) : width(copy.width), height(copy.height) | |
+ { | |
+ data.resize(width); | |
+ for(int i = 0; i < width; i++) data[i] = std::vector< T >(copy.data[i]); | |
+ } | |
~generic2DBuffer_t() | |
{ | |
diff --git a/src/yafraycore/imagefilm.cc b/src/yafraycore/imagefilm.cc | |
index 57c3b5f..6625365 100644 | |
--- a/src/yafraycore/imagefilm.cc | |
+++ b/src/yafraycore/imagefilm.cc | |
@@ -128,6 +128,7 @@ env(e), showMask(showSamMask), tileSize(tSize), tilesOrder(tOrder), premultAlpha | |
filterTable = new float[FILTER_TABLE_SIZE * FILTER_TABLE_SIZE]; | |
image = new rgba2DImage_t(width, height); | |
+ lastimage = new rgba2DImage_t(width, height); | |
densityImage = NULL; | |
estimateDensity = false; | |
depthMap = NULL; | |
@@ -219,6 +220,7 @@ void imageFilm_t::nextPass(bool adaptive_AA, std::string integratorName) | |
splitterMutex.unlock(); | |
nPass++; | |
std::stringstream passString; | |
+ bool skipUnch = !((nPass % 10 == 0) || ((nPass-1) % 10 == 0)); //Force AA for "noisy" pixels each 10 and 11 passes | |
if(flags) flags->clear(); | |
else flags = new tiledBitArray2D_t<3>(w, h, true); | |
@@ -229,23 +231,31 @@ void imageFilm_t::nextPass(bool adaptive_AA, std::string integratorName) | |
{ | |
for(int x = 0; x < w-1; ++x) | |
{ | |
- bool needAA = false; | |
float c = (*image)(x, y).normalized().abscol2bri(); | |
- if(std::fabs(c - (*image)(x+1, y).normalized().col2bri()) >= AA_thesh) | |
- { | |
- needAA=true; flags->setBit(x+1, y); | |
- } | |
- if(std::fabs(c - (*image)(x, y+1).normalized().col2bri()) >= AA_thesh) | |
- { | |
- needAA=true; flags->setBit(x, y+1); | |
- } | |
- if(std::fabs(c - (*image)(x+1, y+1).normalized().col2bri()) >= AA_thesh) | |
- { | |
- needAA=true; flags->setBit(x+1, y+1); | |
- } | |
- if(x > 0 && std::fabs(c - (*image)(x-1, y+1).normalized().col2bri()) >= AA_thesh) | |
- { | |
- needAA=true; flags->setBit(x-1, y+1); | |
+ if (skipUnch){ | |
+ float lc = (*lastimage)(x, y).normalized().abscol2bri(); | |
+ float lastDiff = std::fabs(c - lc); | |
+ bool smallScal = false; | |
+ if(std::min(c, lc)>0) smallScal = (std::max(c, lc)/std::min(c, lc))<1.02; | |
+ if(lastDiff<(AA_thesh/10) && smallScal) continue; //If not changed by the last AA-pass - don't need new AA | |
+ } | |
+ bool needAA = false; | |
+ if(std::fabs(c - (*image)(x+1, y).normalized().col2bri()) >= AA_thesh) { | |
+ needAA=true; | |
+ } else if(std::fabs(c - (*image)(x, y+1).normalized().col2bri()) >= AA_thesh) { | |
+ needAA=true; | |
+ } else if(std::fabs(c - (*image)(x+1, y+1).normalized().col2bri()) >= AA_thesh) { | |
+ needAA=true; | |
+ } else if(x > 0 && std::fabs(c - (*image)(x-1, y).normalized().col2bri()) >= AA_thesh) { | |
+ needAA=true; | |
+ } else if(x > 0 && std::fabs(c - (*image)(x-1, y+1).normalized().col2bri()) >= AA_thesh) { | |
+ needAA=true; | |
+ } else if(y > 0 && std::fabs(c - (*image)(x, y-1).normalized().col2bri()) >= AA_thesh) { | |
+ needAA=true; | |
+ } else if(y > 0 && std::fabs(c - (*image)(x+1, y-1).normalized().col2bri()) >= AA_thesh) { | |
+ needAA=true; | |
+ } else if(y > 0 && x > 0 && std::fabs(c - (*image)(x-1, y-1).normalized().col2bri()) >= AA_thesh) { | |
+ needAA=true; | |
} | |
if(needAA) | |
{ | |
@@ -274,6 +284,10 @@ void imageFilm_t::nextPass(bool adaptive_AA, std::string integratorName) | |
n_resample = h*w; | |
} | |
+ if (skipUnch) { | |
+ delete lastimage; | |
+ lastimage = new rgba2DImage_t(*image); //When unchanged is not skipped, keep lastimage to compare in future | |
+ } | |
if(interactive) output->flush(); | |
passString << "Rendering pass " << nPass << " of " << nPasses << ", resampling " << n_resample << " pixels."; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
INFO: PhotonMap: Rendering pass 1 of 64...
INFO: PhotonMap: Rendering pass 2 of 64, resampling 76266 pixels.
INFO: PhotonMap: Rendering pass 3 of 64, resampling 44289 pixels.
INFO: PhotonMap: Rendering pass 4 of 64, resampling 28971 pixels.
INFO: PhotonMap: Rendering pass 5 of 64, resampling 21307 pixels.
INFO: PhotonMap: Rendering pass 6 of 64, resampling 16344 pixels.
INFO: PhotonMap: Rendering pass 7 of 64, resampling 12272 pixels.
INFO: PhotonMap: Rendering pass 8 of 64, resampling 9345 pixels.
INFO: PhotonMap: Rendering pass 9 of 64, resampling 6873 pixels.
INFO: PhotonMap: Rendering pass 10 of 64, resampling 58332 pixels.
INFO: PhotonMap: Rendering pass 11 of 64, resampling 57317 pixels.
INFO: PhotonMap: Rendering pass 12 of 64, resampling 26570 pixels.
INFO: PhotonMap: Rendering pass 13 of 64, resampling 12128 pixels.
INFO: PhotonMap: Rendering pass 14 of 64, resampling 6194 pixels.
INFO: PhotonMap: Rendering pass 15 of 64, resampling 3774 pixels.
INFO: PhotonMap: Rendering pass 16 of 64, resampling 2210 pixels.
INFO: PhotonMap: Rendering pass 17 of 64, resampling 1366 pixels.
INFO: PhotonMap: Rendering pass 18 of 64, resampling 968 pixels.
INFO: PhotonMap: Rendering pass 19 of 64, resampling 716 pixels.
INFO: PhotonMap: Rendering pass 20 of 64, resampling 55148 pixels.
INFO: PhotonMap: Rendering pass 21 of 64, resampling 54866 pixels.
INFO: PhotonMap: Rendering pass 22 of 64, resampling 17457 pixels.
INFO: PhotonMap: Rendering pass 23 of 64, resampling 6294 pixels.
INFO: PhotonMap: Rendering pass 24 of 64, resampling 2561 pixels.
INFO: PhotonMap: Rendering pass 25 of 64, resampling 1246 pixels.
INFO: PhotonMap: Rendering pass 26 of 64, resampling 754 pixels.
INFO: PhotonMap: Rendering pass 27 of 64, resampling 509 pixels.
INFO: PhotonMap: Rendering pass 28 of 64, resampling 358 pixels.
INFO: PhotonMap: Rendering pass 29 of 64, resampling 280 pixels.
INFO: PhotonMap: Rendering pass 30 of 64, resampling 53929 pixels.
INFO: PhotonMap: Rendering pass 31 of 64, resampling 54028 pixels.
INFO: PhotonMap: Rendering pass 32 of 64, resampling 12526 pixels.
INFO: PhotonMap: Rendering pass 33 of 64, resampling 4341 pixels.
INFO: PhotonMap: Rendering pass 34 of 64, resampling 1550 pixels.
INFO: PhotonMap: Rendering pass 35 of 64, resampling 812 pixels.
INFO: PhotonMap: Rendering pass 36 of 64, resampling 433 pixels.
INFO: PhotonMap: Rendering pass 37 of 64, resampling 249 pixels.
INFO: PhotonMap: Rendering pass 38 of 64, resampling 192 pixels.
INFO: PhotonMap: Rendering pass 39 of 64, resampling 145 pixels.
INFO: PhotonMap: Rendering pass 40 of 64, resampling 53792 pixels.
INFO: PhotonMap: Rendering pass 41 of 64, resampling 53744 pixels.
INFO: PhotonMap: Rendering pass 42 of 64, resampling 9574 pixels.
INFO: PhotonMap: Rendering pass 43 of 64, resampling 2726 pixels.
INFO: PhotonMap: Rendering pass 44 of 64, resampling 850 pixels.
INFO: PhotonMap: Rendering pass 45 of 64, resampling 370 pixels.
INFO: PhotonMap: Rendering pass 46 of 64, resampling 207 pixels.
INFO: PhotonMap: Rendering pass 47 of 64, resampling 136 pixels.
INFO: PhotonMap: Rendering pass 48 of 64, resampling 79 pixels.
INFO: PhotonMap: Rendering pass 49 of 64, resampling 45 pixels.
INFO: PhotonMap: Rendering pass 50 of 64, resampling 53482 pixels.
INFO: PhotonMap: Rendering pass 51 of 64, resampling 53607 pixels.
INFO: PhotonMap: Rendering pass 52 of 64, resampling 7796 pixels.
INFO: PhotonMap: Rendering pass 53 of 64, resampling 1805 pixels.
INFO: PhotonMap: Rendering pass 54 of 64, resampling 503 pixels.
INFO: PhotonMap: Rendering pass 55 of 64, resampling 212 pixels.
INFO: PhotonMap: Rendering pass 56 of 64, resampling 76 pixels.
INFO: PhotonMap: Rendering pass 57 of 64, resampling 31 pixels.
INFO: PhotonMap: Rendering pass 58 of 64, resampling 18 pixels.
INFO: PhotonMap: Rendering pass 59 of 64, resampling 11 pixels.
INFO: PhotonMap: Rendering pass 60 of 64, resampling 53346 pixels.
INFO: PhotonMap: Rendering pass 61 of 64, resampling 53485 pixels.
INFO: PhotonMap: Rendering pass 62 of 64, resampling 6110 pixels.
INFO: PhotonMap: Rendering pass 63 of 64, resampling 1354 pixels.
INFO: PhotonMap: Rendering pass 64 of 64, resampling 284 pixels.