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/render/film.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/render/film.cpp')
-rw-r--r-- | intern/cycles/render/film.cpp | 44 |
1 files changed, 39 insertions, 5 deletions
diff --git a/intern/cycles/render/film.cpp b/intern/cycles/render/film.cpp index d6c44b66117..5bf7ba97515 100644 --- a/intern/cycles/render/film.cpp +++ b/intern/cycles/render/film.cpp @@ -267,7 +267,7 @@ NODE_DEFINE(Film) NodeType *type = NodeType::add("film", create); SOCKET_FLOAT(exposure, "Exposure", 0.8f); - SOCKET_FLOAT(pass_alpha_threshold, "Pass Alpha Threshold", 0.5f); + SOCKET_FLOAT(pass_alpha_threshold, "Pass Alpha Threshold", 0.0f); static NodeEnum filter_enum; filter_enum.insert("box", FILTER_BOX); @@ -318,6 +318,13 @@ void Film::device_update(Device *device, DeviceScene *dscene, Scene *scene) /* update __data */ kfilm->exposure = exposure; kfilm->pass_flag = 0; + + kfilm->display_pass_stride = -1; + kfilm->display_pass_components = 0; + kfilm->display_divide_pass_stride = -1; + kfilm->use_display_exposure = false; + kfilm->use_display_pass_alpha = (display_pass == PASS_COMBINED); + kfilm->light_pass_flag = 0; kfilm->pass_stride = 0; kfilm->use_light_pass = use_light_visibility || use_sample_clamp; @@ -464,6 +471,16 @@ void Film::device_update(Device *device, DeviceScene *dscene, Scene *scene) break; } + if (pass.type == display_pass) { + kfilm->display_pass_stride = kfilm->pass_stride; + kfilm->display_pass_components = pass.components; + kfilm->use_display_exposure = pass.exposure && (kfilm->exposure != 1.0f); + } + else if (pass.type == PASS_DIFFUSE_COLOR || pass.type == PASS_TRANSMISSION_COLOR || + pass.type == PASS_GLOSSY_COLOR || pass.type == PASS_SUBSURFACE_COLOR) { + kfilm->display_divide_pass_stride = kfilm->pass_stride; + } + kfilm->pass_stride += pass.components; } @@ -485,7 +502,18 @@ void Film::device_update(Device *device, DeviceScene *dscene, Scene *scene) } kfilm->pass_stride = align_up(kfilm->pass_stride, 4); - kfilm->pass_alpha_threshold = pass_alpha_threshold; + + /* When displaying the normal/uv pass in the viewport we need to disable + * transparency. + * + * We also don't need to perform light accumulations. Later we want to optimize this to suppress + * light calculations. */ + if (display_pass == PASS_NORMAL || display_pass == PASS_UV) { + kfilm->use_light_pass = 0; + } + else { + kfilm->pass_alpha_threshold = pass_alpha_threshold; + } /* update filter table */ vector<float> table = filter_table(filter_type, filter_width); @@ -518,7 +546,7 @@ bool Film::modified(const Film &film) return !Node::equals(film) || !Pass::equals(passes, film.passes); } -void Film::tag_passes_update(Scene *scene, const vector<Pass> &passes_) +void Film::tag_passes_update(Scene *scene, const vector<Pass> &passes_, bool update_passes) { if (Pass::contains(passes, PASS_UV) != Pass::contains(passes_, PASS_UV)) { scene->mesh_manager->tag_update(scene); @@ -526,10 +554,16 @@ void Film::tag_passes_update(Scene *scene, const vector<Pass> &passes_) foreach (Shader *shader, scene->shaders) shader->need_update_mesh = true; } - else if (Pass::contains(passes, PASS_MOTION) != Pass::contains(passes_, PASS_MOTION)) + else if (Pass::contains(passes, PASS_MOTION) != Pass::contains(passes_, PASS_MOTION)) { scene->mesh_manager->tag_update(scene); + } + else if (Pass::contains(passes, PASS_AO) != Pass::contains(passes_, PASS_AO)) { + scene->integrator->tag_update(scene); + } - passes = passes_; + if (update_passes) { + passes = passes_; + } } void Film::tag_update(Scene * /*scene*/) |