ed649102129bbcad7b596484e19d8d15f21018e0
3 #include "QuadAreaLight.hxx"
5 QuadAreaLight::QuadAreaLight(Scene
* scene
,
6 const Vec3f
& intensity
,
15 m_intensity(intensity
)
17 m_n
= m_e1
.cross(m_e2
);
22 QuadAreaLight::QuadAreaLight()
32 QuadAreaLight::~QuadAreaLight()
37 QuadAreaLight::Illuminate(Ray
& shadow_ray
, Vec3f
& intensity
)
39 // generate random factors
40 float xi1
= drand48();
41 float xi2
= drand48();
43 // bilinear interpolation of position
44 Vec3f pos
= m_p0
+ m_e1
* xi1
+ m_e2
* xi2
;
45 // direction of shadow ray
46 Vec3f dir
= pos
-shadow_ray
.origin();
48 float dist
= dir
.norm();
49 float cosN
= (dir
.dot(m_n
)) / dist
;
54 // squared falloff and projected area
55 intensity
= m_intensity
* ( m_area
* cosN
/ ( dist
*dist
));
58 shadow_ray
.setDir(dir
);
59 shadow_ray
.setT(dist
);
65 QuadAreaLight::IsArea()
71 QuadAreaLight::GetNormal(const Vec3f
& pos
) const
This page took 0.044179 seconds and 3 git commands to generate.