From 543c43509ccbce7f61849aa49ea079493771bb20 Mon Sep 17 00:00:00 2001 From: Wenzel Jakob Date: Thu, 21 Oct 2010 12:02:10 +0200 Subject: [PATCH] fixed SSS material --- src/librender/subsurface.cpp | 23 +++++++++++++++-------- src/shapes/cylinder.cpp | 21 +++++++++++---------- src/subsurface/dipole.cpp | 7 ++++--- 3 files changed, 30 insertions(+), 21 deletions(-) diff --git a/src/librender/subsurface.cpp b/src/librender/subsurface.cpp index e609fcf3..93f2d2bc 100644 --- a/src/librender/subsurface.cpp +++ b/src/librender/subsurface.cpp @@ -50,16 +50,26 @@ Subsurface::Subsurface(Stream *stream, InstanceManager *manager) : m_eta = stream->readFloat(); m_sizeMultiplier = stream->readFloat(); unsigned int shapeCount = stream->readUInt(); - for (unsigned int i=0; i(manager->getInstance(stream))); + + for (unsigned int i=0; i(manager->getInstance(stream)); + m_shapes.push_back(shape); + } m_sigmaT = m_sigmaS + m_sigmaA; } - + +Subsurface::~Subsurface() { +} + void Subsurface::setParent(ConfigurableObject *parent) { if (parent->getClass()->derivesFrom(Shape::m_theClass)) { Shape *shape = static_cast(parent); - m_shapes.push_back(shape); - m_configured = false; + if (shape->isCompound()) + return; + if (std::find(m_shapes.begin(), m_shapes.end(), shape) == m_shapes.end()) { + m_shapes.push_back(shape); + m_configured = false; + } } else { Log(EError, "IsotropicDipole: Invalid child node!"); } @@ -77,8 +87,5 @@ void Subsurface::serialize(Stream *stream, InstanceManager *manager) const { manager->serialize(stream, m_shapes[i]); } -Subsurface::~Subsurface() { -} - MTS_IMPLEMENT_CLASS(Subsurface, true, NetworkedObject) MTS_NAMESPACE_END diff --git a/src/shapes/cylinder.cpp b/src/shapes/cylinder.cpp index 62bae820..878b05fe 100644 --- a/src/shapes/cylinder.cpp +++ b/src/shapes/cylinder.cpp @@ -214,16 +214,6 @@ public: return true; } - AABB getClippedAABB(const AABB &box) const { - /* Compute a base bounding box */ - AABB base(getAABB()); - base.clip(box); - - /* Now forget about the cylinder ends and - intersect an infinite cylinder with each AABB face */ - return box; - } - #if 0 inline AABB getAABB(Float start, Float end) const { AABB result; @@ -238,6 +228,17 @@ public: return result; } + AABB getClippedAABB(const AABB &box) const { + /* Compute a base bounding box */ + AABB base(getAABB()); + base.clip(box); + + /* Now forget about the cylinder ends and + intersect an infinite cylinder with each AABB face */ + return box; + } + + AABB getAABB() const { /* Very approximate .. */ return getAABB(0, m_length); diff --git a/src/subsurface/dipole.cpp b/src/subsurface/dipole.cpp index d6d008be..92a506ed 100644 --- a/src/subsurface/dipole.cpp +++ b/src/subsurface/dipole.cpp @@ -255,13 +255,14 @@ public: Float sa = 0; for (std::vector::iterator it = m_shapes.begin(); - it != m_shapes.end(); ++it) + it != m_shapes.end(); ++it) sa += (*it)->getSurfaceArea(); size_t sampleCount = (size_t) std::ceil(sa / (M_PI * m_minMFP * m_minMFP) * m_sampleMultiplier); + Log(EInfo, "Generating " SIZE_T_FMT " irradiance samples..", sampleCount); ref sched = Scheduler::getInstance(); - + /* This could be a bit more elegant.. - inform the irradiance sampler about the index of this subsurface integrator */ std::vector ssIntegrators @@ -295,7 +296,7 @@ public: m_octreeResID = Scheduler::getInstance()->registerResource(m_octree); m_ready = true; - return false; + return true; } void wakeup(std::map ¶ms) {