Commit b4ddf33d authored by Matt Pharr's avatar Matt Pharr Committed by Jan Scheffczyk

Fix bogus computation of cosTotalWidth in ProjectionLight.

This caused sampling outgoing rays to be incorrect, missing much of the
image, which led to bogus results with e.g. BDPT.
parent 76c61031
......@@ -68,9 +68,10 @@ ProjectionLight::ProjectionLight(const Transform &LightToWorld,
lightProjection = Perspective(fov, hither, yon);
// Compute cosine of cone surrounding projection directions
Float opposite = std::tan(Radians(fov) / 2.f);
Float tanDiag = opposite * std::sqrt(1 + 1 / (aspect * aspect));
cosTotalWidth = std::cos(std::atan(tanDiag));
// Distance from origin to a corner of the screen window.
Float h = (screenBounds.pMin.x * screenBounds.pMin.x +
screenBounds.pMin.y * screenBounds.pMin.y + 1);
cosTotalWidth = 1 / h;
}
Spectrum ProjectionLight::Sample_Li(const Interaction &ref, const Point2f &u,
......@@ -115,7 +116,7 @@ Spectrum ProjectionLight::Sample_Le(const Point2f &u1, const Point2f &u2,
ProfilePhase _(Prof::LightSample);
Vector3f v = UniformSampleCone(u1, cosTotalWidth);
*ray = Ray(pLight, LightToWorld(v), Infinity, time, mediumInterface.inside);
*nLight = (Normal3f)ray->d; /// same here
*nLight = (Normal3f)ray->d;
*pdfPos = 1.f;
*pdfDir = UniformConePdf(cosTotalWidth);
return I * Projection(ray->d);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment