示例#1
0
文件: ward.cpp 项目: blckshrk/IFT6042
	void configure() {
		unsigned int extraFlags = 0;
		if (m_alphaU != m_alphaV)
			extraFlags |= EAnisotropic;

		m_components.clear();
		m_components.push_back(EGlossyReflection | EFrontSide | extraFlags
			| ((!m_specularReflectance->isConstant() || !m_alphaU->isConstant()
			  || !m_alphaV->isConstant()) ? ESpatiallyVarying : 0));
		m_components.push_back(EDiffuseReflection | EFrontSide | extraFlags
			| (m_diffuseReflectance->isConstant() ? 0 : ESpatiallyVarying));

		/* Verify the input parameters and fix them if necessary */
		std::pair<Texture *, Texture *> result = ensureEnergyConservation(
			m_specularReflectance, m_diffuseReflectance,
			"specularReflectance", "diffuseReflectance", 1.0f);
		m_specularReflectance = result.first;
		m_diffuseReflectance = result.second;

		/* Compute weights that steer samples towards
		   the specular or diffuse components */
		Float dAvg = m_diffuseReflectance->getAverage().getLuminance(),
			  sAvg = m_specularReflectance->getAverage().getLuminance();
		m_specularSamplingWeight = sAvg / (dAvg + sAvg);

		m_usesRayDifferentials =
			m_diffuseReflectance->usesRayDifferentials() ||
			m_specularReflectance->usesRayDifferentials() ||
			m_alphaU->usesRayDifferentials() ||
			m_alphaV->usesRayDifferentials();

		BSDF::configure();
	}
    void configure() {
        /* Verify the input parameters and fix them if necessary */
        m_transmittance = ensureEnergyConservation(m_transmittance, "transmittance", 1.0f);

        m_components.clear();
        m_components.push_back(EDiffuseTransmission | EFrontSide | EBackSide
                               | (m_transmittance->isConstant() ? 0 : ESpatiallyVarying));
        BSDF::configure();
    }
	void configure() {
		/* Verify the input parameters and fix them if necessary */
		m_specularReflectance = ensureEnergyConservation(
			m_specularReflectance, "specularReflectance", 1.0f);
		
		m_usesRayDifferentials = 
			m_specularReflectance->usesRayDifferentials();

		m_components.clear();
		m_components.push_back(EDeltaReflection | EFrontSide
			| (m_specularReflectance->isConstant() ? 0 : ESpatiallyVarying));

		BSDF::configure();
	}
示例#4
0
	void configure() {
		unsigned int extraFlags = 0;
		if (!m_sigmaA->isConstant() || !m_alpha->isConstant())
			extraFlags |= ESpatiallyVarying;

		m_components.clear();
		for (int i=0; i<m_nested->getComponentCount(); ++i)
			m_components.push_back(m_nested->getType(i) | extraFlags);

		m_components.push_back(EGlossyReflection | EFrontSide | EBackSide
			| (m_specularReflectance->isConstant() ? 0 : ESpatiallyVarying));

		m_usesRayDifferentials = m_nested->usesRayDifferentials()
			|| m_sigmaA->usesRayDifferentials()
			|| m_alpha->usesRayDifferentials()
			|| m_specularReflectance->usesRayDifferentials();

		/* Compute weights that further steer samples towards
		   the specular or nested components */
		Float avgAbsorption = (m_sigmaA->getAverage()
			 *(-2*m_thickness)).exp().average();

		m_specularSamplingWeight = 1.0f / (avgAbsorption + 1.0f);

		/* Verify the input parameters and fix them if necessary */
		m_specularReflectance = ensureEnergyConservation(
			m_specularReflectance, "specularReflectance", 1.0f);

		if (!m_roughTransmittance.get()) {
			/* Load precomputed data used to compute the rough
			   transmittance through the dielectric interface */
			m_roughTransmittance = new RoughTransmittance(
				m_distribution.getType());

			m_roughTransmittance->checkEta(m_eta);
			m_roughTransmittance->checkAlpha(m_alpha->getMinimum().average());
			m_roughTransmittance->checkAlpha(m_alpha->getMaximum().average());

			/* Reduce the rough transmittance data to a 2D slice */
			m_roughTransmittance->setEta(m_eta);

			/* If possible, even reduce it to a 1D slice */
			if (m_alpha->isConstant())
				m_roughTransmittance->setAlpha(
					m_alpha->eval(Intersection()).average());
		}

		BSDF::configure();
	}
示例#5
0
	void configure() {
		unsigned int extraFlags = 0;
		if (m_alphaU != m_alphaV)
			extraFlags |= EAnisotropic;

		if (!m_alphaU->isConstant() || !m_alphaV->isConstant() ||
			!m_specularReflectance->isConstant())
			extraFlags |= ESpatiallyVarying;

		m_components.clear();
		m_components.push_back(EGlossyReflection | EFrontSide | extraFlags);

		/* Verify the input parameters and fix them if necessary */
		m_specularReflectance = ensureEnergyConservation(
			m_specularReflectance, "specularReflectance", 1.0f);

		m_usesRayDifferentials =
			m_alphaU->usesRayDifferentials() ||
			m_alphaV->usesRayDifferentials() ||
			m_specularReflectance->usesRayDifferentials();

		BSDF::configure();
	}