diff --git a/RayTracer/shape/LightSingleGroup.cpp b/RayTracer/shape/LightSingleGroup.cpp index 3cea533b13dcc49438933f6c3056e5decfe19ebf..79a9216811f534fbe9d33cda71aac3038e698c37 100644 --- a/RayTracer/shape/LightSingleGroup.cpp +++ b/RayTracer/shape/LightSingleGroup.cpp @@ -13,8 +13,11 @@ LightSingleGroup::LightSingleGroup(const util::Mat4& matrix, : light(light), transform(util::Transformation(matrix)) { } -util::SurfacePoint LightSingleGroup::sampleLight() const { - auto sample = light->sampleLight(); +util::SurfacePoint LightSingleGroup::sampleLight(const cam::Hit& h) const { + cam::Hit xx(transform.fromWorld.transformPoint(h.point()), + transform.fromWorldN.transformDir(h.normal()), h.texel(), + h.scalar(), h.material); + auto sample = light->sampleLight(xx); auto result = util::SurfacePoint(transform.toWorld.transformPoint(sample.point()), transform.toWorldN.transformDir(sample.normal()), diff --git a/RayTracer/shape/LightSingleGroup.h b/RayTracer/shape/LightSingleGroup.h index b824d426ac39f010b68e4cde4caefcdc273eac03..0cda9ba99b3108e5734538745a820ddca3505f0b 100644 --- a/RayTracer/shape/LightSingleGroup.h +++ b/RayTracer/shape/LightSingleGroup.h @@ -11,7 +11,7 @@ class LightSingleGroup : public Light { std::shared_ptr<Light> shape); LightSingleGroup(const util::Mat4& matrix, std::shared_ptr<Light> shape); - util::SurfacePoint sampleLight() const override; + util::SurfacePoint sampleLight(const cam::Hit& h) const override; util::Vec3 calculateLightEmission(const util::SurfacePoint& p, const util::Vec3& d) const override;