Skip to content

Commit

Permalink
Physlight (#16)
Browse files Browse the repository at this point in the history
Add Physlight.
  • Loading branch information
anderslanglands authored Aug 20, 2020
1 parent 0d3b3d7 commit 0d7f1ff
Show file tree
Hide file tree
Showing 12 changed files with 1,087 additions and 181 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@ Major changes include:
sampling ([Hart et al. 2019](https://onlinelibrary.wiley.com/doi/abs/10.1111/cgf.14060)).
* An implementation of Bitterli et al's environment light [portal sampling](https://benedikt-bitterli.me/pmems.html)
technique is included.
* Rendering can now be performed in absolute physical units with modelling of real cameras as per [Langlands & Fascione 2020](https://github.com/wetadigital/physlight). Code contributed by Anders Langlands & Luca Fascione Copyright © 2020, Weta Digital, Ltd.
* And also...
* Various improvements have been made to the `Sampler` classes, including
better randomization and a new sampler that implements pmj02bn sampling ([Christensen et
Expand Down
1 change: 1 addition & 0 deletions src/pbrt/cmd/imgtool.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
#include <pbrt/util/spectrum.h>
#include <pbrt/util/string.h>
#include <pbrt/util/vecmath.h>
#include <pbrt/util/progressreporter.h>

extern "C" {
#include <skymodel/ArHosekSkyModel.h>
Expand Down
1 change: 1 addition & 0 deletions src/pbrt/cpu/integrators.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2180,6 +2180,7 @@ void BDPTIntegrator::Render() {

// FIXME: leaks
weightFilms[BufferIndex(s, t)] = new RGBFilm(
Sensor::CreateDefault(),
camera.GetFilm().FullResolution(),
Bounds2i(Point2i(0, 0), camera.GetFilm().FullResolution()),
new BoxFilter, // FIXME: leaks
Expand Down
41 changes: 25 additions & 16 deletions src/pbrt/cpu/integrators_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -87,9 +87,12 @@ std::vector<TestScene> GetScenes() {
new GeometricPrimitive(sphere, material, nullptr, mediumInterface)));
PrimitiveHandle bvh(new BVHAccel(std::move(prims)));

static ConstantSpectrum I(Pi);
// We have to do this little dance here to make sure the spectrum is
// properly normalized (this is usually all handled inside *Light::Create())
ConstantSpectrum I(1);
Float scale = Pi / SpectrumToPhotometric(&I);
std::vector<LightHandle> lights;
lights.push_back(new PointLight(identity, MediumInterface(), &I, 1.f, Allocator()));
lights.push_back(new PointLight(identity, MediumInterface(), &I, scale, Allocator()));

scenes.push_back({bvh, lights, "Sphere, 1 light, Kd = 0.5", 1.0});
}
Expand All @@ -111,12 +114,15 @@ std::vector<TestScene> GetScenes() {
new GeometricPrimitive(sphere, material, nullptr, mediumInterface)));
PrimitiveHandle bvh(new BVHAccel(std::move(prims)));

static ConstantSpectrum I(Pi / 4);
// We have to do this little dance here to make sure the spectrum is
// properly normalized (this is usually all handled inside *Light::Create())
ConstantSpectrum I(1);
Float scale = Pi / (4 * SpectrumToPhotometric(&I));
std::vector<LightHandle> lights;
lights.push_back(new PointLight(identity, MediumInterface(), &I, 1.f, Allocator()));
lights.push_back(new PointLight(identity, MediumInterface(), &I, 1.f, Allocator()));
lights.push_back(new PointLight(identity, MediumInterface(), &I, 1.f, Allocator()));
lights.push_back(new PointLight(identity, MediumInterface(), &I, 1.f, Allocator()));
lights.push_back(new PointLight(identity, MediumInterface(), &I, scale, Allocator()));
lights.push_back(new PointLight(identity, MediumInterface(), &I, scale, Allocator()));
lights.push_back(new PointLight(identity, MediumInterface(), &I, scale, Allocator()));
lights.push_back(new PointLight(identity, MediumInterface(), &I, scale, Allocator()));

scenes.push_back({bvh, lights, "Sphere, 1 light, Kd = 0.5", 1.0});
}
Expand All @@ -132,9 +138,12 @@ std::vector<TestScene> GetScenes() {
FloatTextureHandle sigma = alloc.new_object<FloatConstantTexture>(0.);
const MaterialHandle material = new DiffuseMaterial(Kd, sigma, nullptr);

static ConstantSpectrum Le(0.5);
// We have to do this little dance here to make sure the spectrum is
// properly normalized (this is usually all handled inside *Light::Create())
ConstantSpectrum Le(1);
Float scale = 0.5 / SpectrumToPhotometric(&Le);
LightHandle areaLight =
new DiffuseAreaLight(identity, MediumInterface(), &Le, 1.f, sphere, Image(),
new DiffuseAreaLight(identity, MediumInterface(), &Le, scale, sphere, Image(),
nullptr, false, Allocator());

std::vector<LightHandle> lights;
Expand Down Expand Up @@ -268,7 +277,7 @@ std::vector<TestIntegrator> GetIntegrators() {
// Path tracing integrators
for (auto &sampler : GetSamplers(resolution)) {
FilterHandle filter = new BoxFilter(Vector2f(0.5, 0.5));
RGBFilm *film = new RGBFilm(resolution,
RGBFilm *film = new RGBFilm(Sensor::CreateDefault(), resolution,
Bounds2i(Point2i(0, 0), resolution), filter, 1.,
inTestDir("test.exr"), 1., RGBColorSpace::sRGB);
PerspectiveCamera *camera = new PerspectiveCamera(
Expand All @@ -286,7 +295,7 @@ std::vector<TestIntegrator> GetIntegrators() {

for (auto &sampler : GetSamplers(resolution)) {
FilterHandle filter = new BoxFilter(Vector2f(0.5, 0.5));
RGBFilm *film = new RGBFilm(resolution,
RGBFilm *film = new RGBFilm(Sensor::CreateDefault(), resolution,
Bounds2i(Point2i(0, 0), resolution), filter, 1.,
inTestDir("test.exr"), 1., RGBColorSpace::sRGB);
OrthographicCamera *camera = new OrthographicCamera(
Expand All @@ -305,7 +314,7 @@ std::vector<TestIntegrator> GetIntegrators() {
// Volume path tracing integrators
for (auto &sampler : GetSamplers(resolution)) {
FilterHandle filter = new BoxFilter(Vector2f(0.5, 0.5));
RGBFilm *film = new RGBFilm(resolution,
RGBFilm *film = new RGBFilm(Sensor::CreateDefault(), resolution,
Bounds2i(Point2i(0, 0), resolution), filter, 1.,
inTestDir("test.exr"), 1., RGBColorSpace::sRGB);
PerspectiveCamera *camera = new PerspectiveCamera(
Expand All @@ -322,7 +331,7 @@ std::vector<TestIntegrator> GetIntegrators() {
}
for (auto &sampler : GetSamplers(resolution)) {
FilterHandle filter = new BoxFilter(Vector2f(0.5, 0.5));
RGBFilm *film = new RGBFilm(resolution,
RGBFilm *film = new RGBFilm(Sensor::CreateDefault(), resolution,
Bounds2i(Point2i(0, 0), resolution), filter, 1.,
inTestDir("test.exr"), 1., RGBColorSpace::sRGB);
OrthographicCamera *camera = new OrthographicCamera(
Expand All @@ -341,7 +350,7 @@ std::vector<TestIntegrator> GetIntegrators() {
// Simple path (perspective only, still sample light and BSDFs). Yolo
for (auto &sampler : GetSamplers(resolution)) {
FilterHandle filter = new BoxFilter(Vector2f(0.5, 0.5));
RGBFilm *film = new RGBFilm(resolution,
RGBFilm *film = new RGBFilm(Sensor::CreateDefault(), resolution,
Bounds2i(Point2i(0, 0), resolution), filter, 1.,
inTestDir("test.exr"), 1., RGBColorSpace::sRGB);
PerspectiveCamera *camera = new PerspectiveCamera(
Expand All @@ -360,7 +369,7 @@ std::vector<TestIntegrator> GetIntegrators() {
// BDPT
for (auto &sampler : GetSamplers(resolution)) {
FilterHandle filter = new BoxFilter(Vector2f(0.5, 0.5));
RGBFilm *film = new RGBFilm(resolution,
RGBFilm *film = new RGBFilm(Sensor::CreateDefault(), resolution,
Bounds2i(Point2i(0, 0), resolution), filter, 1.,
inTestDir("test.exr"), 1., RGBColorSpace::sRGB);
PerspectiveCamera *camera = new PerspectiveCamera(
Expand All @@ -380,7 +389,7 @@ std::vector<TestIntegrator> GetIntegrators() {
// MLT
{
FilterHandle filter = new BoxFilter(Vector2f(0.5, 0.5));
RGBFilm *film = new RGBFilm(resolution,
RGBFilm *film = new RGBFilm(Sensor::CreateDefault(), resolution,
Bounds2i(Point2i(0, 0), resolution), filter, 1.,
inTestDir("test.exr"), 1., RGBColorSpace::sRGB);
PerspectiveCamera *camera = new PerspectiveCamera(
Expand Down
Loading

0 comments on commit 0d7f1ff

Please sign in to comment.