diff options
author | Jeroen Bakker <j.bakker@atmind.nl> | 2019-09-05 13:47:20 +0300 |
---|---|---|
committer | Jeroen Bakker <j.bakker@atmind.nl> | 2019-09-11 13:19:44 +0300 |
commit | 7e61e597253f3ca75f2fb86a57212ca750ffbbe8 (patch) | |
tree | 6dbe0bf05fc3380f9729bf719ed1223997d5b0e3 /intern/cycles/blender | |
parent | d4f8bc80a4bd69707a92e7141a2fb67d3f668c58 (diff) |
Cycles: Display RenderPass in Viewport
This change allows the user to select a renderpass in the 3d viewport.
Added support for external renderers to extend the `View3DShading` struct.
This way Blender doesn't need to know the features an external render engine wants to support.
Note that the View3DShading is also available in the scene->display.shading; although this is
supported, it does not make sense for render engines to put something here as it is really
scene/workbench related.
Currently cycles assumes that it always needs to calculate the combined pass; it ignores the
`pass_flag` in KernelFilm. We could optimize this but that was not in scope of this change
Reviewed By: brecht
Differential Revision: https://developer.blender.org/D5689
Diffstat (limited to 'intern/cycles/blender')
-rw-r--r-- | intern/cycles/blender/addon/properties.py | 54 | ||||
-rw-r--r-- | intern/cycles/blender/addon/ui.py | 20 | ||||
-rw-r--r-- | intern/cycles/blender/blender_camera.cpp | 2 | ||||
-rw-r--r-- | intern/cycles/blender/blender_sync.cpp | 12 | ||||
-rw-r--r-- | intern/cycles/blender/blender_sync.h | 2 | ||||
-rw-r--r-- | intern/cycles/blender/blender_viewport.cpp | 36 | ||||
-rw-r--r-- | intern/cycles/blender/blender_viewport.h | 10 |
7 files changed, 132 insertions, 4 deletions
diff --git a/intern/cycles/blender/addon/properties.py b/intern/cycles/blender/addon/properties.py index 3acdfc391a6..93f8f76cd6a 100644 --- a/intern/cycles/blender/addon/properties.py +++ b/intern/cycles/blender/addon/properties.py @@ -151,6 +151,44 @@ enum_texture_limit = ( ('8192', "8192", "Limit texture size to 8192 pixels", 7), ) +enum_view3d_shading_render_pass= ( + ('', "General", ""), + + ('COMBINED', "Combined", "Show the Combined Render pass", 1), + ('EMISSION', "Emission", "Show the Emission render pass", 33), + ('BACKGROUND', "Background", "Show the Background render pass", 34), + ('AO', "Ambient Occlusion", "Show the Ambient Occlusion render pass", 35), + + ('', "Light", ""), + + ('DIFFUSE_DIRECT', "Diffuse Direct", "Show the Diffuse Direct render pass", 38), + ('DIFFUSE_INDIRECT', "Diffuse Indirect", "Show the Diffuse Indirect render pass", 39), + ('DIFFUSE_COLOR', "Diffuse Color", "Show the Diffuse Color render pass", 40), + + ('GLOSSY_DIRECT', "Glossy Direct", "Show the Glossy Direct render pass", 41), + ('GLOSSY_INDIRECT', "Glossy Indirect", "Show the Glossy Indirect render pass", 42), + ('GLOSSY_COLOR', "Glossy Color", "Show the Glossy Color render pass", 43), + + ('', "", ""), + + ('TRANSMISSION_DIRECT', "Transmission Direct", "Show the Transmission Direct render pass", 44), + ('TRANSMISSION_INDIRECT', "Transmission Indirect", "Show the Transmission Indirect render pass", 45), + ('TRANSMISSION_COLOR', "Transmission Color", "Show the Transmission Color render pass", 46), + + ('SUBSURFACE_DIRECT', "Subsurface Direct", "Show the Subsurface Direct render pass", 47), + ('SUBSURFACE_INDIRECT', "Subsurface Indirect", "Show the Subsurface Indirect render pass", 48), + ('SUBSURFACE_COLOR', "Subsurface Color", "Show the Subsurface Color render pass", 49), + + ('VOLUME_DIRECT', "Volume Direct", "Show the Volume Direct render pass", 50), + ('VOLUME_INDIRECT', "Volume Indirect", "Show the Volume Indirect render pass", 51), + + ('', "Data", ""), + + ('NORMAL', "Normal", "Show the Normal render pass", 3), + ('UV', "UV", "Show the UV render pass", 4), + ('MIST', "Mist", "Show the Mist render pass", 32), +) + class CyclesRenderSettings(bpy.types.PropertyGroup): @@ -1475,6 +1513,15 @@ class CyclesPreferences(bpy.types.AddonPreferences): self.draw_impl(self.layout, context) +class CyclesView3DShadingSettings(bpy.types.PropertyGroup): + render_pass: EnumProperty( + name="Render Pass", + description="Render pass to show in the 3D Viewport", + items=enum_view3d_shading_render_pass, + default='COMBINED', + ) + + def register(): bpy.utils.register_class(CyclesRenderSettings) bpy.utils.register_class(CyclesCameraSettings) @@ -1488,6 +1535,12 @@ def register(): bpy.utils.register_class(CyclesDeviceSettings) bpy.utils.register_class(CyclesPreferences) bpy.utils.register_class(CyclesRenderLayerSettings) + bpy.utils.register_class(CyclesView3DShadingSettings) + + bpy.types.View3DShading.cycles = bpy.props.PointerProperty( + name="Cycles Settings", + type=CyclesView3DShadingSettings, + ) def unregister(): @@ -1503,3 +1556,4 @@ def unregister(): bpy.utils.unregister_class(CyclesDeviceSettings) bpy.utils.unregister_class(CyclesPreferences) bpy.utils.unregister_class(CyclesRenderLayerSettings) + bpy.utils.unregister_class(CyclesView3DShadingSettings) diff --git a/intern/cycles/blender/addon/ui.py b/intern/cycles/blender/addon/ui.py index 0af59411c5c..9028100ad7a 100644 --- a/intern/cycles/blender/addon/ui.py +++ b/intern/cycles/blender/addon/ui.py @@ -2050,6 +2050,25 @@ class CYCLES_RENDER_PT_simplify_culling(CyclesButtonsPanel, Panel): sub.prop(cscene, "distance_cull_margin", text="Distance") +class CYCLES_VIEW3D_PT_shading_render_pass(Panel): + bl_space_type = 'VIEW_3D' + bl_region_type = 'HEADER' + bl_label = "Render Pass" + bl_parent_id = 'VIEW3D_PT_shading' + COMPAT_ENGINES = {'CYCLES'} + + @classmethod + def poll(cls, context): + return (context.engine in cls.COMPAT_ENGINES + and context.space_data.shading.type == 'RENDERED') + + def draw(self, context): + shading = context.space_data.shading + + layout = self.layout + layout.prop(shading.cycles, "render_pass", text="") + + class CYCLES_VIEW3D_PT_shading_lighting(Panel): bl_space_type = 'VIEW_3D' bl_region_type = 'HEADER' @@ -2172,6 +2191,7 @@ classes = ( CYCLES_RENDER_PT_simplify_render, CYCLES_RENDER_PT_simplify_culling, CYCLES_VIEW3D_PT_shading_lighting, + CYCLES_VIEW3D_PT_shading_render_pass, CYCLES_RENDER_PT_motion_blur, CYCLES_RENDER_PT_motion_blur_curve, CYCLES_RENDER_PT_film, diff --git a/intern/cycles/blender/blender_camera.cpp b/intern/cycles/blender/blender_camera.cpp index da43f94708c..3b19e78894a 100644 --- a/intern/cycles/blender/blender_camera.cpp +++ b/intern/cycles/blender/blender_camera.cpp @@ -899,6 +899,8 @@ BufferParams BlenderSync::get_buffer_params(BL::RenderSettings &b_render, params.height = height; } + update_viewport_display_passes(b_v3d, params.passes, false); + return params; } diff --git a/intern/cycles/blender/blender_sync.cpp b/intern/cycles/blender/blender_sync.cpp index e50d96cf345..8b7c66363d9 100644 --- a/intern/cycles/blender/blender_sync.cpp +++ b/intern/cycles/blender/blender_sync.cpp @@ -206,7 +206,7 @@ void BlenderSync::sync_data(BL::RenderSettings &b_render, sync_view_layer(b_v3d, b_view_layer); sync_integrator(); - sync_film(); + sync_film(b_v3d); sync_shaders(b_depsgraph, b_v3d); sync_images(); sync_curve_settings(); @@ -336,13 +336,17 @@ void BlenderSync::sync_integrator() /* Film */ -void BlenderSync::sync_film() +void BlenderSync::sync_film(BL::SpaceView3D &b_v3d) { PointerRNA cscene = RNA_pointer_get(&b_scene.ptr, "cycles"); Film *film = scene->film; Film prevfilm = *film; + if (b_v3d) { + film->display_pass = update_viewport_display_passes(b_v3d, film->passes, true); + } + film->exposure = get_float(cscene, "film_exposure"); film->filter_type = (FilterType)get_enum( cscene, "pixel_filter_type", FILTER_NUM_TYPES, FILTER_BLACKMAN_HARRIS); @@ -368,8 +372,10 @@ void BlenderSync::sync_film() } } - if (film->modified(prevfilm)) + if (film->modified(prevfilm)) { film->tag_update(scene); + film->tag_passes_update(scene, prevfilm.passes, false); + } } /* Render Layer */ diff --git a/intern/cycles/blender/blender_sync.h b/intern/cycles/blender/blender_sync.h index c6c7b7549cf..a80f484fb92 100644 --- a/intern/cycles/blender/blender_sync.h +++ b/intern/cycles/blender/blender_sync.h @@ -116,7 +116,7 @@ class BlenderSync { int width, int height, void **python_thread_state); - void sync_film(); + void sync_film(BL::SpaceView3D &b_v3d); void sync_view(); void sync_world(BL::Depsgraph &b_depsgraph, BL::SpaceView3D &b_v3d, bool update_all); void sync_shaders(BL::Depsgraph &b_depsgraph, BL::SpaceView3D &b_v3d); diff --git a/intern/cycles/blender/blender_viewport.cpp b/intern/cycles/blender/blender_viewport.cpp index 93dd8faa450..a74b20f150b 100644 --- a/intern/cycles/blender/blender_viewport.cpp +++ b/intern/cycles/blender/blender_viewport.cpp @@ -15,6 +15,8 @@ */ #include "blender_viewport.h" +#include "blender_util.h" + CCL_NAMESPACE_BEGIN BlenderViewportParameters::BlenderViewportParameters() @@ -59,4 +61,38 @@ const bool BlenderViewportParameters::custom_viewport_parameters() const return !(use_scene_world && use_scene_lights); } +PassType BlenderViewportParameters::get_viewport_display_render_pass(BL::SpaceView3D &b_v3d) +{ + PassType display_pass = PASS_NONE; + if (b_v3d) { + BL::View3DShading b_view3dshading = b_v3d.shading(); + PointerRNA cshading = RNA_pointer_get(&b_view3dshading.ptr, "cycles"); + display_pass = (PassType)get_enum(cshading, "render_pass", -1, -1); + } + return display_pass; +} + +PassType update_viewport_display_passes(BL::SpaceView3D &b_v3d, + vector<Pass> &passes, + bool reset_passes) +{ + if (b_v3d) { + PassType display_pass = BlenderViewportParameters::get_viewport_display_render_pass(b_v3d); + + if (reset_passes) { + passes.clear(); + /* We always need a combined pass for now. It would be a good optimization + * to support rendering without combined pass. */ + Pass::add(PASS_COMBINED, passes); + } + + if (display_pass != PASS_COMBINED) { + Pass::add(display_pass, passes); + } + + return display_pass; + } + return PASS_NONE; +} + CCL_NAMESPACE_END diff --git a/intern/cycles/blender/blender_viewport.h b/intern/cycles/blender/blender_viewport.h index 6b2f8ea4215..564c4f2b210 100644 --- a/intern/cycles/blender/blender_viewport.h +++ b/intern/cycles/blender/blender_viewport.h @@ -22,6 +22,7 @@ #include "RNA_access.h" #include "RNA_blender_cpp.h" +#include "render/film.h" #include "util/util_param.h" CCL_NAMESPACE_BEGIN @@ -41,8 +42,17 @@ class BlenderViewportParameters { const bool modified(const BlenderViewportParameters &other) const; const bool custom_viewport_parameters() const; friend class BlenderSync; + + public: + /* Retrieve the render pass that needs to be displayed on the given `SpaceView3D` + * When the `b_v3d` parameter is not given `PASS_NONE` will be returned. */ + static PassType get_viewport_display_render_pass(BL::SpaceView3D &b_v3d); }; +PassType update_viewport_display_passes(BL::SpaceView3D &b_v3d, + vector<Pass> &passes, + bool reset_passes); + CCL_NAMESPACE_END #endif |