documentation on the supported types of textures
parent
3527c37f13
commit
24769ecf83
|
@ -161,6 +161,22 @@
|
|||
<xsl:attribute name="name">p1</xsl:attribute>
|
||||
</xsl:template>
|
||||
|
||||
<!-- Update the parameters of the checkerboard plugin -->
|
||||
<xsl:template match="texture[@type='checkerboard']/spectrum[@name='brightColor']/@name">
|
||||
<xsl:attribute name="name">color0</xsl:attribute>
|
||||
</xsl:template>
|
||||
<xsl:template match="texture[@type='checkerboard']/spectrum[@name='darkColor']/@name">
|
||||
<xsl:attribute name="name">color1</xsl:attribute>
|
||||
</xsl:template>
|
||||
|
||||
<!-- Update the parameters of the gridtexture plugin -->
|
||||
<xsl:template match="texture[@type='gridtexture']/spectrum[@name='brightColor']/@name">
|
||||
<xsl:attribute name="name">color0</xsl:attribute>
|
||||
</xsl:template>
|
||||
<xsl:template match="texture[@type='gridtexture']/spectrum[@name='darkColor']/@name">
|
||||
<xsl:attribute name="name">color1</xsl:attribute>
|
||||
</xsl:template>
|
||||
|
||||
<!-- Update the name of the lambertian plugin -->
|
||||
<xsl:template match="bsdf[@type='lambertian']/@type">
|
||||
<xsl:attribute name="type">diffuse</xsl:attribute>
|
||||
|
|
|
@ -61,12 +61,14 @@ f.write('\input{section_shapes}\n')
|
|||
os.path.walk('../src/shapes', traverse, f)
|
||||
f.write('\input{section_bsdf}\n')
|
||||
os.path.walk('../src/bsdfs', traverse, f)
|
||||
f.write('\input{section_phase}\n')
|
||||
os.path.walk('../src/phase', traverse, f)
|
||||
f.write('\input{section_textures}\n')
|
||||
os.path.walk('../src/textures', 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_phase}\n')
|
||||
os.path.walk('../src/phase', traverse, f)
|
||||
f.write('\input{section_luminaires}\n')
|
||||
os.path.walk('../src/luminaires', traverse, f)
|
||||
f.write('\input{section_integrators}\n')
|
||||
|
|
|
@ -0,0 +1,7 @@
|
|||
\newpage
|
||||
\subsection{Textures}
|
||||
\label{sec:textures}
|
||||
The following section describes the available texture sources. In Mitsuba,
|
||||
textures are objects that can be attached to scattering model
|
||||
parameters supporting the ``\Texture'' type (see \secref{bsdfs} for examples).
|
||||
|
|
@ -30,10 +30,62 @@
|
|||
|
||||
MTS_NAMESPACE_BEGIN
|
||||
|
||||
/**
|
||||
* Gamma-corrected bitmap texture using the EXR, JPG, PNG, TGA or BMP
|
||||
* file formats.
|
||||
/*!\plugin{bitmap}{Bitmap texture}
|
||||
* \parameters{
|
||||
* \parameter{filename}{\String}{
|
||||
* Filename of the bitmap to be loaded
|
||||
* }
|
||||
* \parameter{gamma}{\Float}{
|
||||
* Gamma value of the source bitmap file
|
||||
* \default{\emph{automatic}, i.e. linear for EXR input,
|
||||
* and sRGB for everything else.}
|
||||
* }
|
||||
* \parameter{filterType}{\String}{
|
||||
* Specifies the texture filturing that should be used for lookups
|
||||
* \begin{enumerate}[(i)]
|
||||
* \item \code{ewa}: Elliptically weighted average (a.k.a.
|
||||
* anisotropic filtering). This produces the best quality
|
||||
* \item \code{trilinear}: Simple trilinear (isotropic) filtering.
|
||||
* \item \code{none}: No filtering, do nearest neighbor lookups.
|
||||
* \end{enumerate}
|
||||
* Default: \code{ewa}.
|
||||
* }
|
||||
* \parameter{wrapMode}{\String}{
|
||||
* This parameter defines the behavior of the texture outside of the $[0,1]$ $uv$ range.
|
||||
* \begin{enumerate}[(i)]
|
||||
* \item \code{repeat}: Repeat the texture (i.e. $uv$ coordinates
|
||||
* are taken modulo 2)
|
||||
* \item \code{clamp}: Clamp $uv$ coordinates to $[0,1]$
|
||||
* \item \code{black}: Switch to a zero-valued texture
|
||||
* \item \code{white}: Switch to a one-valued texture
|
||||
* \end{enumerate}
|
||||
* Default: \code{repeat}.
|
||||
* }
|
||||
* \parameter{maxAnisotropy}{\Float}{
|
||||
* Specifies an upper limit on the amount of anisotropy
|
||||
* of \code{ewa} lookups\default{8}
|
||||
* }
|
||||
* \parameter{uscale, vscale}{\Float}{
|
||||
* Multiplicative factors that should be applied to UV values before a lookup
|
||||
* }
|
||||
* \parameter{uoffset, voffset}{\Float}{
|
||||
* Numerical offset that should be applied to UV values before a lookup
|
||||
* }
|
||||
* }
|
||||
* This plugin implements a bitmap-based texture, which supports the following
|
||||
* file formats:
|
||||
* \begin{itemize}
|
||||
* \item OpenEXR
|
||||
* \item JPEG
|
||||
* \item PNG (Portable Network Graphics)
|
||||
* \item TGA (Targa)
|
||||
* \item BMP (Windows bitmaps)
|
||||
* \end{itemize}
|
||||
*
|
||||
* The plugin internally converts all bitmap data into a \emph{linear} space to ensure
|
||||
* a proper workflow.
|
||||
*/
|
||||
|
||||
class BitmapTexture : public Texture2D {
|
||||
public:
|
||||
BitmapTexture(const Properties &props) : Texture2D(props) {
|
||||
|
@ -46,9 +98,8 @@ public:
|
|||
|
||||
ref<FileStream> fs = new FileStream(m_filename, FileStream::EReadOnly);
|
||||
std::string extension = boost::to_lower_copy(m_filename.extension());
|
||||
|
||||
std::string filterType = props.getString("filterType", "ewa");
|
||||
std::string wrapMode = props.getString("wrapMode", "repeat");
|
||||
std::string filterType = boost::to_lower_copy(props.getString("filterType", "ewa"));
|
||||
std::string wrapMode = boost::to_lower_copy(props.getString("wrapMode", "repeat"));
|
||||
|
||||
if (filterType == "ewa")
|
||||
m_filterType = MIPMap::EEWA;
|
||||
|
|
|
@ -23,26 +23,38 @@
|
|||
|
||||
MTS_NAMESPACE_BEGIN
|
||||
|
||||
/**
|
||||
* Checkerboard texture
|
||||
/*!\plugin{checkerboard}{Checkerboard}
|
||||
* \parameters{
|
||||
* \parameter{color0, color1}{\Spectrum}{
|
||||
* Color values for the two differently-colored patches
|
||||
* \default{0.4 and 0.2}
|
||||
* }
|
||||
* \parameter{uscale, vscale}{\Float}{
|
||||
* Multiplicative factors that should be applied to UV values before a lookup
|
||||
* }
|
||||
* \parameter{uoffset, voffset}{\Float}{
|
||||
* Numerical offset that should be applied to UV values before a lookup
|
||||
* }
|
||||
* }
|
||||
* This plugin implements a simple procedural checkerboard texture.
|
||||
*/
|
||||
class Checkerboard : public Texture2D {
|
||||
public:
|
||||
Checkerboard(const Properties &props) : Texture2D(props) {
|
||||
m_brightColor = props.getSpectrum("brightColor", Spectrum(.4f));
|
||||
m_darkColor = props.getSpectrum("darkColor", Spectrum(.2f));
|
||||
m_color0 = props.getSpectrum("color0", Spectrum(.4f));
|
||||
m_color1 = props.getSpectrum("color1", Spectrum(.2f));
|
||||
}
|
||||
|
||||
Checkerboard(Stream *stream, InstanceManager *manager)
|
||||
: Texture2D(stream, manager) {
|
||||
m_brightColor = Spectrum(stream);
|
||||
m_darkColor = Spectrum(stream);
|
||||
m_color0 = Spectrum(stream);
|
||||
m_color1 = Spectrum(stream);
|
||||
}
|
||||
|
||||
void serialize(Stream *stream, InstanceManager *manager) const {
|
||||
Texture2D::serialize(stream, manager);
|
||||
m_brightColor.serialize(stream);
|
||||
m_darkColor.serialize(stream);
|
||||
m_color0.serialize(stream);
|
||||
m_color1.serialize(stream);
|
||||
}
|
||||
|
||||
inline Spectrum getValue(const Point2 &uv) const {
|
||||
|
@ -50,9 +62,9 @@ public:
|
|||
y = 2*modulo((int) (uv.y * 2), 2) - 1;
|
||||
|
||||
if (x*y == 1)
|
||||
return m_brightColor;
|
||||
return m_color0;
|
||||
else
|
||||
return m_darkColor;
|
||||
return m_color1;
|
||||
}
|
||||
|
||||
Spectrum getValue(const Point2 &uv, Float dudx, Float dudy, Float dvdx, Float dvdy) const {
|
||||
|
@ -64,11 +76,11 @@ public:
|
|||
}
|
||||
|
||||
Spectrum getAverage() const {
|
||||
return m_darkColor * .5f;
|
||||
return m_color1 * .5f;
|
||||
}
|
||||
|
||||
Spectrum getMaximum() const {
|
||||
return m_brightColor;
|
||||
return m_color0;
|
||||
}
|
||||
|
||||
bool isConstant() const {
|
||||
|
@ -78,8 +90,8 @@ public:
|
|||
std::string toString() const {
|
||||
std::ostringstream oss;
|
||||
oss << "Checkerboard[" << endl
|
||||
<< " darkColor = " << m_darkColor.toString() << "," << endl
|
||||
<< " brightColor = " << m_brightColor.toString() << endl
|
||||
<< " color1 = " << m_color1.toString() << "," << endl
|
||||
<< " color0 = " << m_color0.toString() << endl
|
||||
<< "]";
|
||||
return oss.str();
|
||||
}
|
||||
|
@ -88,26 +100,26 @@ public:
|
|||
|
||||
MTS_DECLARE_CLASS()
|
||||
protected:
|
||||
Spectrum m_darkColor;
|
||||
Spectrum m_brightColor;
|
||||
Spectrum m_color1;
|
||||
Spectrum m_color0;
|
||||
};
|
||||
|
||||
// ================ Hardware shader implementation ================
|
||||
|
||||
class CheckerboardShader : public Shader {
|
||||
public:
|
||||
CheckerboardShader(Renderer *renderer, const Spectrum &brightColor,
|
||||
const Spectrum &darkColor, const Point2 &uvOffset,
|
||||
CheckerboardShader(Renderer *renderer, const Spectrum &color0,
|
||||
const Spectrum &color1, const Point2 &uvOffset,
|
||||
const Vector2 &uvScale) : Shader(renderer, ETextureShader),
|
||||
m_brightColor(brightColor), m_darkColor(darkColor),
|
||||
m_color0(color0), m_color1(color1),
|
||||
m_uvOffset(uvOffset), m_uvScale(uvScale) {
|
||||
}
|
||||
|
||||
void generateCode(std::ostringstream &oss,
|
||||
const std::string &evalName,
|
||||
const std::vector<std::string> &depNames) const {
|
||||
oss << "uniform vec3 " << evalName << "_brightColor;" << endl
|
||||
<< "uniform vec3 " << evalName << "_darkColor;" << endl
|
||||
oss << "uniform vec3 " << evalName << "_color0;" << endl
|
||||
<< "uniform vec3 " << evalName << "_color1;" << endl
|
||||
<< "uniform vec2 " << evalName << "_uvOffset;" << endl
|
||||
<< "uniform vec2 " << evalName << "_uvScale;" << endl
|
||||
<< endl
|
||||
|
@ -117,37 +129,37 @@ public:
|
|||
<< " uv.y * " << evalName << "_uvScale.y + " << evalName << "_uvOffset.y);" << endl
|
||||
<< " float x = 2*(mod(int(uv.x*2), 2)) - 1, y = 2*(mod(int(uv.y*2), 2)) - 1;" << endl
|
||||
<< " if (x*y == 1)" << endl
|
||||
<< " return " << evalName << "_brightColor;" << endl
|
||||
<< " return " << evalName << "_color0;" << endl
|
||||
<< " else" << endl
|
||||
<< " return " << evalName << "_darkColor;" << endl
|
||||
<< " return " << evalName << "_color1;" << endl
|
||||
<< "}" << endl;
|
||||
}
|
||||
|
||||
void resolve(const GPUProgram *program, const std::string &evalName, std::vector<int> ¶meterIDs) const {
|
||||
parameterIDs.push_back(program->getParameterID(evalName + "_brightColor", false));
|
||||
parameterIDs.push_back(program->getParameterID(evalName + "_darkColor", false));
|
||||
parameterIDs.push_back(program->getParameterID(evalName + "_color0", false));
|
||||
parameterIDs.push_back(program->getParameterID(evalName + "_color1", false));
|
||||
parameterIDs.push_back(program->getParameterID(evalName + "_uvOffset", false));
|
||||
parameterIDs.push_back(program->getParameterID(evalName + "_uvScale", false));
|
||||
}
|
||||
|
||||
void bind(GPUProgram *program, const std::vector<int> ¶meterIDs,
|
||||
int &textureUnitOffset) const {
|
||||
program->setParameter(parameterIDs[0], m_brightColor);
|
||||
program->setParameter(parameterIDs[1], m_darkColor);
|
||||
program->setParameter(parameterIDs[0], m_color0);
|
||||
program->setParameter(parameterIDs[1], m_color1);
|
||||
program->setParameter(parameterIDs[2], m_uvOffset);
|
||||
program->setParameter(parameterIDs[3], m_uvScale);
|
||||
}
|
||||
|
||||
MTS_DECLARE_CLASS()
|
||||
private:
|
||||
Spectrum m_brightColor;
|
||||
Spectrum m_darkColor;
|
||||
Spectrum m_color0;
|
||||
Spectrum m_color1;
|
||||
Point2 m_uvOffset;
|
||||
Vector2 m_uvScale;
|
||||
};
|
||||
|
||||
Shader *Checkerboard::createShader(Renderer *renderer) const {
|
||||
return new CheckerboardShader(renderer, m_brightColor, m_darkColor,
|
||||
return new CheckerboardShader(renderer, m_color0, m_color1,
|
||||
m_uvOffset, m_uvScale);
|
||||
}
|
||||
|
||||
|
|
|
@ -23,28 +23,47 @@
|
|||
|
||||
MTS_NAMESPACE_BEGIN
|
||||
|
||||
/**
|
||||
* Grid texture
|
||||
/*!\plugin{gridtexture}{Procedural grid texture}
|
||||
* \parameters{
|
||||
* \parameter{color0}{\Spectrum}{
|
||||
* Color values of the background
|
||||
* \default{0.2}
|
||||
* }
|
||||
* \parameter{color1}{\Spectrum}{
|
||||
* Color value of the lines
|
||||
* \default{0.4}
|
||||
* }
|
||||
* \parameter{lineWidth}{\Float}{Width of the grid lines in UV space
|
||||
* \default{0.01}
|
||||
* }
|
||||
* \parameter{uscale, vscale}{\Float}{
|
||||
* Multiplicative factors that should be applied to UV values before a lookup
|
||||
* }
|
||||
* \parameter{uoffset, voffset}{\Float}{
|
||||
* Numerical offset that should be applied to UV values before a lookup
|
||||
* }
|
||||
* }
|
||||
* This plugin implements a simple procedural grid texture.
|
||||
*/
|
||||
class GridTexture : public Texture2D {
|
||||
public:
|
||||
GridTexture(const Properties &props) : Texture2D(props) {
|
||||
m_brightColor = props.getSpectrum("brightColor", Spectrum(.4f));
|
||||
m_darkColor = props.getSpectrum("darkColor", Spectrum(.2f));
|
||||
m_color0 = props.getSpectrum("color0", Spectrum(.2f));
|
||||
m_color1 = props.getSpectrum("color1", Spectrum(.4f));
|
||||
m_lineWidth = props.getFloat("lineWidth", .01f);
|
||||
}
|
||||
|
||||
GridTexture(Stream *stream, InstanceManager *manager)
|
||||
: Texture2D(stream, manager) {
|
||||
m_brightColor = Spectrum(stream);
|
||||
m_darkColor = Spectrum(stream);
|
||||
m_color0 = Spectrum(stream);
|
||||
m_color1 = Spectrum(stream);
|
||||
m_lineWidth = stream->readFloat();
|
||||
}
|
||||
|
||||
void serialize(Stream *stream, InstanceManager *manager) const {
|
||||
Texture2D::serialize(stream, manager);
|
||||
m_brightColor.serialize(stream);
|
||||
m_darkColor.serialize(stream);
|
||||
m_color0.serialize(stream);
|
||||
m_color1.serialize(stream);
|
||||
stream->writeFloat(m_lineWidth);
|
||||
}
|
||||
|
||||
|
@ -58,9 +77,9 @@ public:
|
|||
y-=1;
|
||||
|
||||
if (std::abs(x) < m_lineWidth || std::abs(y) < m_lineWidth)
|
||||
return m_darkColor;
|
||||
return m_color1;
|
||||
else
|
||||
return m_brightColor;
|
||||
return m_color0;
|
||||
}
|
||||
|
||||
Spectrum getValue(const Point2 &uv, Float dudx,
|
||||
|
@ -73,11 +92,11 @@ public:
|
|||
}
|
||||
|
||||
Spectrum getMaximum() const {
|
||||
return m_brightColor;
|
||||
return m_color0;
|
||||
}
|
||||
|
||||
Spectrum getAverage() const {
|
||||
return m_brightColor; // that's not quite right
|
||||
return m_color0; // that's not quite right
|
||||
}
|
||||
|
||||
bool isConstant() const {
|
||||
|
@ -92,8 +111,8 @@ public:
|
|||
|
||||
MTS_DECLARE_CLASS()
|
||||
protected:
|
||||
Spectrum m_brightColor;
|
||||
Spectrum m_darkColor;
|
||||
Spectrum m_color0;
|
||||
Spectrum m_color1;
|
||||
Float m_lineWidth;
|
||||
};
|
||||
|
||||
|
@ -101,18 +120,18 @@ protected:
|
|||
|
||||
class GridTextureShader : public Shader {
|
||||
public:
|
||||
GridTextureShader(Renderer *renderer, const Spectrum &brightColor,
|
||||
const Spectrum &darkColor, Float lineWidth, const Point2 &uvOffset,
|
||||
GridTextureShader(Renderer *renderer, const Spectrum &color0,
|
||||
const Spectrum &color1, Float lineWidth, const Point2 &uvOffset,
|
||||
const Vector2 &uvScale) : Shader(renderer, ETextureShader),
|
||||
m_brightColor(brightColor), m_darkColor(darkColor),
|
||||
m_color0(color0), m_color1(color1),
|
||||
m_lineWidth(lineWidth), m_uvOffset(uvOffset), m_uvScale(uvScale) {
|
||||
}
|
||||
|
||||
void generateCode(std::ostringstream &oss,
|
||||
const std::string &evalName,
|
||||
const std::vector<std::string> &depNames) const {
|
||||
oss << "uniform vec3 " << evalName << "_brightColor;" << endl
|
||||
<< "uniform vec3 " << evalName << "_darkColor;" << endl
|
||||
oss << "uniform vec3 " << evalName << "_color0;" << endl
|
||||
<< "uniform vec3 " << evalName << "_color1;" << endl
|
||||
<< "uniform float " << evalName << "_lineWidth;" << endl
|
||||
<< "uniform vec2 " << evalName << "_uvOffset;" << endl
|
||||
<< "uniform vec2 " << evalName << "_uvScale;" << endl
|
||||
|
@ -126,15 +145,15 @@ public:
|
|||
<< " if (x > .5) x -= 1.0;" << endl
|
||||
<< " if (y > .5) y -= 1.0;" << endl
|
||||
<< " if (abs(x) < " << evalName << "_lineWidth || abs(y) < " << evalName << "_lineWidth)" << endl
|
||||
<< " return " << evalName << "_darkColor;" << endl
|
||||
<< " return " << evalName << "_color1;" << endl
|
||||
<< " else" << endl
|
||||
<< " return " << evalName << "_brightColor;" << endl
|
||||
<< " return " << evalName << "_color0;" << endl
|
||||
<< "}" << endl;
|
||||
}
|
||||
|
||||
void resolve(const GPUProgram *program, const std::string &evalName, std::vector<int> ¶meterIDs) const {
|
||||
parameterIDs.push_back(program->getParameterID(evalName + "_brightColor", false));
|
||||
parameterIDs.push_back(program->getParameterID(evalName + "_darkColor", false));
|
||||
parameterIDs.push_back(program->getParameterID(evalName + "_color0", false));
|
||||
parameterIDs.push_back(program->getParameterID(evalName + "_color1", false));
|
||||
parameterIDs.push_back(program->getParameterID(evalName + "_lineWidth", false));
|
||||
parameterIDs.push_back(program->getParameterID(evalName + "_uvOffset", false));
|
||||
parameterIDs.push_back(program->getParameterID(evalName + "_uvScale", false));
|
||||
|
@ -142,8 +161,8 @@ public:
|
|||
|
||||
void bind(GPUProgram *program, const std::vector<int> ¶meterIDs,
|
||||
int &textureUnitOffset) const {
|
||||
program->setParameter(parameterIDs[0], m_brightColor);
|
||||
program->setParameter(parameterIDs[1], m_darkColor);
|
||||
program->setParameter(parameterIDs[0], m_color0);
|
||||
program->setParameter(parameterIDs[1], m_color1);
|
||||
program->setParameter(parameterIDs[2], m_lineWidth);
|
||||
program->setParameter(parameterIDs[3], m_uvOffset);
|
||||
program->setParameter(parameterIDs[4], m_uvScale);
|
||||
|
@ -151,15 +170,15 @@ public:
|
|||
|
||||
MTS_DECLARE_CLASS()
|
||||
private:
|
||||
Spectrum m_brightColor;
|
||||
Spectrum m_darkColor;
|
||||
Spectrum m_color0;
|
||||
Spectrum m_color1;
|
||||
Float m_lineWidth;
|
||||
Point2 m_uvOffset;
|
||||
Vector2 m_uvScale;
|
||||
};
|
||||
|
||||
Shader *GridTexture::createShader(Renderer *renderer) const {
|
||||
return new GridTextureShader(renderer, m_brightColor, m_darkColor,
|
||||
return new GridTextureShader(renderer, m_color0, m_color1,
|
||||
m_lineWidth, m_uvOffset, m_uvScale);
|
||||
}
|
||||
|
||||
|
|
|
@ -22,8 +22,22 @@
|
|||
|
||||
MTS_NAMESPACE_BEGIN
|
||||
|
||||
/**
|
||||
* Vertex colors passthrough texture
|
||||
/*!\plugin{vertexcolors}{Vertex color passthrough texture}
|
||||
* When rendering with a mesh that contains vertex colors,
|
||||
* this plugin exposes the underlying color data as a texture.
|
||||
* Currently, this is only supported by the \code{PLY}
|
||||
* file format loader.
|
||||
*
|
||||
* Here is an example:
|
||||
* \begin{xml}[caption=Rendering a PLY file with vertex colors]
|
||||
* <shape type="ply">
|
||||
* <string name="filename" value="mesh.ply"/>
|
||||
*
|
||||
* <bsdf type="diffuse">
|
||||
* <texture type="vertexcolors" name="reflectance"/>
|
||||
* </bsdf>
|
||||
* </shape>
|
||||
* \end{xml}
|
||||
*/
|
||||
class VertexColors : public Texture {
|
||||
public:
|
||||
|
|
Loading…
Reference in New Issue