various cleanups

metadata
Wenzel Jakob 2011-07-17 15:20:55 +02:00
parent 06c250f0fc
commit a5d3024a39
24 changed files with 144 additions and 115 deletions

View File

@ -101,6 +101,7 @@
<spectrum name="specularReflectance" value="{number($specularAmount)*number($specularReflectance)}"/> <spectrum name="specularReflectance" value="{number($specularAmount)*number($specularReflectance)}"/>
</xsl:otherwise> </xsl:otherwise>
</xsl:choose> </xsl:choose>
<xsl:apply-templates select="node()[@name!='specularReflectance' and @name!='diffuseReflectance' and @name!='diffuseAmount' and @name!='specularAmount']"/>
</bsdf> </bsdf>
</xsl:template> </xsl:template>
@ -174,6 +175,14 @@
<xsl:attribute name="name">eta</xsl:attribute> <xsl:attribute name="name">eta</xsl:attribute>
</xsl:template> </xsl:template>
<!-- Update the name of the roughglass plugin -->
<xsl:template match="bsdf[@type='roughglass']/@type">
<xsl:attribute name="type">roughdielectric</xsl:attribute>
</xsl:template>
<xsl:template match="bsdf[@type='roughglass']/float[@name='alphaB']/@name">
<xsl:attribute name="name">alpha</xsl:attribute>
</xsl:template>
<!-- Update the name of the composite plugin --> <!-- Update the name of the composite plugin -->
<xsl:template match="bsdf[@type='composite']/@type"> <xsl:template match="bsdf[@type='composite']/@type">
<xsl:attribute name="type">mixture</xsl:attribute> <xsl:attribute name="type">mixture</xsl:attribute>

View File

@ -18,7 +18,7 @@ the executable without parameters:
$\texttt{\$}$ mitsuba $\texttt{\$}$ mitsuba
\end{shell} \end{shell}
\begin{console}[label=lst:mitsuba-cli,caption=Command line options of the \texttt{mitsuba} binary] \begin{console}[label=lst:mitsuba-cli,caption=Command line options of the \texttt{mitsuba} binary]
Mitsuba version 0.2.1, Copyright (c) 2011 Wenzel Jakob Mitsuba version 0.3.0, Copyright (c) 2011 Wenzel Jakob
Usage: mitsuba [options] <One or more scene XML files> Usage: mitsuba [options] <One or more scene XML files>
Options/Arguments: Options/Arguments:
-h Display this help text -h Display this help text

View File

@ -59,6 +59,10 @@ f = open('plugins_generated.tex', 'w')
f.write('\section{Plugin reference}\n') f.write('\section{Plugin reference}\n')
f.write('\input{section_bsdf}\n') f.write('\input{section_bsdf}\n')
os.path.walk('../src/bsdfs', traverse, f) os.path.walk('../src/bsdfs', traverse, f)
f.write('\input{section_subsurface}\n')
os.path.walk('../src/subsurface', traverse, f)
f.write('\input{section_media}\n')
os.path.walk('../src/media', traverse, f)
f.write('\input{section_integrators}\n') f.write('\input{section_integrators}\n')
os.path.walk('../src/integrators', traverse, f) os.path.walk('../src/integrators', traverse, f)
f.close() f.close()

View File

@ -55,11 +55,11 @@
\end{figure} \end{figure}
} }
\newcommand{\rendering}[2]{\subfigure[#1]{\fbox{\includegraphics[width=0.47\textwidth]{images/#2}}}\hfill} \newcommand{\rendering}[2]{\subfloat[#1]{\fbox{\includegraphics[width=0.47\textwidth]{images/#2}}}\hfill}
\newcommand{\unframedrendering}[2]{\subfigure[#1]{\includegraphics[width=0.47\textwidth]{images/#2}}\hfill} \newcommand{\unframedrendering}[2]{\subfloat[#1]{\includegraphics[width=0.47\textwidth]{images/#2}}\hfill}
\newcommand{\medrendering}[2]{ \subfigure[#1]{\fbox{\includegraphics[width=0.3\textwidth]{images/#2}}}\hfill} \newcommand{\medrendering}[2]{ \subfloat[#1]{\fbox{\includegraphics[width=0.3\textwidth]{images/#2}}}\hfill}
\newcommand{\unframedmedrendering}[2]{\subfigure[#1]{\includegraphics[width=0.3\textwidth]{images/#2}}\hfill} \newcommand{\unframedmedrendering}[2]{\subfloat[#1]{\includegraphics[width=0.3\textwidth]{images/#2}}\hfill}
\newcommand{\smallrendering}[2]{ \subfigure[#1]{\fbox{\includegraphics[width=0.2\textwidth]{images/#2}}}\hfill} \newcommand{\smallrendering}[2]{ \subfloat[#1]{\fbox{\includegraphics[width=0.2\textwidth]{images/#2}}}\hfill}
\newcommand{\parameter}[3]{ \newcommand{\parameter}[3]{
\otoprule \otoprule

View File

@ -109,7 +109,6 @@
author = {Geisler-Moroder, D. and D\"ur, A.}, author = {Geisler-Moroder, D. and D\"ur, A.},
booktitle = {Computer Graphics Forum}, booktitle = {Computer Graphics Forum},
volume = {29}, volume = {29},
number = {4},
pages = {1391--1398}, pages = {1391--1398},
year = {2010}, year = {2010},
organization = {Wiley Online Library} organization = {Wiley Online Library}

View File

@ -1,4 +1,4 @@
\documentclass[footexclude,11pt,DIV11]{scrartcl} \documentclass[footinclude=false,11pt,DIV11]{scrartcl}
% Wenzel's standard prelude % Wenzel's standard prelude
% ----- 8< ----- 8< ------ % ----- 8< ----- 8< ------
@ -15,11 +15,12 @@
\usepackage{color} \usepackage{color}
\usepackage{colortbl} \usepackage{colortbl}
\usepackage{listings} \usepackage{listings}
\usepackage[hang]{subfigure}
\usepackage{enumerate} \usepackage{enumerate}
\usepackage{ragged2e} % Ragged-right columns with hyphenation \usepackage{ragged2e} % Ragged-right columns with hyphenation
\usepackage{macros} \usepackage{macros}
\usepackage[format=hang,font=small,labelfont=bf]{caption} \usepackage[format=hang,font=small,labelfont=bf]{caption}
\usepackage[expansion=false, babel=true]{microtype}
\usepackage{subfig}
% Make sure that ligatures remain searchable in the PDF % Make sure that ligatures remain searchable in the PDF
\input glyphtounicode \input glyphtounicode
@ -32,24 +33,10 @@
\setcounter{secnumdepth}{3} \setcounter{secnumdepth}{3}
\setcounter{tocdepth}{3} \setcounter{tocdepth}{3}
\newcommand{\MitsubaVersion}{0.2.1} \newcommand{\MitsubaVersion}{0.3.0}
\usepackage[
bookmarks,
bookmarksnumbered,
colorlinks,
linkcolor=myblue,
urlcolor=myblue,
citecolor=myblue,
pdfpagelabels,
pdftitle={Mitsuba \MitsubaVersion\, Documentation},
pdfauthor={Wenzel Jakob},
pdfstartview=FitH
]{hyperref}
\typearea[current]{last} \typearea[current]{last}
\raggedbottom \raggedbottom
\usepackage[expansion=false, babel=true]{microtype}
\renewcommand*\ttdefault{txtt} \renewcommand*\ttdefault{txtt}
\usepackage{scrpage2} \usepackage{scrpage2}
@ -65,6 +52,22 @@
\addtokomafont{descriptionlabel}{\rmfamily} \addtokomafont{descriptionlabel}{\rmfamily}
\pagestyle{scrheadings} \pagestyle{scrheadings}
\usepackage[
bookmarks,
bookmarksnumbered,
colorlinks,
plainpages=false,
pdfpagelabels,
hypertexnames=false,
linkcolor=myblue,
urlcolor=myblue,
citecolor=myblue,
pdfpagelabels,
pdftitle={Mitsuba \MitsubaVersion\, Documentation},
pdfauthor={Wenzel Jakob},
pdfstartview=FitH
]{hyperref}
\definecolor{myblue}{rgb}{0,.1,.6} \definecolor{myblue}{rgb}{0,.1,.6}
\definecolor{myred}{rgb}{0.63,.16,.16} \definecolor{myred}{rgb}{0.63,.16,.16}
\definecolor{lstshade}{gray}{0.95} \definecolor{lstshade}{gray}{0.95}

4
doc/section_media.tex Normal file
View File

@ -0,0 +1,4 @@
\newpage
\subsection{Participating media}
\label{sec:media}
TBD

View File

@ -0,0 +1,5 @@
\newpage
\subsection{Subsurface scattering}
\label{sec:subsurface}
TBD

View File

@ -226,38 +226,38 @@ inline int log2i(size_t value) {
#endif #endif
/// Check if an integer is a power of two (unsigned 32 bit version) /// Check if an integer is a power of two (unsigned 32 bit version)
inline bool isPow2(uint32_t i) { return (i & (i-1)) == 0; } inline bool isPowerOfTwo(uint32_t i) { return (i & (i-1)) == 0; }
/// Check if an integer is a power of two (signed 32 bit version) /// Check if an integer is a power of two (signed 32 bit version)
inline bool isPow2(int32_t i) { return i > 0 && (i & (i-1)) == 0; } inline bool isPowerOfTwo(int32_t i) { return i > 0 && (i & (i-1)) == 0; }
/// Check if an integer is a power of two (64 bit version) /// Check if an integer is a power of two (64 bit version)
inline bool isPow2(uint64_t i) { return (i & (i-1)) == 0; } inline bool isPowerOfTwo(uint64_t i) { return (i & (i-1)) == 0; }
/// Check if an integer is a power of two (signed 64 bit version) /// Check if an integer is a power of two (signed 64 bit version)
inline bool isPow2(int64_t i) { return i > 0 && (i & (i-1)) == 0; } inline bool isPowerOfTwo(int64_t i) { return i > 0 && (i & (i-1)) == 0; }
#if defined(MTS_AMBIGUOUS_SIZE_T) #if defined(MTS_AMBIGUOUS_SIZE_T)
inline bool isPow2(size_t value) { inline bool isPowerOfTwo(size_t value) {
if (sizeof(size_t) == 8) if (sizeof(size_t) == 8) /// will be optimized away
return isPow2((uint64_t) value); return isPowerOfTwo((uint64_t) value);
else else
return isPow2((uint32_t) value); return isPowerOfTwo((uint32_t) value);
} }
#endif #endif
/// Round an integer to the next power of two /// Round an integer to the next power of two
extern MTS_EXPORT_CORE uint32_t roundToPow2(uint32_t i); extern MTS_EXPORT_CORE uint32_t roundToPowerOfTwo(uint32_t i);
/// Round an integer to the next power of two (64 bit version) /// Round an integer to the next power of two (64 bit version)
extern MTS_EXPORT_CORE uint64_t roundToPow2(uint64_t i); extern MTS_EXPORT_CORE uint64_t roundToPowerOfTwo(uint64_t i);
#if defined(MTS_AMBIGUOUS_SIZE_T) #if defined(MTS_AMBIGUOUS_SIZE_T)
inline size_t roundToPow2(size_t value) { inline size_t roundToPowerOfTwo(size_t value) {
if (sizeof(size_t) == 8) if (sizeof(size_t) == 8) /// will be optimized away
return (size_t) roundToPow2((uint64_t) value); return (size_t) roundToPowerOfTwo((uint64_t) value);
else else
return (size_t) roundToPow2((uint32_t) value); return (size_t) roundToPowerOfTwo((uint32_t) value);
} }
#endif #endif

View File

@ -58,7 +58,7 @@ MTS_NAMESPACE_BEGIN
* angle (i.e. diffuse or very rough materials). * angle (i.e. diffuse or very rough materials).
* Therefore, users are discouraged to use this plugin to coat smooth * Therefore, users are discouraged to use this plugin to coat smooth
* diffuse materials, since there is a separately available plugin * diffuse materials, since there is a separately available plugin
* named \pluginref{smoothplastic}, which covers the same case and does not * named \pluginref{plastic}, which covers the same case and does not
* suffer from energy loss. * suffer from energy loss.
* *
* Evaluating the internal component of this model entails refracting the * Evaluating the internal component of this model entails refracting the

View File

@ -60,7 +60,7 @@ MTS_NAMESPACE_BEGIN
* factor used to modulate the specular reflectance component\default{1.0}} * factor used to modulate the specular reflectance component\default{1.0}}
* \parameter{diffuse\showbreak Reflectance}{\Spectrum\Or\Texture}{Optional * \parameter{diffuse\showbreak Reflectance}{\Spectrum\Or\Texture}{Optional
* factor used to modulate the diffuse reflectance component\default{0.5}} * factor used to modulate the diffuse reflectance component\default{0.5}}
* } * }\vspace{-1mm}
* \renderings{ * \renderings{
* \rendering{Beckmann, $\alpha=0.1$}{bsdf_roughplastic_beckmann} * \rendering{Beckmann, $\alpha=0.1$}{bsdf_roughplastic_beckmann}
* \rendering{GGX, $\alpha=0.3$}{bsdf_roughplastic_ggx} * \rendering{GGX, $\alpha=0.3$}{bsdf_roughplastic_ggx}

View File

@ -2,8 +2,8 @@ Import('env', 'plugins')
plugins += env.SharedLibrary('direct', ['direct/direct.cpp']) plugins += env.SharedLibrary('direct', ['direct/direct.cpp'])
plugins += env.SharedLibrary('errctrl', ['misc/errctrl.cpp']) plugins += env.SharedLibrary('errctrl', ['misc/errctrl.cpp'])
plugins += env.SharedLibrary('path', ['path/path.cpp'])
plugins += env.SharedLibrary('irrcache', ['misc/irrcache.cpp', 'misc/irrcache_proc.cpp']) plugins += env.SharedLibrary('irrcache', ['misc/irrcache.cpp', 'misc/irrcache_proc.cpp'])
plugins += env.SharedLibrary('path', ['path/path.cpp'])
plugins += env.SharedLibrary('volpath', ['path/volpath.cpp']) plugins += env.SharedLibrary('volpath', ['path/volpath.cpp'])
plugins += env.SharedLibrary('volpath_simple', ['path/volpath_simple.cpp']) plugins += env.SharedLibrary('volpath_simple', ['path/volpath_simple.cpp'])
plugins += env.SharedLibrary('ptracer', ['path/ptracer.cpp', 'path/ptracer_proc.cpp']) plugins += env.SharedLibrary('ptracer', ['path/ptracer.cpp', 'path/ptracer_proc.cpp'])

View File

@ -30,27 +30,33 @@ MTS_NAMESPACE_BEGIN
class MIDirectIntegrator : public SampleIntegrator { class MIDirectIntegrator : public SampleIntegrator {
public: public:
MIDirectIntegrator(const Properties &props) : SampleIntegrator(props) { MIDirectIntegrator(const Properties &props) : SampleIntegrator(props) {
/* Number of samples to take using the luminaire sampling technique */ /* Number of shading samples -- this parameter is a shorthand notation
m_luminaireSamples = props.getInteger("luminaireSamples", 1); to set both 'luminaireSamples' and 'bsdfSamples' at the same time*/
/* Number of samples to take using the BSDF sampling technique */ size_t shadingSamples = props.getSize("shadingSamples", 1);
m_bsdfSamples = props.getInteger("bsdfSamples", 1);
Assert(m_luminaireSamples + m_bsdfSamples > 0); /* Number of samples to take using the luminaire sampling technique */
m_luminaireSamples = props.getSize("luminaireSamples", shadingSamples);
/* Number of samples to take using the BSDF sampling technique */
m_bsdfSamples = props.getSize("bsdfSamples", shadingSamples);
Assert(m_luminaireSamples >= 0 && m_bsdfSamples >= 0 &&
m_luminaireSamples + m_bsdfSamples > 0);
} }
/// Unserialize from a binary data stream /// Unserialize from a binary data stream
MIDirectIntegrator(Stream *stream, InstanceManager *manager) MIDirectIntegrator(Stream *stream, InstanceManager *manager)
: SampleIntegrator(stream, manager) { : SampleIntegrator(stream, manager) {
m_luminaireSamples = stream->readInt(); m_luminaireSamples = stream->readSize();
m_bsdfSamples = stream->readInt(); m_bsdfSamples = stream->readSize();
configure(); configure();
} }
void configure() { void configure() {
size_t sum = m_luminaireSamples + m_bsdfSamples;
m_weightBSDF = 1 / (Float) m_bsdfSamples; m_weightBSDF = 1 / (Float) m_bsdfSamples;
m_weightLum = 1 / (Float) m_luminaireSamples; m_weightLum = 1 / (Float) m_luminaireSamples;
m_fracBSDF = m_bsdfSamples / (Float) (m_luminaireSamples + m_bsdfSamples); m_fracBSDF = m_bsdfSamples / (Float) sum;
m_fracLum = m_luminaireSamples / (Float) (m_luminaireSamples + m_bsdfSamples); m_fracLum = m_luminaireSamples / (Float) sum;
} }
void configureSampler(Sampler *sampler) { void configureSampler(Sampler *sampler) {
@ -105,13 +111,13 @@ public:
/* Luminaire sampling */ /* Luminaire sampling */
/* ==================================================================== */ /* ==================================================================== */
Point2 *sampleArray; Point2 *sampleArray;
int numLuminaireSamples = m_luminaireSamples, size_t numLuminaireSamples = m_luminaireSamples,
numBSDFSamples = m_bsdfSamples; numBSDFSamples = m_bsdfSamples;
Float fracLum = m_fracLum, fracBSDF = m_fracBSDF, Float fracLum = m_fracLum, fracBSDF = m_fracBSDF,
weightLum = m_weightLum, weightBSDF = m_weightBSDF; weightLum = m_weightLum, weightBSDF = m_weightBSDF;
if (rRec.depth > 1) { if (rRec.depth > 1) {
/* This integrator is used by another integrator. /* This integrator is used recursively by another integrator.
Be less accurate as this sample will not directly be observed. */ Be less accurate as this sample will not directly be observed. */
numBSDFSamples = numLuminaireSamples = 1; numBSDFSamples = numLuminaireSamples = 1;
fracLum = fracBSDF = .5f; fracLum = fracBSDF = .5f;
@ -121,11 +127,10 @@ public:
if (numLuminaireSamples > 1) { if (numLuminaireSamples > 1) {
sampleArray = rRec.sampler->next2DArray(numLuminaireSamples); sampleArray = rRec.sampler->next2DArray(numLuminaireSamples);
} else { } else {
sample = rRec.nextSample2D(); sample = rRec.nextSample2D(); sampleArray = &sample;
sampleArray = &sample;
} }
for (int i=0; i<numLuminaireSamples; ++i) { for (size_t i=0; i<numLuminaireSamples; ++i) {
/* Estimate the direct illumination if this is requested */ /* Estimate the direct illumination if this is requested */
if (scene->sampleLuminaire(its.p, ray.time, lRec, sampleArray[i])) { if (scene->sampleLuminaire(its.p, ray.time, lRec, sampleArray[i])) {
/* Allocate a record for querying the BSDF */ /* Allocate a record for querying the BSDF */
@ -157,11 +162,10 @@ public:
if (numBSDFSamples > 1) { if (numBSDFSamples > 1) {
sampleArray = rRec.sampler->next2DArray(numBSDFSamples); sampleArray = rRec.sampler->next2DArray(numBSDFSamples);
} else { } else {
sample = rRec.nextSample2D(); sample = rRec.nextSample2D(); sampleArray = &sample;
sampleArray = &sample;
} }
for (int i=0; i<numBSDFSamples; ++i) { for (size_t i=0; i<numBSDFSamples; ++i) {
/* Sample BSDF * cos(theta) */ /* Sample BSDF * cos(theta) */
BSDFQueryRecord bRec(its); BSDFQueryRecord bRec(its);
bRec.sampler = rRec.sampler; bRec.sampler = rRec.sampler;
@ -211,8 +215,8 @@ public:
void serialize(Stream *stream, InstanceManager *manager) const { void serialize(Stream *stream, InstanceManager *manager) const {
SampleIntegrator::serialize(stream, manager); SampleIntegrator::serialize(stream, manager);
stream->writeInt(m_luminaireSamples); stream->writeSize(m_luminaireSamples);
stream->writeInt(m_bsdfSamples); stream->writeSize(m_bsdfSamples);
} }
std::string toString() const { std::string toString() const {
@ -226,7 +230,8 @@ public:
MTS_DECLARE_CLASS() MTS_DECLARE_CLASS()
private: private:
int m_luminaireSamples, m_bsdfSamples; size_t m_luminaireSamples;
size_t m_bsdfSamples;
Float m_fracBSDF, m_fracLum; Float m_fracBSDF, m_fracLum;
Float m_weightBSDF, m_weightLum; Float m_weightBSDF, m_weightLum;
}; };

View File

@ -427,7 +427,7 @@ int modulo(int a, int b) {
} }
/* Fast rounding & power-of-two test algorithms from PBRT */ /* Fast rounding & power-of-two test algorithms from PBRT */
uint32_t roundToPow2(uint32_t i) { uint32_t roundToPowerOfTwo(uint32_t i) {
i--; i--;
i |= i >> 1; i |= i >> 2; i |= i >> 1; i |= i >> 2;
i |= i >> 4; i |= i >> 8; i |= i >> 4; i |= i >> 8;
@ -435,7 +435,7 @@ uint32_t roundToPow2(uint32_t i) {
return i+1; return i+1;
} }
uint64_t roundToPow2(uint64_t i) { uint64_t roundToPowerOfTwo(uint64_t i) {
i--; i--;
i |= i >> 1; i |= i >> 2; i |= i >> 1; i |= i >> 2;
i |= i >> 4; i |= i >> 8; i |= i >> 4; i |= i >> 8;

View File

@ -27,7 +27,7 @@ MTS_NAMESPACE_BEGIN
Wavelet2D::Wavelet2D(const Bitmap *bitmap, int selectedChannel) { Wavelet2D::Wavelet2D(const Bitmap *bitmap, int selectedChannel) {
Assert(bitmap->getWidth() == bitmap->getHeight()); Assert(bitmap->getWidth() == bitmap->getHeight());
Assert(isPow2(bitmap->getWidth())); Assert(isPowerOfTwo(bitmap->getWidth()));
m_size = bitmap->getWidth(); m_size = bitmap->getWidth();
m_data = new float[m_size * m_size]; m_data = new float[m_size * m_size];
@ -60,7 +60,7 @@ Wavelet2D::Wavelet2D(const Bitmap *bitmap, int selectedChannel) {
} }
Wavelet2D::Wavelet2D(const SparseWavelet2D *sw) { Wavelet2D::Wavelet2D(const SparseWavelet2D *sw) {
Assert(isPow2(sw->getSize())); Assert(isPowerOfTwo(sw->getSize()));
m_size = sw->getSize(); m_size = sw->getSize();
m_data = new float[m_size * m_size]; m_data = new float[m_size * m_size];
m_temp = new float[m_size]; m_temp = new float[m_size];
@ -467,7 +467,7 @@ std::string SparseWavelet2D::toString() const {
/* ==================================================================== */ /* ==================================================================== */
Wavelet3D::Wavelet3D(const float *data, size_t resolution) { Wavelet3D::Wavelet3D(const float *data, size_t resolution) {
Assert(isPow2(resolution)); Assert(isPowerOfTwo(resolution));
m_size = resolution; m_size = resolution;
size_t nEntries = m_size * m_size * m_size; size_t nEntries = m_size * m_size * m_size;

View File

@ -121,7 +121,7 @@ void GLTexture::init() {
glFramebufferTexture2DEXT(GL_FRAMEBUFFER_EXT, glFramebufferTexture2DEXT(GL_FRAMEBUFFER_EXT,
GL_COLOR_ATTACHMENT0_EXT, m_glType, m_id, 0); GL_COLOR_ATTACHMENT0_EXT, m_glType, m_id, 0);
} else if (m_type == ETextureCubeMap) { } else if (m_type == ETextureCubeMap) {
Assert(m_size.x == m_size.y && isPow2(m_size.x)); Assert(m_size.x == m_size.y && isPowerOfTwo(m_size.x));
Assert(m_fbType == EColorBuffer); Assert(m_fbType == EColorBuffer);
Assert(m_samples == 1); Assert(m_samples == 1);
@ -168,7 +168,7 @@ void GLTexture::init() {
glFramebufferTexture2DEXT(GL_FRAMEBUFFER_EXT, glFramebufferTexture2DEXT(GL_FRAMEBUFFER_EXT,
GL_DEPTH_ATTACHMENT_EXT, m_glType, m_id, 0); GL_DEPTH_ATTACHMENT_EXT, m_glType, m_id, 0);
} else if (m_type == ETextureCubeMap) { } else if (m_type == ETextureCubeMap) {
Assert(m_size.x == m_size.y && isPow2(m_size.x)); Assert(m_size.x == m_size.y && isPowerOfTwo(m_size.x));
for (int i=0; i<6; i++) for (int i=0; i<6; i++)
glTexImage2D(GL_TEXTURE_CUBE_MAP_POSITIVE_X + i, 0, m_internalFormat, glTexImage2D(GL_TEXTURE_CUBE_MAP_POSITIVE_X + i, 0, m_internalFormat,
m_size.x, m_size.y, 0, m_format, m_dataFormat, NULL); m_size.x, m_size.y, 0, m_format, m_dataFormat, NULL);
@ -227,8 +227,8 @@ void GLTexture::refresh() {
glBindTexture(m_glType, m_id); glBindTexture(m_glType, m_id);
if (m_type == ETexture1D) { if (m_type == ETexture1D) {
Assert((isPow2(m_size.x) && m_size.y == 1) Assert((isPowerOfTwo(m_size.x) && m_size.y == 1)
|| (isPow2(m_size.y) && m_size.x == 1)); || (isPowerOfTwo(m_size.y) && m_size.x == 1));
if (isMipMapped()) { if (isMipMapped()) {
/* Let GLU generate mipmaps for us */ /* Let GLU generate mipmaps for us */
@ -260,7 +260,7 @@ void GLTexture::refresh() {
} else if (m_type == ETextureCubeMap) { } else if (m_type == ETextureCubeMap) {
Assert(bitmap != NULL); Assert(bitmap != NULL);
Assert(bitmap->getWidth() == bitmap->getHeight()); Assert(bitmap->getWidth() == bitmap->getHeight());
Assert(isPow2(bitmap->getWidth())); Assert(isPowerOfTwo(bitmap->getWidth()));
if (isMipMapped()) if (isMipMapped())
glTexParameteri(m_glType, GL_GENERATE_MIPMAP, GL_TRUE); glTexParameteri(m_glType, GL_GENERATE_MIPMAP, GL_TRUE);

View File

@ -31,9 +31,9 @@ MIPMap::MIPMap(int width, int height, Spectrum *pixels,
m_wrapMode(wrapMode), m_maxAnisotropy(maxAnisotropy) { m_wrapMode(wrapMode), m_maxAnisotropy(maxAnisotropy) {
Spectrum *texture = pixels; Spectrum *texture = pixels;
if (filterType != ENone && (!isPow2(width) || !isPow2(height))) { if (filterType != ENone && (!isPowerOfTwo(width) || !isPowerOfTwo(height))) {
m_width = (int) roundToPow2((uint32_t) width); m_width = (int) roundToPowerOfTwo((uint32_t) width);
m_height = (int) roundToPow2((uint32_t) height); m_height = (int) roundToPowerOfTwo((uint32_t) height);
/* The texture needs to be up-sampled */ /* The texture needs to be up-sampled */
Spectrum *texture1 = new Spectrum[m_width*height]; Spectrum *texture1 = new Spectrum[m_width*height];

View File

@ -23,7 +23,7 @@ MTS_NAMESPACE_BEGIN
SparseMipmap3D::SparseMipmap3D(const AABB &aabb, size_t size, const float *data, SparseMipmap3D::SparseMipmap3D(const AABB &aabb, size_t size, const float *data,
Float maxError, Float offset) : m_aabb(aabb), m_size(size) { Float maxError, Float offset) : m_aabb(aabb), m_size(size) {
Assert(isPow2(m_size)); Assert(isPowerOfTwo(m_size));
m_levels = 1 + log2i(m_size); m_levels = 1 + log2i(m_size);
m_aabbSum = Vector(m_aabb.min + m_aabb.max); m_aabbSum = Vector(m_aabb.min + m_aabb.max);

View File

@ -105,10 +105,10 @@ public:
std::string toString() const { std::string toString() const {
std::ostringstream oss; std::ostringstream oss;
oss << "HaltonSequence[" << std::endl oss << "HaltonSequence[" << endl
<< " sampleCount = " << m_sampleCount << "," << std::endl << " sampleCount = " << m_sampleCount << "," << endl
<< " sampleIndex = " << m_sampleIndex << "," << std::endl << " sampleIndex = " << m_sampleIndex << "," << endl
<< " sampleDepth = " << m_sampleDepth << std::endl << " sampleDepth = " << m_sampleDepth << endl
<< "]"; << "]";
return oss.str(); return oss.str();
} }

View File

@ -115,10 +115,10 @@ public:
std::string toString() const { std::string toString() const {
std::ostringstream oss; std::ostringstream oss;
oss << "HammersleySequence[" << std::endl oss << "HammersleySequence[" << endl
<< " sampleCount = " << m_sampleCount << "," << std::endl << " sampleCount = " << m_sampleCount << "," << endl
<< " sampleIndex = " << m_sampleIndex << "," << std::endl << " sampleIndex = " << m_sampleIndex << "," << endl
<< " sampleDepth = " << m_sampleDepth << std::endl << " sampleDepth = " << m_sampleDepth << endl
<< "]"; << "]";
return oss.str(); return oss.str();
} }

View File

@ -93,8 +93,8 @@ public:
std::string toString() const { std::string toString() const {
std::ostringstream oss; std::ostringstream oss;
oss << "IndependentSampler[" << std::endl oss << "IndependentSampler[" << endl
<< " sampleCount = " << m_sampleCount << std::endl << " sampleCount = " << m_sampleCount << endl
<< "]"; << "]";
return oss.str(); return oss.str();
} }

View File

@ -29,19 +29,6 @@ class LowDiscrepancySampler : public Sampler {
public: public:
LowDiscrepancySampler() : Sampler(Properties()) { } LowDiscrepancySampler() : Sampler(Properties()) { }
LowDiscrepancySampler(Stream *stream, InstanceManager *manager)
: Sampler(stream, manager) {
m_depth = stream->readInt();
m_random = static_cast<Random *>(manager->getInstance(stream));
m_samples1D = new Float*[m_depth];
m_samples2D = new Point2*[m_depth];
for (int i=0; i<m_depth; i++) {
m_samples1D[i] = new Float[(size_t) m_sampleCount];
m_samples2D[i] = new Point2[(size_t) m_sampleCount];
}
}
LowDiscrepancySampler(const Properties &props) : Sampler(props) { LowDiscrepancySampler(const Properties &props) : Sampler(props) {
/* Sample count (will be rounded up to the next power of two) */ /* Sample count (will be rounded up to the next power of two) */
m_sampleCount = props.getSize("sampleCount", 4); m_sampleCount = props.getSize("sampleCount", 4);
@ -49,8 +36,8 @@ public:
/* Depth, up to which which low discrepancy samples are guaranteed to be available. */ /* Depth, up to which which low discrepancy samples are guaranteed to be available. */
m_depth = props.getInteger("depth", 3); m_depth = props.getInteger("depth", 3);
if (!isPow2(m_sampleCount)) { if (!isPowerOfTwo(m_sampleCount)) {
m_sampleCount = (size_t) roundToPow2(m_sampleCount); m_sampleCount = roundToPowerOfTwo(m_sampleCount);
Log(EWarn, "Sample count should be a power of two -- rounding to " Log(EWarn, "Sample count should be a power of two -- rounding to "
SIZE_T_FMT, m_sampleCount); SIZE_T_FMT, m_sampleCount);
} }
@ -66,6 +53,19 @@ public:
m_random = new Random(); m_random = new Random();
} }
LowDiscrepancySampler(Stream *stream, InstanceManager *manager)
: Sampler(stream, manager) {
m_random = static_cast<Random *>(manager->getInstance(stream));
m_depth = stream->readInt();
m_samples1D = new Float*[m_depth];
m_samples2D = new Point2*[m_depth];
for (int i=0; i<m_depth; i++) {
m_samples1D[i] = new Float[(size_t) m_sampleCount];
m_samples2D[i] = new Point2[(size_t) m_sampleCount];
}
}
virtual ~LowDiscrepancySampler() { virtual ~LowDiscrepancySampler() {
for (int i=0; i<m_depth; i++) { for (int i=0; i<m_depth; i++) {
delete[] m_samples1D[i]; delete[] m_samples1D[i];
@ -77,8 +77,8 @@ public:
void serialize(Stream *stream, InstanceManager *manager) const { void serialize(Stream *stream, InstanceManager *manager) const {
Sampler::serialize(stream, manager); Sampler::serialize(stream, manager);
stream->writeInt(m_depth);
manager->serialize(stream, m_random.get()); manager->serialize(stream, m_random.get());
stream->writeInt(m_depth);
} }
ref<Sampler> clone() { ref<Sampler> clone() {
@ -198,9 +198,9 @@ public:
std::string toString() const { std::string toString() const {
std::ostringstream oss; std::ostringstream oss;
oss << "LowDiscrepancySampler[" << std::endl oss << "LowDiscrepancySampler[" << endl
<< " sampleCount = " << m_sampleCount << "," << std::endl << " sampleCount = " << m_sampleCount << "," << endl
<< " depth = " << m_depth << std::endl << " depth = " << m_depth << endl
<< "]"; << "]";
return oss.str(); return oss.str();
} }
@ -209,7 +209,8 @@ public:
private: private:
ref<Random> m_random; ref<Random> m_random;
int m_depth; int m_depth;
int m_sampleDepth1D, m_sampleDepth2D; int m_sampleDepth1D;
int m_sampleDepth2D;
Float **m_samples1D; Float **m_samples1D;
Point2 **m_samples2D; Point2 **m_samples2D;
}; };

View File

@ -30,8 +30,7 @@ MTS_NAMESPACE_BEGIN
*/ */
class StratifiedSampler : public Sampler { class StratifiedSampler : public Sampler {
public: public:
StratifiedSampler() : Sampler(Properties()) { StratifiedSampler() : Sampler(Properties()) { }
}
StratifiedSampler(const Properties &props) : Sampler(props) { StratifiedSampler(const Properties &props) : Sampler(props) {
/* Sample count (will be rounded up to the next perfect square) */ /* Sample count (will be rounded up to the next perfect square) */
@ -195,12 +194,12 @@ public:
std::string toString() const { std::string toString() const {
std::ostringstream oss; std::ostringstream oss;
oss << "StratifiedSampler[" << std::endl oss << "StratifiedSampler[" << endl
<< " resolution = " << m_resolution << "," << std::endl << " resolution = " << m_resolution << "," << endl
<< " sampleCount = " << m_sampleCount << "," << std::endl << " sampleCount = " << m_sampleCount << "," << endl
<< " depth = " << m_depth << "," << std::endl << " depth = " << m_depth << "," << endl
<< " sampleIndex = " << m_sampleIndex << "," << std::endl << " sampleIndex = " << m_sampleIndex << "," << endl
<< " sampleDepth = " << m_depth << std::endl << " sampleDepth = " << m_depth << endl
<< "]"; << "]";
return oss.str(); return oss.str();
} }

View File

@ -57,7 +57,7 @@ public:
/// Size of an individual block (must be a power of 2) /// Size of an individual block (must be a power of 2)
m_blockSize = props.getInteger("blockSize", 4); m_blockSize = props.getInteger("blockSize", 4);
if (!isPow2(m_blockSize)) if (!isPowerOfTwo(m_blockSize))
Log(EError, "Block size must be a power of two!"); Log(EError, "Block size must be a power of two!");
/* Width of an individual voxel. Will use the step size of the /* Width of an individual voxel. Will use the step size of the