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/blender_viewport.cpp | |
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/blender_viewport.cpp')
-rw-r--r-- | intern/cycles/blender/blender_viewport.cpp | 36 |
1 files changed, 36 insertions, 0 deletions
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 |