From aec0c6a9846ba9c51fa8cd170da4aa246898c5c3 Mon Sep 17 00:00:00 2001 From: Wenzel Jakob Date: Fri, 12 Oct 2012 11:49:53 -0400 Subject: [PATCH] implemented getRoughness() for the remainder of BSDFs --- src/bsdfs/blendbsdf.cpp | 6 ++++++ src/bsdfs/bump.cpp | 4 ++++ src/bsdfs/coating.cpp | 5 +++++ src/bsdfs/hk.cpp | 6 ++++++ src/bsdfs/irawan.cpp | 6 ++++++ src/bsdfs/roughcoating.cpp | 6 ++++++ 6 files changed, 33 insertions(+) diff --git a/src/bsdfs/blendbsdf.cpp b/src/bsdfs/blendbsdf.cpp index 51262e76..bc81157e 100644 --- a/src/bsdfs/blendbsdf.cpp +++ b/src/bsdfs/blendbsdf.cpp @@ -261,6 +261,12 @@ public: } } + Float getRoughness(const Intersection &its, int component) const { + int bsdfIndex = m_indices[component].first; + component = m_indices[component].second; + return m_bsdfs[bsdfIndex]->getRoughness(its, component); + } + void addChild(const std::string &name, ConfigurableObject *child) { if (child->getClass()->derivesFrom(MTS_CLASS(BSDF))) { BSDF *bsdf = static_cast(child); diff --git a/src/bsdfs/bump.cpp b/src/bsdfs/bump.cpp index a51f10af..0faf92e1 100644 --- a/src/bsdfs/bump.cpp +++ b/src/bsdfs/bump.cpp @@ -230,6 +230,10 @@ public: return result; } + Float getRoughness(const Intersection &its, int component) const { + return m_nested->getRoughness(its, component); + } + std::string toString() const { std::ostringstream oss; oss << "BumpMap[" << endl diff --git a/src/bsdfs/coating.cpp b/src/bsdfs/coating.cpp index ca2a0be1..e50ed9d0 100644 --- a/src/bsdfs/coating.cpp +++ b/src/bsdfs/coating.cpp @@ -379,6 +379,11 @@ public: return SmoothCoating::sample(bRec, pdf, sample); } + Float getRoughness(const Intersection &its, int component) const { + return component < (int) m_components.size() + ? m_nested->getRoughness(its, component) : (Float) 0; + } + std::string toString() const { std::ostringstream oss; oss << "SmoothCoating[" << endl diff --git a/src/bsdfs/hk.cpp b/src/bsdfs/hk.cpp index 887ac843..bc0097a5 100644 --- a/src/bsdfs/hk.cpp +++ b/src/bsdfs/hk.cpp @@ -408,6 +408,12 @@ public: } } + Float getRoughness(const Intersection &its, int component) const { + /* For lack of a better value, treat this material as diffuse + in Manifold Exploration */ + return std::numeric_limits::infinity(); + } + std::string toString() const { std::ostringstream oss; oss << "HanrahanKrueger[" << endl diff --git a/src/bsdfs/irawan.cpp b/src/bsdfs/irawan.cpp index 053bff5e..311afe98 100644 --- a/src/bsdfs/irawan.cpp +++ b/src/bsdfs/irawan.cpp @@ -614,6 +614,12 @@ public: return al / (4.0f * M_PI) * c1 * c2 / (c1 + c2); } + Float getRoughness(const Intersection &its, int component) const { + /* For lack of a better value, treat this material as diffuse + in Manifold Exploration */ + return std::numeric_limits::infinity(); + } + std::string toString() const { std::ostringstream oss; oss << "IrawanClothBRDF[" << endl diff --git a/src/bsdfs/roughcoating.cpp b/src/bsdfs/roughcoating.cpp index cb153317..77fe6784 100644 --- a/src/bsdfs/roughcoating.cpp +++ b/src/bsdfs/roughcoating.cpp @@ -437,6 +437,12 @@ public: return RoughCoating::sample(bRec, pdf, sample); } + Float getRoughness(const Intersection &its, int component) const { + return component < (int) m_components.size() + ? m_nested->getRoughness(its, component) + : m_alpha->getAverage().average(); + } + void addChild(const std::string &name, ConfigurableObject *child) { if (child->getClass()->derivesFrom(MTS_CLASS(BSDF))) { if (m_nested != NULL)