Commit: 75a6d3abf75f3082adf5240ae34973844c0d9a09 Author: Sebastian Herhoz Date: Wed Sep 21 17:58:34 2022 +0200 Branches: master https://developer.blender.org/rB75a6d3abf75f3082adf5240ae34973844c0d9a09
Cycles: add Path Guiding on CPU through Intel OpenPGL 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 =================================================================== M CMakeLists.txt M build_files/cmake/config/blender_full.cmake M build_files/cmake/config/blender_release.cmake M intern/cycles/CMakeLists.txt M intern/cycles/blender/addon/engine.py M intern/cycles/blender/addon/properties.py M intern/cycles/blender/addon/ui.py M intern/cycles/blender/python.cpp M intern/cycles/blender/sync.cpp M intern/cycles/cmake/external_libs.cmake M intern/cycles/cmake/macros.cmake M intern/cycles/device/cpu/device.cpp M intern/cycles/device/cpu/device_impl.cpp M intern/cycles/device/cpu/device_impl.h M intern/cycles/device/cpu/kernel_thread_globals.cpp M intern/cycles/device/cpu/kernel_thread_globals.h M intern/cycles/device/device.cpp M intern/cycles/device/device.h M intern/cycles/integrator/CMakeLists.txt A intern/cycles/integrator/guiding.h M intern/cycles/integrator/path_trace.cpp M intern/cycles/integrator/path_trace.h M intern/cycles/integrator/path_trace_work.h M intern/cycles/integrator/path_trace_work_cpu.cpp M intern/cycles/integrator/path_trace_work_cpu.h M intern/cycles/integrator/render_scheduler.cpp M intern/cycles/integrator/render_scheduler.h M intern/cycles/kernel/CMakeLists.txt M intern/cycles/kernel/data_template.h M intern/cycles/kernel/device/cpu/globals.h A intern/cycles/kernel/integrator/guiding.h M intern/cycles/kernel/integrator/intersect_closest.h M intern/cycles/kernel/integrator/mnee.h M intern/cycles/kernel/integrator/path_state.h M intern/cycles/kernel/integrator/shade_background.h M intern/cycles/kernel/integrator/shade_light.h M intern/cycles/kernel/integrator/shade_shadow.h M intern/cycles/kernel/integrator/shade_surface.h M intern/cycles/kernel/integrator/shade_volume.h M intern/cycles/kernel/integrator/shadow_state_template.h M intern/cycles/kernel/integrator/state.h M intern/cycles/kernel/integrator/state_template.h M intern/cycles/kernel/integrator/subsurface.h M intern/cycles/kernel/integrator/subsurface_disk.h M intern/cycles/kernel/integrator/subsurface_random_walk.h M intern/cycles/kernel/integrator/surface_shader.h M intern/cycles/kernel/integrator/volume_shader.h M intern/cycles/kernel/types.h M intern/cycles/scene/film.cpp M intern/cycles/scene/integrator.cpp M intern/cycles/scene/integrator.h M intern/cycles/scene/pass.cpp M intern/cycles/scene/scene.cpp M intern/cycles/scene/scene.h M intern/cycles/session/session.cpp M intern/cycles/util/CMakeLists.txt A intern/cycles/util/guiding.h M tests/python/CMakeLists.txt M tests/python/cycles_render_tests.py =================================================================== diff --git a/CMakeLists.txt b/CMakeLists.txt index ef3309ded48..d8adf6c396f 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -429,6 +429,7 @@ mark_as_advanced(WITH_CPU_SIMD) # Cycles option(WITH_CYCLES "Enable Cycles Render Engine" ON) option(WITH_CYCLES_OSL "Build Cycles with OpenShadingLanguage support" ON) +option(WITH_CYCLES_PATH_GUIDING "Build Cycles with path guiding support" ON) option(WITH_CYCLES_EMBREE "Build Cycles with Embree support" ON) option(WITH_CYCLES_LOGGING "Build Cycles with logging support" ON) option(WITH_CYCLES_DEBUG "Build Cycles with options useful for debugging (e.g., MIS)" OFF) diff --git a/build_files/cmake/config/blender_full.cmake b/build_files/cmake/config/blender_full.cmake index 27577a9fbf7..958eb17522b 100644 --- a/build_files/cmake/config/blender_full.cmake +++ b/build_files/cmake/config/blender_full.cmake @@ -17,6 +17,7 @@ set(WITH_COMPOSITOR_CPU ON CACHE BOOL "" FORCE) set(WITH_CYCLES ON CACHE BOOL "" FORCE) set(WITH_CYCLES_EMBREE ON CACHE BOOL "" FORCE) set(WITH_CYCLES_OSL ON CACHE BOOL "" FORCE) +set(WITH_CYCLES_PATH_GUIDING ON CACHE BOOL "" FORCE) set(WITH_DRACO ON CACHE BOOL "" FORCE) set(WITH_FFTW3 ON CACHE BOOL "" FORCE) set(WITH_FREESTYLE ON CACHE BOOL "" FORCE) diff --git a/build_files/cmake/config/blender_release.cmake b/build_files/cmake/config/blender_release.cmake index 793d1cb0853..d5f5230862b 100644 --- a/build_files/cmake/config/blender_release.cmake +++ b/build_files/cmake/config/blender_release.cmake @@ -18,6 +18,7 @@ set(WITH_COMPOSITOR_CPU ON CACHE BOOL "" FORCE) set(WITH_CYCLES ON CACHE BOOL "" FORCE) set(WITH_CYCLES_EMBREE ON CACHE BOOL "" FORCE) set(WITH_CYCLES_OSL ON CACHE BOOL "" FORCE) +set(WITH_CYCLES_PATH_GUIDING ON CACHE BOOL "" FORCE) set(WITH_DRACO ON CACHE BOOL "" FORCE) set(WITH_FFTW3 ON CACHE BOOL "" FORCE) set(WITH_FREESTYLE ON CACHE BOOL "" FORCE) diff --git a/intern/cycles/CMakeLists.txt b/intern/cycles/CMakeLists.txt index 8adb032ad9e..f619e6b104e 100644 --- a/intern/cycles/CMakeLists.txt +++ b/intern/cycles/CMakeLists.txt @@ -347,6 +347,24 @@ if(WITH_OPENCOLORIO) ) endif() +if(WITH_CYCLES_PATH_GUIDING) + add_definitions(-DWITH_PATH_GUIDING) + + # The level of the guiding integration. + # Different levels can be selected to measure the overhead of different stages. + # 1 = recording the path segments + # 2 = 1 + generating (not storing) sample data from the segments + # 3 = 2 + storing the generates sample data + # 4 = 3 + training the guiding fields + # 5 = 4 + querying the trained guiding for sampling (full path guiding) + add_definitions(-DPATH_GUIDING_LEVEL=5) + + include_directories( + SYSTEM + ${OPENPGL_INCLUDE_DIR} + ) +endif() + # NaN debugging if(WITH_CYCLES_DEBUG_NAN) add_definitions(-DWITH_CYCLES_DEBUG_NAN) diff --git a/intern/cycles/blender/addon/engine.py b/intern/cycles/blender/addon/engine.py index 1a99674d239..794338fe78e 100644 --- a/intern/cycles/blender/addon/engine.py +++ b/intern/cycles/blender/addon/engine.py @@ -156,6 +156,11 @@ def with_osl(): return _cycles.with_osl +def with_path_guiding(): + import _cycles + return _cycles.with_path_guiding + + def system_info(): import _cycles return _cycles.system_info() diff --git a/intern/cycles/blender/addon/properties.py b/intern/cycles/blender/addon/properties.py index cd263e5b9c4..b5ac39d09e6 100644 --- a/intern/cycles/blender/addon/properties.py +++ b/intern/cycles/blender/addon/properties.py @@ -179,6 +179,12 @@ enum_view3d_shading_render_pass = ( ('SAMPLE_COUNT', "Sample Count", "Per-pixel number of samples"), ) +enum_guiding_distribution = ( + ('PARALLAX_AWARE_VMM', "Parallax-Aware VMM", "Use Parallax-aware von Mises-Fisher models as directional distribution", 0), + ('DIRECTIONAL_QUAD_TREE', "Directional Quad Tree", "Use Directional Quad Trees as directional distribution", 1), + ('VMM', "VMM", "Use von Mises-Fisher models as directional distribution", 2), +) + def enum_openimagedenoise_denoiser(self, context): import _cycles @@ -358,7 +364,9 @@ class CyclesRenderSettings(bpy.types.PropertyGroup): preview_samples: IntProperty( name="Viewport Samples", description="Number of samples to render in the viewport, unlimited if 0", - min=0, max=(1 << 24), + min=0, + soft_min=1, + max=(1 << 24), default=1024, ) @@ -507,6 +515,78 @@ class CyclesRenderSettings(bpy.types.PropertyGroup): default=1.0, ) + use_guiding: BoolProperty( + name="Guiding", + description="Use path guiding for sampling paths. Path guiding incrementally " + "learns the light distribution of the scene and guides path into directions " + "with high direct and indirect light contributions", + default=False, + ) + + use_deterministic_guiding: BoolProperty( + name="Deterministic", + description="Makes path guiding deterministic which means renderings will be" + "reproducible with the same pixel values every time. This feature slows down" + "training", + default=True, + ) + + guiding_distribution_type: EnumProperty( + name="Guiding Distribution Type", + description="Type of representation for the guiding distribution", + items=enum_guiding_distribution, + default='PARALLAX_AWARE_VMM', + ) + + use_surface_guiding: BoolProperty( + name="Surface Guiding", + description="Use guiding when sampling directions on a surface", + default=True, + ) + + surface_guiding_probability: FloatProperty( + name="Surface Guiding Probability", + description="The probability of guiding a direction on a surface", + min=0.0, max=1.0, + default=0.5, + ) + + use_volume_guiding: BoolProperty( + name="Volume Guiding", + description="Use guiding when sampling directions inside a volume", + default=True, + ) + + guiding_training_samples: IntProperty( + name="Training Samples", + description="The maximum number of samples used for training path guiding. " + "Higher samples lead to more accurate guiding, however may also unnecessarily slow " + "down rendering once guiding is accurate enough. " + "A value 0 will continue training until the last sample", + min=0, + soft_min=1, + default=128, + ) + + volume_guiding_probability: FloatProperty( + name="Volume Guiding Probability", + description="The probability of guiding a direction inside a volume", + min=0.0, max=1.0, + default=0.5, + ) + + use_guiding_direct_light: BoolProperty( + name="Guide Direct Light", + description="Consider the contribution of directly visible light sources during guiding", + default=True, + ) + + use_guiding_mis_weights: BoolProperty( + name="Use MIS Weights", + description="Use the MIS weight to weight the contribution of directly visible light sources during guiding", + default=True, + ) + max_bounces: IntProperty( name="Max Bounces", description="Total maximum number of bounces", diff --git a/intern/cycles/blender/addon/ui.py b/intern/cycles/blender/addon/ui.py index ee284dd899a..7036e58f6fb 100644 --- a/intern/cycles/blender/addon/ui.py +++ b/intern/cycles/blender/addon/ui.py @@ -278,6 +278,63 @@ class CYCLES_RENDER_PT_sampling_render_denoise(CyclesButtonsPanel, Panel): col.prop(cscene, "denoising_prefilter", text="Prefilter") +class CYCLES_RENDER_PT_sampling_path_guiding(CyclesButtonsPanel, Panel): + bl_label = "Path Guiding" + bl_parent_id = "CYCLES_RENDER_PT_sampling" + bl_options = {'DEFAULT_CLOSED'} + + @classmethod + def poll(cls, context): + from . import engine + return use_cpu(context) and engine.with_path_guiding() + + def draw_header(self, context): + scene = context.scene + cscene = scene.cycles + + self.layout.prop(cscene, "use_guiding", text="") + + def draw(self, context): + scene = context.scene + cscene = scene.cycles + + layout = self.layout + layout.use_property_split = True + layout.use_property_decorate = False + layout.active = cscene.use_guiding + + col = layout.column(align=True) + col.prop(cscene, "use_surface_guiding") + col.prop(cscene, "use_volume_guiding") + col.prop(cscene, "guiding_training_samples") + + +class CYCLES_RENDER_PT_sampling_path_guiding_debug(CyclesDebugButtonsPanel, Panel): + bl_label = "Debug" + bl_parent_id = "CYCLES_RENDER_PT_sampling_path_guiding" + bl_options = {'DEFAULT_CLOSED'} + + def draw(self, context): + scene = context.scene + cscene = scene.cycles + + layout = self.layout + layout.use_property_split = True + layout.use_property_decorate = False + layout.active = cscene.use_guiding + + layout.prop(cscene, "guiding_distribution_type", text="Distribution Type") + + col = layout.column(align=True) + col.prop(cscene, "surface_guiding_probability") + col.prop(cscene, "volume_guiding_probability") + + col = layout.column(align=True) + col.prop(cscene, "use_deterministic_guiding") + col.prop(cscene, "use_guiding_direct_light") + col.prop(cscene, "use_guiding_mis_weights") + + class CYCLES_RENDER_PT_sampling_advanced(CyclesButtonsPanel, Panel): bl_label = "Advanced" bl_parent_id = "CYCLES_RENDER_PT_sampling" @@ -2286,6 +2343,8 @@ classes = ( CYCLES_RENDER_PT_sampling_viewport_denoise, CYCLES_RENDER_PT_sampling_render, CYCLES_RENDER_PT_sampling_render_denoise, + CYCLES_RENDER_PT_sampling_path_guiding, + CYCLES_RENDER_PT_sampling_path_guiding_debug, CYCLES_RENDER_PT_sampling_advanced, CYCLES_RENDER_PT_light_paths, CYCLES_RENDER_PT_light_paths_max_bounces, diff --git a/intern/cycles/blende @@ Diff output truncated at 10240 characters. @@ _______________________________________________ Bf-blender-cvs mailing list [email protected] List details, subscription details or unsubscribe: https://lists.blender.org/mailman/listinfo/bf-blender-cvs
