This adds path guiding features into Cycles by integrating Intel's Open Path Guiding Library. It can be enabled in the Sampling > Path Guiding panel in the render properties. This feature helps reduce noise in scenes where finding a path to light is difficult for regular path tracing. The current implementation supports guiding directional sampling decisions on surfaces, when the material contains a least one diffuse component, and in volumes with isotropic and anisotropic Henyey-Greenstein phase functions. On surfaces, the guided sampling decision is proportional to the product of the incident radiance and the normal-oriented cosine lobe and in volumes it is proportional to the product of the incident radiance and the phase function. The incident radiance field of a scene is learned and updated during rendering after each per-frame rendering iteration/progression. At the moment, path guiding is only supported by the CPU backend. Support for GPU backends will be added in future versions of OpenPGL. Ref T92571 Differential Revision: https://developer.blender.org/D15286
92 lines
2.5 KiB
C++
92 lines
2.5 KiB
C++
/* SPDX-License-Identifier: Apache-2.0
|
|
* Copyright 2011-2022 Blender Foundation */
|
|
|
|
#pragma once
|
|
|
|
/* So ImathMath is included before our kernel_cpu_compat. */
|
|
#ifdef WITH_OSL
|
|
/* So no context pollution happens from indirectly included windows.h */
|
|
# include "util/windows.h"
|
|
# include <OSL/oslexec.h>
|
|
#endif
|
|
|
|
#ifdef WITH_EMBREE
|
|
# include <embree3/rtcore.h>
|
|
#endif
|
|
|
|
#include "device/cpu/kernel.h"
|
|
#include "device/device.h"
|
|
#include "device/memory.h"
|
|
|
|
// clang-format off
|
|
#include "kernel/device/cpu/compat.h"
|
|
#include "kernel/device/cpu/kernel.h"
|
|
#include "kernel/device/cpu/globals.h"
|
|
|
|
#include "kernel/osl/globals.h"
|
|
// clang-format on
|
|
|
|
#include "util/guiding.h"
|
|
#include "util/unique_ptr.h"
|
|
|
|
CCL_NAMESPACE_BEGIN
|
|
|
|
class CPUDevice : public Device {
|
|
public:
|
|
KernelGlobalsCPU kernel_globals;
|
|
|
|
device_vector<TextureInfo> texture_info;
|
|
bool need_texture_info;
|
|
|
|
#ifdef WITH_OSL
|
|
OSLGlobals osl_globals;
|
|
#endif
|
|
#ifdef WITH_EMBREE
|
|
RTCScene embree_scene = NULL;
|
|
RTCDevice embree_device;
|
|
#endif
|
|
#ifdef WITH_PATH_GUIDING
|
|
mutable unique_ptr<openpgl::cpp::Device> guiding_device;
|
|
#endif
|
|
|
|
CPUDevice(const DeviceInfo &info_, Stats &stats_, Profiler &profiler_);
|
|
~CPUDevice();
|
|
|
|
virtual BVHLayoutMask get_bvh_layout_mask() const override;
|
|
|
|
/* Returns true if the texture info was copied to the device (meaning, some more
|
|
* re-initialization might be needed). */
|
|
bool load_texture_info();
|
|
|
|
virtual void mem_alloc(device_memory &mem) override;
|
|
virtual void mem_copy_to(device_memory &mem) override;
|
|
virtual void mem_copy_from(
|
|
device_memory &mem, size_t y, size_t w, size_t h, size_t elem) override;
|
|
virtual void mem_zero(device_memory &mem) override;
|
|
virtual void mem_free(device_memory &mem) override;
|
|
virtual device_ptr mem_alloc_sub_ptr(device_memory &mem,
|
|
size_t offset,
|
|
size_t /*size*/) override;
|
|
|
|
virtual void const_copy_to(const char *name, void *host, size_t size) override;
|
|
|
|
void global_alloc(device_memory &mem);
|
|
void global_free(device_memory &mem);
|
|
|
|
void tex_alloc(device_texture &mem);
|
|
void tex_free(device_texture &mem);
|
|
|
|
void build_bvh(BVH *bvh, Progress &progress, bool refit) override;
|
|
|
|
void *get_guiding_device() const override;
|
|
|
|
virtual void get_cpu_kernel_thread_globals(
|
|
vector<CPUKernelThreadGlobals> &kernel_thread_globals) override;
|
|
virtual void *get_cpu_osl_memory() override;
|
|
|
|
protected:
|
|
virtual bool load_kernels(uint /*kernel_features*/) override;
|
|
};
|
|
|
|
CCL_NAMESPACE_END
|