NaiveRenderOutput.cpp
Go to the documentation of this file.00001 /**<!--------------------------------------------------------------------> 00002 @file NaiveRenderOutput.cpp 00003 @author Travis Fischer (fisch0920@gmail.com) 00004 @author Matthew Jacobs (jacobs.mh@gmail.com) 00005 @date Fall 2008 00006 00007 @brief 00008 Records point samples from a renderer and naively reconstructs the 00009 underlying image by storing samples into the bin/pixel which they fall 00010 into, overwriting previous samples, and not using any reconstruction 00011 filter 00012 <!-------------------------------------------------------------------->**/ 00013 00014 #include "NaiveRenderOutput.h" 00015 #include "PointSample.h" 00016 00017 #include <SpectralSampleSet.h> 00018 #include <QtCore> 00019 00020 void NaiveRenderOutput::_addSample(const PointSample &sample) { 00021 ASSERT(m_output); 00022 unsigned col, row; 00023 00024 m_viewport.getBin(sample.position, col, row); 00025 ASSERT(row < (unsigned) m_output->getHeight()); 00026 ASSERT(col < (unsigned) m_output->getWidth()); 00027 00028 ProgressiveFilterValue<SpectralSampleSet> &average = 00029 m_progressiveValues[row * m_output->getWidth() + col]; 00030 00031 // progressive box filter, averaging the cumulative contribution of each 00032 // sample within a given pixel uniformly 00033 average.addSample(sample.value.getValue<SpectralSampleSet>(), 1); 00034 00035 m_output->setPixel(row, col, average.getValue()); 00036 } 00037 00038 #if 0 00039 void NaiveRenderOutput::_addSample(const PointSample &sample) { 00040 ASSERT(m_output); 00041 unsigned col, row; 00042 00043 m_viewport.getBin(sample.position, col, row); 00044 ASSERT(row < (unsigned) m_output->getHeight()); 00045 ASSERT(col < (unsigned) m_output->getWidth()); 00046 00047 real_t tally = ++m_tally[row * m_output->getWidth() + col]; 00048 Vector3 value = sample.value.getValue<SpectralSampleSet>().getRGB(); 00049 00050 // progressive box filter, averaging the cumulative contribution of each 00051 // sample within a given pixel uniformly 00052 if (tally > 1) { 00053 const Vector3 &p0 = (*m_output->getPixel(row, col)); 00054 real_t alpha = 1.0 / tally; 00055 real_t beta = (tally - 1) / tally; 00056 00057 value = value * alpha + p0 * beta; 00058 } 00059 00060 const Pixel &p = Pixel::fromVector(value); 00061 m_output->setPixel(row, col, &p); 00062 } 00063 #endif 00064
Generated on 28 Feb 2009 for Milton by
1.5.6