void Shape::configure() { if (m_bsdf == NULL) { ref<BSDF> bsdf = NULL; if (isEmitter() || isSensor() || hasSubsurface()) { /* Light source / sensor and no BSDF! -> set an all-absorbing BSDF */ Properties props("diffuse"); props.setSpectrum("reflectance", Spectrum(0.0f)); bsdf = static_cast<BSDF *> (PluginManager::getInstance()-> createObject(MTS_CLASS(BSDF), props)); } else if (!isMediumTransition()) { /* A surface without BSDF, which is not a medium transition/sensor/emitter/subsurface emitter doesn't make much sense. Assign it a 0.5 Lambertian BRDF for convenience */ Properties props("diffuse"); props.setSpectrum("reflectance", Spectrum(0.5f)); bsdf = static_cast<BSDF *> (PluginManager::getInstance()-> createObject(MTS_CLASS(BSDF), props)); } else { /* Assign a "null" BSDF */ bsdf = static_cast<BSDF *> (PluginManager::getInstance()-> createObject(MTS_CLASS(BSDF), Properties("null"))); } bsdf->configure(); addChild(bsdf); } if ((m_bsdf->getType() & BSDF::ENull) && (isEmitter() || isSensor() || hasSubsurface())) Log(EError, "Shape \"%s\" has an index-matched BSDF and an " "emitter/sensor/subsurface attachment. This is not allowed!", getName().c_str()); }
ExpressionFor::ExpressionFor(Co<Expression> iterator, Co<Expression> start, Co<Expression> end, Co<Expression> delta, Co<Expression> body, bool is_inclusive) : iterator(iterator), start(start), end(end), delta(delta), body(body), is_inclusive(is_inclusive) { isEmitter(false); }
void Material::preview(Shape *shape) { SurfacePoint pt; pt.shape = shape; if (isEmitter()) { Emitter *emitter = getEmitter(pt); emitter->preview(shape); if (emitter != Material::s_nullEmitter) safeDelete(emitter); } BSDF *bsdf = getBSDF(pt); bsdf->preview(shape); safeDelete(bsdf); }
void Mesh::activate() { if (!m_bsdf) { /* If no material was assigned, instantiate a diffuse BRDF */ m_bsdf = static_cast<BSDF *>( NoriObjectFactory::createInstance("diffuse", PropertyList())); } //check if the mesh is an emitter if(isEmitter()){ m_dpdf = new DiscretePDF(m_F.cols()); //for every face set the surface area for (int i = 0; i < m_F.cols(); ++i) { float curArea = surfaceArea(i); m_dpdf->append(curArea); m_surfaceArea += curArea; } //normalize the pdf m_dpdf->normalize(); } }
///============================================================ void CEventEmitterMulti::addEmitter(IEventEmitter *e, bool mustDelete) { nlassert(e != this); // avoid infinite recursion nlassert(!isEmitter(e)); _Emitters.push_back(std::make_pair(e, mustDelete)); }