Skip to content
Snippets Groups Projects
Commit 626a4a69 authored by Yoel's avatar Yoel
Browse files

Refactor point light with emission and pdf

parent f271d5cc
No related branches found
No related tags found
No related merge requests found
......@@ -13,14 +13,21 @@ util::SurfacePoint PointLight::sampleLight(const cam::Hit& h) const {
return util::SurfacePoint(util::Vec3(0), h.point().normalize(), {},
material);
}
util::Vec3 PointLight::calculateLightEmission(const util::SurfacePoint& p,
const util::Vec3& d) const {
// Basically this is just the emission at a surface point. And the pdf dimms
// the light in regard to the angle.
auto emission = p.emission();
// Illegally do not divide by area
// auto area = M_PI * std::pow(radius, 2);
auto pdf = std::pow(d.length(), 2);
return emission / pdf;
/*std::pair<util::Vec3, float> PointLight::calculateLightEmission(
const util::SurfacePoint& p, const util::Vec3& d) const {
// Basically this is just the emission at a surface point. And the pdf dimms
// the light in regard to the angle.
auto emission = p.emission();
// Illegally do not divide by area
// auto area = M_PI * std::pow(radius, 2);
auto pdf = std::pow(d.length(), 2);
return {emission, pdf};
}*/
util::Vec3 PointLight::lightEmission(const util::SurfacePoint& p) const {
return p.emission();
}
float PointLight::lightPdf(const util::SurfacePoint& p,
const util::Vec3& dl_out) const {
return -std::pow(dl_out.length(), 2);
}
} // namespace shapes
......@@ -8,8 +8,9 @@ class PointLight : public Light {
PointLight(const util::Vec3& emission);
util::SurfacePoint sampleLight(const cam::Hit& h) const override;
util::Vec3 calculateLightEmission(const util::SurfacePoint& p,
const util::Vec3& d) const override;
util::Vec3 lightEmission(const util::SurfacePoint& p) const override;
float lightPdf(const util::SurfacePoint& p,
const util::Vec3& dl_out) const override;
private:
std::shared_ptr<material::Material> material;
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment