Пример #1
0
	inline Spectrum Le(const Vector &direction) const {
		/* Compute sky light radiance for direction */
		Vector d = normalize(m_worldToLuminaire(direction));

		if (m_clipBelowHorizon) {
			/* if sun is below horizon, return black */
			if (d.z < 0.0f)
				return Spectrum(0.0f);
		}

		/* make all "zero values" the same */
		if (d.z < 0.001f)
			d = normalize(Vector(d.x, d.y,  0.001f));

		const Point2 dSpherical = toSphericalCoordinates(d);
		const Float theta = dSpherical.x;

#ifndef ENFORCE_SINGLE_ZENITH_ANGLE
		const Float phi = dSpherical.y;
#else
		Float phi;
		if (fabs(theta) < 1e-5)
			phi = 0.0f;
		else
			phi = dSpherical.y;
#endif

		Spectrum L;
		getSkySpectralRadiance(theta, phi, L);
		L *= m_skyScale;
		
		return L;
	}
Пример #2
0
	void sample(const Point &p, LuminaireSamplingRecord &lRec,
		const Point2 &sample) const {
		Point local = m_worldToLuminaire(p);
		Vector2 planeProjection = Vector2(local.x, local.y);

		if (planeProjection.length() > m_radius || local.z < 0) {
			lRec.pdf = 0.0f;
		} else {
			lRec.sRec.p = m_luminaireToWorld(Point(local.x, local.y, 0));
			lRec.d = m_direction;
			lRec.luminaire = this;
			lRec.pdf = 1.0f;
			lRec.value = m_intensity;
		}
	}