From: Roland Hieber Date: Sun, 31 Jan 2010 03:45:55 +0000 (+0100) Subject: drand() needs X-Git-Url: https://git.rohieb.name/MicroTrace.git/commitdiff_plain/d09f84c0fc495347e9f73c362819f5b726b23dda?hp=a8137256e983a49f97ff1fbecd26a1a0372f7b0b drand() needs --- diff --git a/QuadAreaLight.cxx b/QuadAreaLight.cxx index ed64910..24e0b8e 100644 --- a/QuadAreaLight.cxx +++ b/QuadAreaLight.cxx @@ -1,4 +1,5 @@ #include +#include #include "QuadAreaLight.hxx" @@ -16,7 +17,7 @@ QuadAreaLight::QuadAreaLight(Scene* scene, { m_n = m_e1.cross(m_e2); m_area = m_n.norm(); - m_n.normalize(); + m_n.normalize(); } QuadAreaLight::QuadAreaLight() @@ -36,21 +37,21 @@ QuadAreaLight::~QuadAreaLight() bool QuadAreaLight::Illuminate(Ray& shadow_ray, Vec3f& intensity) { - // generate random factors + // generate random factors float xi1 = drand48(); float xi2 = drand48(); - + // bilinear interpolation of position Vec3f pos = m_p0 + m_e1 * xi1 + m_e2* xi2; // direction of shadow ray Vec3f dir = pos-shadow_ray.origin(); - + float dist = dir.norm(); float cosN = (dir.dot(m_n)) / dist; if(cosN <= 0.0f ) return false; - + // squared falloff and projected area intensity = m_intensity * ( m_area * cosN / ( dist*dist));