4 #include "QuadAreaLight.hxx"
6 QuadAreaLight::QuadAreaLight(Scene
* scene
,
7 const Vec3f
& intensity
,
16 m_intensity(intensity
)
18 m_n
= m_e1
.cross(m_e2
);
23 QuadAreaLight::QuadAreaLight()
33 QuadAreaLight::~QuadAreaLight()
38 QuadAreaLight::Illuminate(Ray
& shadow_ray
, Vec3f
& intensity
)
40 // generate random factors
41 float xi1
= drand48();
42 float xi2
= drand48();
44 // bilinear interpolation of position
45 Vec3f pos
= m_p0
+ m_e1
* xi1
+ m_e2
* xi2
;
46 // direction of shadow ray
47 Vec3f dir
= pos
-shadow_ray
.origin();
49 float dist
= dir
.norm();
50 float cosN
= (dir
.dot(m_n
)) / dist
;
55 // squared falloff and projected area
56 intensity
= m_intensity
* ( m_area
* cosN
/ ( dist
*dist
));
59 shadow_ray
.setDir(dir
);
60 shadow_ray
.setT(dist
);
66 QuadAreaLight::IsArea()
72 QuadAreaLight::GetNormal(const Vec3f
& pos
) const
This page took 0.04324 seconds and 5 git commands to generate.