提交 782f8e2d 编写于 作者: M Matt Pharr

Fix ImageInfiniteLight luminance computation to use the equi-area parameterization

上级 88a814d4
...@@ -1430,26 +1430,23 @@ LightHandle LightHandle::Create(const std::string &name, ...@@ -1430,26 +1430,23 @@ LightHandle LightHandle::Create(const std::string &name,
// units // units
float illuminance = 0; float illuminance = 0;
const Image &image = imageAndMetadata.image; const Image &image = imageAndMetadata.image;
int ye = image.Resolution().y / 2;
int ys = 0;
int xs = 0;
int xe = image.Resolution().x;
RGB lum = imageAndMetadata.metadata.GetColorSpace()->LuminanceVector(); RGB lum = imageAndMetadata.metadata.GetColorSpace()->LuminanceVector();
for (int y = ys; y < ye; ++y) { for (int y = 0; y < image.Resolution().y; ++y) {
float v = (float(y) + 0.5f) / float(image.Resolution().y); float v = (float(y) + 0.5f) / float(image.Resolution().y);
float theta = (v - 0.5f) * Pi; for (int x = 0; x < image.Resolution().x; ++x) {
float cosTheta = std::cos(theta); Float u = (x + 0.5f) / image.Resolution().x;
float sinTheta = std::sin(theta); Vector3f w = EqualAreaSquareToSphere(Point2f(u, v));
for (int x = xs; x < xe; ++x) { // We could be more clever and see if we're in the inner rotated
// square, but not a big deal...
if (w.z <= 0)
continue;
ImageChannelValues values = image.GetChannels({x, y}); ImageChannelValues values = image.GetChannels({x, y});
for (int c = 0; c < 3; ++c) { for (int c = 0; c < 3; ++c)
illuminance += values[c] * lum[c] * std::abs(cosTheta) * illuminance += values[c] * lum[c] * CosTheta(w);
std::abs(sinTheta);
}
} }
} }
illuminance /= float(ye - ys) * float(xe - xs); illuminance *= 2 * Pi / (image.Resolution().x * image.Resolution().y);
illuminance *= Pi * Pi;
// scaling factor is just the ratio of the target // scaling factor is just the ratio of the target
// illuminance and the illuminance of the map multiplied by // illuminance and the illuminance of the map multiplied by
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册