提交 fc37e41b 编写于 作者: M Matt Pharr

Update from book source

上级 ca0db69d
......@@ -56,7 +56,7 @@ class SamplerHandle
PBRT_CPU_GPU inline Float Get1D();
PBRT_CPU_GPU inline Point2f Get2D();
std::vector<SamplerHandle> Clone(int n, Allocator alloc);
std::vector<SamplerHandle> Clone(int n, Allocator alloc = {});
std::string ToString() const;
};
......
......@@ -111,7 +111,6 @@ int main(int argc, char *argv[]) {
// Declare variables for parsed command line
PBRTOptions options;
std::vector<std::string> filenames;
std::string logLevel = "error";
std::string renderCoordSys = "cameraworld";
bool format = false, toPly = false;
......@@ -201,11 +200,12 @@ int main(int argc, char *argv[]) {
#endif // !NDEBUG
printf("Copyright (c)1998-2020 Matt Pharr, Wenzel Jakob, and Greg Humphreys.\n");
printf("The source code to pbrt (but *not* the book contents) is covered "
"by the BSD License.\n");
"by the Apache 2.0 License.\n");
printf("See the file LICENSE.txt for the conditions of the license.\n");
fflush(stdout);
}
// Check validity of provided arguments
if (renderCoordSys == "camera")
options.renderingSpace = RenderingCoordinateSystem::Camera;
else if (renderCoordSys == "cameraworld")
......@@ -223,6 +223,7 @@ int main(int argc, char *argv[]) {
options.logLevel = LogLevelFromString(logLevel);
// Initialize pbrt
InitPBRT(options);
if (format || toPly || options.upgrade) {
......@@ -240,9 +241,8 @@ int main(int argc, char *argv[]) {
CPURender(scene);
LOG_VERBOSE("Memory used after post-render cleanup: %s", GetCurrentRSS());
// Clean up after rendering scene
// Clean up after rendering the scene
CleanupPBRT();
}
return 0;
}
......@@ -142,20 +142,19 @@ void ImageTileIntegrator::Render() {
});
// Declare common variables for rendering image in tiles
Bounds2i pixelBounds = camera.GetFilm().PixelBounds();
int spp = samplerPrototype.SamplesPerPixel();
int startWave = 0, endWave = 1, waveDelta = 1;
std::vector<ScratchBuffer> scratchBuffers;
for (int i = 0; i < MaxThreadIndex(); ++i)
scratchBuffers.push_back(ScratchBuffer(65536));
std::vector<SamplerHandle> samplers =
samplerPrototype.Clone(MaxThreadIndex(), Allocator());
std::vector<SamplerHandle> samplers = samplerPrototype.Clone(MaxThreadIndex());
Bounds2i pixelBounds = camera.GetFilm().PixelBounds();
int spp = samplerPrototype.SamplesPerPixel();
ProgressReporter progress(int64_t(spp) * pixelBounds.Area(), "Rendering",
Options->quiet);
int startWave = 0, endWave = 1, waveDelta = 1;
if (Options->recordPixelStatistics)
StatsEnablePixelStats(pixelBounds,
RemoveExtension(camera.GetFilm().GetFilename()));
......@@ -206,6 +205,7 @@ void ImageTileIntegrator::Render() {
});
}
// Render image in waves
while (startWave < spp) {
// Render image tiles in parallel
ParallelFor2D(pixelBounds, [&](Bounds2i tileBounds) {
......@@ -256,6 +256,7 @@ void ImageTileIntegrator::Render() {
camera.InitMetadata(&metadata);
camera.GetFilm().WriteImage(metadata, 1.0f / startWave);
}
if (mseOutFile)
fclose(mseOutFile);
progress.Done();
......
......@@ -47,12 +47,12 @@ class Integrator {
const Bounds3f &SceneBounds() const { return sceneBounds; }
virtual void Render() = 0;
pstd::optional<ShapeIntersection> Intersect(const Ray &ray,
Float tMax = Infinity) const;
bool IntersectP(const Ray &ray, Float tMax = Infinity) const;
virtual void Render() = 0;
bool Unoccluded(const Interaction &p0, const Interaction &p1) const {
return !IntersectP(p0.SpawnRayTo(p1), 1 - ShadowEpsilon);
}
......@@ -62,12 +62,13 @@ class Integrator {
// Integrator Public Members
std::vector<LightHandle> lights;
PrimitiveHandle aggregate;
std::vector<LightHandle> infiniteLights;
protected:
// Integrator Private Methods
Integrator(PrimitiveHandle aggregate, std::vector<LightHandle> l)
: lights(std::move(l)), aggregate(aggregate) {
Integrator(PrimitiveHandle aggregate, std::vector<LightHandle> lights)
: lights(lights), aggregate(aggregate) {
// Integrator Constructor Implementation
if (aggregate)
sceneBounds = aggregate.Bounds();
......@@ -80,7 +81,6 @@ class Integrator {
}
// Integrator Private Members
PrimitiveHandle aggregate;
Bounds3f sceneBounds;
};
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册