added a new Texture::isMonochromatic function

metadata
Wenzel Jakob 2013-12-10 17:02:07 +01:00
parent 3d7592cf6e
commit a424a29602
11 changed files with 61 additions and 1 deletions

View File

@ -73,6 +73,10 @@ public:
return false;
}
inline bool isMonochromatic() const {
return m_value == Spectrum(m_value[0]);
}
Shader *createShader(Renderer *renderer) const;
ref<Bitmap> getBitmap(const Vector2i &resolutionHint) const;
@ -128,6 +132,10 @@ public:
return false;
}
inline bool isMonochromatic() const {
return true;
}
Shader *createShader(Renderer *renderer) const;
ref<Bitmap> getBitmap(const Vector2i &resolutionHint) const;
@ -187,6 +195,10 @@ public:
return m_a->usesRayDifferentials() || m_b->usesRayDifferentials();
}
inline bool isMonochromatic() const {
return m_a->isMonochromatic() && m_b->isMonochromatic();
}
Shader *createShader(Renderer *renderer) const;
ref<Bitmap> getBitmap(const Vector2i &resolutionHint) const;
@ -246,6 +258,10 @@ public:
return m_a->usesRayDifferentials() || m_b->usesRayDifferentials();
}
inline bool isMonochromatic() const {
return m_a->isMonochromatic() && m_b->isMonochromatic();
}
Shader *createShader(Renderer *renderer) const;
ref<Bitmap> getBitmap(const Vector2i &resolutionHint) const;
@ -306,6 +322,10 @@ public:
return m_a->usesRayDifferentials() || m_b->usesRayDifferentials();
}
inline bool isMonochromatic() const {
return m_a->isMonochromatic() && m_b->isMonochromatic();
}
Shader *createShader(Renderer *renderer) const;
void serialize(Stream *stream, InstanceManager *manager) const;

View File

@ -63,9 +63,16 @@ public:
/// Return the resolution in pixels, if applicable
virtual Vector3i getResolution() const;
/// Return whether the texture takes on a single constant value
/// Return whether the texture takes on a constant value everywhere
virtual bool isConstant() const;
/**
* \brief Return whether the texture is monochromatic / spectrally uniform
*
* The implementation may conservatively return \c false if it is not sure.
*/
virtual bool isMonochromatic() const;
/**
* \brief Does this texture perform any pre-filtering when
* ray differentials are available?

View File

@ -482,6 +482,7 @@ void export_render() {
.def("getSensor", shape_getSensor, BP_RETURN_VALUE)
.def("hasBSDF", &Shape::hasBSDF)
.def("getBSDF", shape_getBSDF, BP_RETURN_VALUE)
.def("setBSDF", &Shape::setBSDF)
.def("getPrimitiveCount", &Shape::getPrimitiveCount)
.def("getEffectivePrimitiveCount", &Shape::getEffectivePrimitiveCount)
.def("copyAttachments", &Shape::copyAttachments);

View File

@ -46,6 +46,7 @@ Spectrum Texture::getAverage() const { NotImplementedError("getAverage"); }
Spectrum Texture::getMinimum() const { NotImplementedError("getMinimum"); }
Spectrum Texture::getMaximum() const { NotImplementedError("getMaximum"); }
bool Texture::isConstant() const { NotImplementedError("isConstant"); }
bool Texture::isMonochromatic() const { NotImplementedError("isMonochromatic"); }
bool Texture::usesRayDifferentials() const { NotImplementedError("usesRayDifferentials"); }
ref<Bitmap> Texture::getBitmap(const Vector2i &) const { NotImplementedError("getBitmap"); }

View File

@ -542,6 +542,10 @@ public:
return true;
}
bool isMonochromatic() const {
return m_mipmap1.get() != NULL;
}
Vector3i getResolution() const {
if (m_mipmap3.get()) {
return Vector3i(

View File

@ -105,6 +105,11 @@ public:
return false;
}
bool isMonochromatic() const {
return Spectrum(m_color0[0]) == m_color0
&& Spectrum(m_color1[0]) == m_color1;
}
std::string toString() const {
std::ostringstream oss;
oss << "Checkerboard[" << endl

View File

@ -105,6 +105,10 @@ public:
return Spectrum(1.0f);
}
bool isMonochromatic() const {
return false;
}
bool isConstant() const {
return false;
}

View File

@ -122,6 +122,11 @@ public:
return false;
}
bool isMonochromatic() const {
return Spectrum(m_color0[0]) == m_color0
&& Spectrum(m_color1[0]) == m_color1;
}
std::string toString() const {
return "GridTexture[]";
}

View File

@ -138,6 +138,10 @@ public:
return m_nested->usesRayDifferentials();
}
bool isMonochromatic() const {
return m_nested->isMonochromatic();
}
Shader *createShader(Renderer *renderer) const;
void serialize(Stream *stream, InstanceManager *manager) const {

View File

@ -80,6 +80,10 @@ public:
return false;
}
bool isMonochromatic() const {
return false; /* No way to tell from here, really .. */
}
std::string toString() const {
return "VertexColors[]";
}

View File

@ -152,6 +152,11 @@ public:
return false;
}
bool isMonochromatic() const {
return Spectrum(m_edgeColor[0]) == m_edgeColor
&& Spectrum(m_interiorColor[0]) == m_interiorColor;
}
std::string toString() const {
std::ostringstream oss;
oss << "WireFrame[" << endl