本文整理汇总了C++中Sampler::GetMoreSamples方法的典型用法代码示例。如果您正苦于以下问题:C++ Sampler::GetMoreSamples方法的具体用法?C++ Sampler::GetMoreSamples怎么用?C++ Sampler::GetMoreSamples使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Sampler
的用法示例。
在下文中一共展示了Sampler::GetMoreSamples方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: Run
// RPFSamplerRendererTask Definitions
void RPFSamplerRendererTask::Run() {
PBRT_STARTED_RENDERTASK(taskNum);
// Get sub-_Sampler_ for _RPFSamplerRendererTask_
Sampler *sampler = mainSampler->GetSubSampler(taskNum, taskCount);
if (!sampler)
{
reporter.Update();
PBRT_FINISHED_RENDERTASK(taskNum);
return;
}
// Declare local variables used for rendering loop
MemoryArena arena;
RNG rng(taskNum);
// Allocate space for samples and intersections
int maxSamples = sampler->MaximumSampleCount();
Sample *samples = origSample->Duplicate(maxSamples);
RayDifferential *rays = new RayDifferential[maxSamples];
Spectrum *Ls = new Spectrum[maxSamples];
Spectrum *Ts = new Spectrum[maxSamples];
Intersection *isects = new Intersection[maxSamples];
// Get samples from _Sampler_ and update image
int sampleCount;
while ((sampleCount = sampler->GetMoreSamples(samples, rng)) > 0) {
// Generate camera rays and compute radiance along rays
for (int i = 0; i < sampleCount; ++i) {
// Find camera ray for _sample[i]_
PBRT_STARTED_GENERATING_CAMERA_RAY(&samples[i]);
float rayWeight = camera->GenerateRayDifferential(samples[i], &rays[i]);
rays[i].ScaleDifferentials(1.f / sqrtf(sampler->samplesPerPixel));
PBRT_FINISHED_GENERATING_CAMERA_RAY(&samples[i], &rays[i], rayWeight);
// Evaluate radiance along camera ray
PBRT_STARTED_CAMERA_RAY_INTEGRATION(&rays[i], &samples[i]);
if (visualizeObjectIds) {
if (rayWeight > 0.f && scene->Intersect(rays[i], &isects[i])) {
// random shading based on shape id...
/* This renderer can optionally ignore the surface and volume integrators
and randomly shade objects based on their shape and primitive id
values. This can be useful to visualize the tessellation of
complex objects and search for problems in geometric models.*/
uint32_t ids[2] = { isects[i].shapeId, isects[i].primitiveId };
uint32_t h = hash((char *)ids, sizeof(ids));
float rgb[3] = { (h & 0xff), (h >> 8) & 0xff, (h >> 16) & 0xff };
Ls[i] = Spectrum::FromRGB(rgb);
Ls[i] /= 255.f;
}
else
Ls[i] = 0.f;
}
else {
//Normal shading based on rendering equation
if (rayWeight > 0.f)
示例2: Run
void IrradiancePrimeTask::Run() {
if (!sampler) { progress.Update(); return; }
MemoryArena arena;
int sampleCount;
RNG rng(29 * taskNum);
int maxSamples = sampler->MaximumSampleCount();
Sample *samples = origSample->Duplicate(maxSamples);
while ((sampleCount = sampler->GetMoreSamples(samples, rng)) > 0) {
for (int i = 0; i < sampleCount; ++i) {
RayDifferential ray;
camera->GenerateRayDifferential(samples[i], &ray);
Intersection isect;
if (scene->Intersect(ray, &isect))
(void)irradianceCache->Li(scene, renderer, ray, isect, &samples[i], rng, arena);
}
arena.FreeAll();
}
delete[] samples;
delete sampler;
progress.Update();
}
示例3: Run
// SamplerRendererTask Definitions
void SamplerRendererTask::Run() {
PBRT_STARTED_RENDERTASK(taskNum);
// Get sub-_Sampler_ for _SamplerRendererTask_
Sampler *sampler = mainSampler->GetSubSampler(taskNum, taskCount);
if (!sampler)
{
reporter.Update();
PBRT_FINISHED_RENDERTASK(taskNum);
return;
}
// Declare local variables used for rendering loop
MemoryArena arena;
/*Full Random initialize SEED with Time (ToDo Metropolis)*/
/*old
* RNG rng(taskNum);
*/
int rseed;
if (PbrtOptions.fullRandom)
rseed = taskNum * time(NULL);
else
rseed = taskNum;
RNG rng(rseed);
// Allocate space for samples and intersections
int maxSamples = sampler->MaximumSampleCount();
Sample *samples = origSample->Duplicate(maxSamples);
RayDifferential *rays = new RayDifferential[maxSamples];
Spectrum *Ls = new Spectrum[maxSamples];
Spectrum *Ts = new Spectrum[maxSamples];
Intersection *isects = new Intersection[maxSamples];
// Get samples from _Sampler_ and update image
int sampleCount;
while ((sampleCount = sampler->GetMoreSamples(samples, rng)) > 0) {
// Generate camera rays and compute radiance along rays
for (int i = 0; i < sampleCount; ++i) {
// Find camera ray for _sample[i]_
PBRT_STARTED_GENERATING_CAMERA_RAY(&samples[i]);
float rayWeight = camera->GenerateRayDifferential(samples[i], &rays[i]);
rays[i].ScaleDifferentials(1.f / sqrtf(sampler->samplesPerPixel));
PBRT_FINISHED_GENERATING_CAMERA_RAY(&samples[i], &rays[i], rayWeight);
// Evaluate radiance along camera ray
PBRT_STARTED_CAMERA_RAY_INTEGRATION(&rays[i], &samples[i]);
if (visualizeObjectIds) {
if (rayWeight > 0.f && scene->Intersect(rays[i], &isects[i])) {
// random shading based on shape id...
uint32_t ids[2] = { isects[i].shapeId, isects[i].primitiveId };
uint32_t h = hash((char *)ids, sizeof(ids));
float rgb[3] = { (h & 0xff), (h >> 8) & 0xff, (h >> 16) & 0xff };
Ls[i] = Spectrum::FromRGB(rgb);
Ls[i] /= 255.f;
}
else
Ls[i] = 0.f;
}
else {
if (rayWeight > 0.f)
示例4: Run
// SamplerRendererTask Definitions
void SamplerRendererTask::Run() {
PBRT_STARTED_RENDERTASK(taskNum);
// Get sub-_Sampler_ for _SamplerRendererTask_
Sampler *sampler = mainSampler->GetSubSampler(taskNum, taskCount);
if (!sampler)
{
reporter.Update();
PBRT_FINISHED_RENDERTASK(taskNum);
return;
}
// Declare local variables used for rendering loop
MemoryArena arena;
RNG rng(taskNum);
// Allocate space for samples and intersections
int maxSamples = sampler->MaximumSampleCount();
Sample *samples = origSample->Duplicate(maxSamples);
RayDifferential *rays = new RayDifferential[maxSamples];
Spectrum *Ls = new Spectrum[maxSamples];
Spectrum *Ts = new Spectrum[maxSamples];
Intersection *isects = new Intersection[maxSamples];
// Get samples from \use{Sampler} and update image
int sampleCount;
while ((sampleCount = sampler->GetMoreSamples(samples, rng)) > 0) {
// Generate camera rays and compute radiance along rays
for (int i = 0; i < sampleCount; ++i) {
// Find camera ray for _sample[i]_
PBRT_STARTED_GENERATING_CAMERA_RAY(&samples[i]);
float rayWeight = camera->GenerateRayDifferential(samples[i], &rays[i]);
PBRT_FINISHED_GENERATING_CAMERA_RAY(&samples[i], &rays[i], rayWeight);
// Evaluate radiance along camera ray
PBRT_STARTED_CAMERA_RAY_INTEGRATION(&rays[i], &samples[i]);
if (rayWeight > 0.f)
Ls[i] = rayWeight * renderer->Li(scene, rays[i], &samples[i], rng,
arena, &isects[i], &Ts[i]);
else {
Ls[i] = 0.f;
Ts[i] = 1.f;
}
// Issue warning if unexpected radiance value returned
if (Ls[i].HasNaNs()) {
Error("Not-a-number radiance value returned "
"for image sample. Setting to black.");
Ls[i] = Spectrum(0.f);
}
else if (Ls[i].y() < -1e-5) {
Error("Negative luminance value, %f, returned"
"for image sample. Setting to black.", Ls[i].y());
Ls[i] = Spectrum(0.f);
}
else if (isinf(Ls[i].y())) {
Error("Infinite luminance value returned"
"for image sample. Setting to black.");
Ls[i] = Spectrum(0.f);
}
PBRT_FINISHED_CAMERA_RAY_INTEGRATION(&rays[i], &samples[i], &Ls[i]);
}
// Report sample results to _Sampler_, add contributions to image
if (sampler->ReportResults(samples, rays, Ls, isects, sampleCount))
{
for (int i = 0; i < sampleCount; ++i)
{
PBRT_STARTED_ADDING_IMAGE_SAMPLE(&samples[i], &rays[i], &Ls[i], &Ts[i]);
camera->film->AddSample(samples[i], Ls[i]);
PBRT_FINISHED_ADDING_IMAGE_SAMPLE();
}
}
// Free \use{MemoryArena} memory from computing image sample values
arena.FreeAll();
}
// Clean up after \use{SamplerRendererTask} is done with its image region
camera->film->UpdateDisplay(sampler->xPixelStart,
sampler->yPixelStart, sampler->xPixelEnd+1, sampler->yPixelEnd+1);
delete sampler;
delete[] samples;
delete[] rays;
delete[] Ls;
delete[] Ts;
delete[] isects;
reporter.Update();
PBRT_FINISHED_RENDERTASK(taskNum);
}