Vector3f AreaDiskLight::sample(float u1, float u2, Vector3f &ns) const { Vector3f p; UniformSampleDisk(u1, u2, p.x(), p.y()); p.x() *= radius; p.y() *= radius; p.z() = height; ns = lightToWorld.matrix.topLeftCorner<3, 3>() * Vector3f(0.f, 0.f, 1.f); return lightToWorld * p; }
//--------------------------------------------------------------------- static Vec3 CosineSampleHemisphere(float u1, float u2) { Vec3 res; UniformSampleDisk(u1, u2, res.x, res.y); res.z = sqrtf(std::max(0.f, 1.f - res.x*res.x - res.y*res.y)); return res; }