From 208a5fd053f15e25b196462ebab12297b0d58a6e Mon Sep 17 00:00:00 2001 From: Matt Pharr Date: Wed, 12 May 2021 10:11:40 -0700 Subject: [PATCH] GPU/wavefront: compute dpdx/dpdy for VisibleSurface at first hit In turn, this gives us valid dzdx and dzdy values with GBuffer film. --- src/pbrt/wavefront/integrator.cpp | 4 ++-- src/pbrt/wavefront/integrator.h | 2 +- src/pbrt/wavefront/surfscatter.cpp | 2 ++ 3 files changed, 5 insertions(+), 3 deletions(-) diff --git a/src/pbrt/wavefront/integrator.cpp b/src/pbrt/wavefront/integrator.cpp index a03db9d..2787de6 100644 --- a/src/pbrt/wavefront/integrator.cpp +++ b/src/pbrt/wavefront/integrator.cpp @@ -83,6 +83,7 @@ WavefrontPathIntegrator::WavefrontPathIntegrator(Allocator alloc, ParsedScene &s sampler = Sampler::Create(scene.sampler.name, scene.sampler.parameters, film.FullResolution(), &scene.sampler.loc, alloc); + samplesPerPixel = sampler.SamplesPerPixel(); Medium cameraMedium = findMedium(scene.camera.medium, &scene.camera.loc); camera = Camera::Create(scene.camera.name, scene.camera.parameters, cameraMedium, @@ -347,7 +348,6 @@ Float WavefrontPathIntegrator::Render() { Timer timer; Vector2i resolution = film.PixelBounds().Diagonal(); Bounds2i pixelBounds = film.PixelBounds(); - int spp = sampler.SamplesPerPixel(); // Launch thread to copy image for display server, if enabled RGB *displayRGB = nullptr, *displayRGBHost = nullptr; std::atomic exitCopyThread{false}; @@ -429,7 +429,7 @@ Float WavefrontPathIntegrator::Render() { }); } - int firstSampleIndex = 0, lastSampleIndex = spp; + int firstSampleIndex = 0, lastSampleIndex = samplesPerPixel; // Update sample index range based on debug start, if provided if (!Options->debugStart.empty()) { std::vector values = SplitStringToInts(Options->debugStart, ','); diff --git a/src/pbrt/wavefront/integrator.h b/src/pbrt/wavefront/integrator.h index 403be0c..b71e960 100644 --- a/src/pbrt/wavefront/integrator.h +++ b/src/pbrt/wavefront/integrator.h @@ -148,7 +148,7 @@ class WavefrontPathIntegrator { pstd::vector *envLights; LightSampler lightSampler; - int maxDepth; + int maxDepth, samplesPerPixel; bool regularize; int scanlinesPerPass, maxQueueSize; diff --git a/src/pbrt/wavefront/surfscatter.cpp b/src/pbrt/wavefront/surfscatter.cpp index ce6caf9..1446d83 100644 --- a/src/pbrt/wavefront/surfscatter.cpp +++ b/src/pbrt/wavefront/surfscatter.cpp @@ -117,6 +117,8 @@ void WavefrontPathIntegrator::EvaluateMaterialAndBSDF(TextureEvaluator texEval, intr.wo = w.wo; intr.time = w.time; + camera.ApproximatedPdxy(intr, samplesPerPixel); + // Estimate BSDF's albedo constexpr int nRhoSamples = 16; SampledSpectrum rho(0.f); -- GitLab