2011-04-27 11:58:34 +00:00
|
|
|
/*
|
2013-08-18 14:16:15 +00:00
|
|
|
* Copyright 2011-2013 Blender Foundation
|
2011-04-27 11:58:34 +00:00
|
|
|
*
|
2013-08-18 14:16:15 +00:00
|
|
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
|
|
* you may not use this file except in compliance with the License.
|
|
|
|
* You may obtain a copy of the License at
|
2011-04-27 11:58:34 +00:00
|
|
|
*
|
2013-08-18 14:16:15 +00:00
|
|
|
* http://www.apache.org/licenses/LICENSE-2.0
|
2011-04-27 11:58:34 +00:00
|
|
|
*
|
2013-08-18 14:16:15 +00:00
|
|
|
* Unless required by applicable law or agreed to in writing, software
|
|
|
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
|
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
|
|
* See the License for the specific language governing permissions and
|
2014-12-25 02:50:24 +01:00
|
|
|
* limitations under the License.
|
2011-04-27 11:58:34 +00:00
|
|
|
*/
|
|
|
|
|
Cycles: Make all #include statements relative to cycles source directory
The idea is to make include statements more explicit and obvious where the
file is coming from, additionally reducing chance of wrong header being
picked up.
For example, it was not obvious whether bvh.h was refferring to builder
or traversal, whenter node.h is a generic graph node or a shader node
and cases like that.
Surely this might look obvious for the active developers, but after some
time of not touching the code it becomes less obvious where file is coming
from.
This was briefly mentioned in T50824 and seems @brecht is fine with such
explicitness, but need to agree with all active developers before committing
this.
Please note that this patch is lacking changes related on GPU/OpenCL
support. This will be solved if/when we all agree this is a good idea to move
forward.
Reviewers: brecht, lukasstockner97, maiself, nirved, dingto, juicyfruit, swerner
Reviewed By: lukasstockner97, maiself, nirved, dingto
Subscribers: brecht
Differential Revision: https://developer.blender.org/D2586
2017-03-28 20:39:14 +02:00
|
|
|
#include "render/background.h"
|
|
|
|
#include "render/camera.h"
|
|
|
|
#include "render/film.h"
|
|
|
|
#include "render/graph.h"
|
|
|
|
#include "render/integrator.h"
|
|
|
|
#include "render/light.h"
|
|
|
|
#include "render/mesh.h"
|
|
|
|
#include "render/nodes.h"
|
|
|
|
#include "render/object.h"
|
|
|
|
#include "render/scene.h"
|
|
|
|
#include "render/shader.h"
|
|
|
|
#include "render/curves.h"
|
2011-04-27 11:58:34 +00:00
|
|
|
|
Cycles: Make all #include statements relative to cycles source directory
The idea is to make include statements more explicit and obvious where the
file is coming from, additionally reducing chance of wrong header being
picked up.
For example, it was not obvious whether bvh.h was refferring to builder
or traversal, whenter node.h is a generic graph node or a shader node
and cases like that.
Surely this might look obvious for the active developers, but after some
time of not touching the code it becomes less obvious where file is coming
from.
This was briefly mentioned in T50824 and seems @brecht is fine with such
explicitness, but need to agree with all active developers before committing
this.
Please note that this patch is lacking changes related on GPU/OpenCL
support. This will be solved if/when we all agree this is a good idea to move
forward.
Reviewers: brecht, lukasstockner97, maiself, nirved, dingto, juicyfruit, swerner
Reviewed By: lukasstockner97, maiself, nirved, dingto
Subscribers: brecht
Differential Revision: https://developer.blender.org/D2586
2017-03-28 20:39:14 +02:00
|
|
|
#include "device/device.h"
|
2011-04-27 11:58:34 +00:00
|
|
|
|
Cycles: Make all #include statements relative to cycles source directory
The idea is to make include statements more explicit and obvious where the
file is coming from, additionally reducing chance of wrong header being
picked up.
For example, it was not obvious whether bvh.h was refferring to builder
or traversal, whenter node.h is a generic graph node or a shader node
and cases like that.
Surely this might look obvious for the active developers, but after some
time of not touching the code it becomes less obvious where file is coming
from.
This was briefly mentioned in T50824 and seems @brecht is fine with such
explicitness, but need to agree with all active developers before committing
this.
Please note that this patch is lacking changes related on GPU/OpenCL
support. This will be solved if/when we all agree this is a good idea to move
forward.
Reviewers: brecht, lukasstockner97, maiself, nirved, dingto, juicyfruit, swerner
Reviewed By: lukasstockner97, maiself, nirved, dingto
Subscribers: brecht
Differential Revision: https://developer.blender.org/D2586
2017-03-28 20:39:14 +02:00
|
|
|
#include "blender/blender_sync.h"
|
|
|
|
#include "blender/blender_session.h"
|
|
|
|
#include "blender/blender_util.h"
|
2011-04-27 11:58:34 +00:00
|
|
|
|
Cycles: Make all #include statements relative to cycles source directory
The idea is to make include statements more explicit and obvious where the
file is coming from, additionally reducing chance of wrong header being
picked up.
For example, it was not obvious whether bvh.h was refferring to builder
or traversal, whenter node.h is a generic graph node or a shader node
and cases like that.
Surely this might look obvious for the active developers, but after some
time of not touching the code it becomes less obvious where file is coming
from.
This was briefly mentioned in T50824 and seems @brecht is fine with such
explicitness, but need to agree with all active developers before committing
this.
Please note that this patch is lacking changes related on GPU/OpenCL
support. This will be solved if/when we all agree this is a good idea to move
forward.
Reviewers: brecht, lukasstockner97, maiself, nirved, dingto, juicyfruit, swerner
Reviewed By: lukasstockner97, maiself, nirved, dingto
Subscribers: brecht
Differential Revision: https://developer.blender.org/D2586
2017-03-28 20:39:14 +02:00
|
|
|
#include "util/util_debug.h"
|
|
|
|
#include "util/util_foreach.h"
|
|
|
|
#include "util/util_opengl.h"
|
|
|
|
#include "util/util_hash.h"
|
2011-04-27 11:58:34 +00:00
|
|
|
|
|
|
|
CCL_NAMESPACE_BEGIN
|
|
|
|
|
|
|
|
/* Constructor */
|
|
|
|
|
2016-01-30 14:18:29 +01:00
|
|
|
BlenderSync::BlenderSync(BL::RenderEngine& b_engine,
|
|
|
|
BL::BlendData& b_data,
|
|
|
|
BL::Scene& b_scene,
|
|
|
|
Scene *scene,
|
|
|
|
bool preview,
|
2017-10-08 04:32:25 +02:00
|
|
|
Progress &progress)
|
2016-01-30 14:18:29 +01:00
|
|
|
: b_engine(b_engine),
|
|
|
|
b_data(b_data),
|
|
|
|
b_scene(b_scene),
|
|
|
|
shader_map(&scene->shaders),
|
|
|
|
object_map(&scene->objects),
|
|
|
|
mesh_map(&scene->meshes),
|
|
|
|
light_map(&scene->lights),
|
|
|
|
particle_system_map(&scene->particle_systems),
|
2011-04-27 11:58:34 +00:00
|
|
|
world_map(NULL),
|
2011-12-01 16:33:21 +00:00
|
|
|
world_recalc(false),
|
2016-01-30 14:18:29 +01:00
|
|
|
scene(scene),
|
|
|
|
preview(preview),
|
2012-09-04 13:29:07 +00:00
|
|
|
experimental(false),
|
2016-04-17 20:15:50 +02:00
|
|
|
dicing_rate(1.0f),
|
2016-04-18 22:35:49 +02:00
|
|
|
max_subdivisions(12),
|
2016-01-30 14:18:29 +01:00
|
|
|
progress(progress)
|
2011-04-27 11:58:34 +00:00
|
|
|
{
|
2016-04-17 20:15:50 +02:00
|
|
|
PointerRNA cscene = RNA_pointer_get(&b_scene.ptr, "cycles");
|
|
|
|
dicing_rate = preview ? RNA_float_get(&cscene, "preview_dicing_rate") : RNA_float_get(&cscene, "dicing_rate");
|
2016-04-18 22:35:49 +02:00
|
|
|
max_subdivisions = RNA_int_get(&cscene, "max_subdivisions");
|
2011-04-27 11:58:34 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
BlenderSync::~BlenderSync()
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Sync */
|
|
|
|
|
|
|
|
bool BlenderSync::sync_recalc()
|
|
|
|
{
|
2011-08-11 16:48:13 +00:00
|
|
|
/* sync recalc flags from blender to cycles. actual update is done separate,
|
2012-06-09 17:22:52 +00:00
|
|
|
* so we can do it later on if doing it immediate is not suitable */
|
2011-08-11 16:48:13 +00:00
|
|
|
|
2011-04-27 11:58:34 +00:00
|
|
|
BL::BlendData::materials_iterator b_mat;
|
2015-01-21 22:19:31 +05:00
|
|
|
bool has_updated_objects = b_data.objects.is_updated();
|
|
|
|
for(b_data.materials.begin(b_mat); b_mat != b_data.materials.end(); ++b_mat) {
|
|
|
|
if(b_mat->is_updated() || (b_mat->node_tree() && b_mat->node_tree().is_updated())) {
|
2011-04-27 11:58:34 +00:00
|
|
|
shader_map.set_recalc(*b_mat);
|
2015-01-21 22:19:31 +05:00
|
|
|
}
|
|
|
|
else {
|
|
|
|
Shader *shader = shader_map.find(*b_mat);
|
|
|
|
if(has_updated_objects && shader != NULL && shader->has_object_dependency) {
|
|
|
|
shader_map.set_recalc(*b_mat);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2011-04-27 11:58:34 +00:00
|
|
|
|
|
|
|
BL::BlendData::lamps_iterator b_lamp;
|
|
|
|
|
2011-08-21 10:32:15 +00:00
|
|
|
for(b_data.lamps.begin(b_lamp); b_lamp != b_data.lamps.end(); ++b_lamp)
|
2012-01-02 19:44:07 +00:00
|
|
|
if(b_lamp->is_updated() || (b_lamp->node_tree() && b_lamp->node_tree().is_updated()))
|
2011-04-27 11:58:34 +00:00
|
|
|
shader_map.set_recalc(*b_lamp);
|
|
|
|
|
2016-09-18 12:04:12 -04:00
|
|
|
bool dicing_prop_changed = false;
|
|
|
|
|
|
|
|
if(experimental) {
|
|
|
|
PointerRNA cscene = RNA_pointer_get(&b_scene.ptr, "cycles");
|
|
|
|
|
|
|
|
float updated_dicing_rate = preview ? RNA_float_get(&cscene, "preview_dicing_rate")
|
|
|
|
: RNA_float_get(&cscene, "dicing_rate");
|
|
|
|
|
|
|
|
if(dicing_rate != updated_dicing_rate) {
|
|
|
|
dicing_rate = updated_dicing_rate;
|
|
|
|
dicing_prop_changed = true;
|
|
|
|
}
|
|
|
|
|
|
|
|
int updated_max_subdivisions = RNA_int_get(&cscene, "max_subdivisions");
|
|
|
|
|
|
|
|
if(max_subdivisions != updated_max_subdivisions) {
|
|
|
|
max_subdivisions = updated_max_subdivisions;
|
|
|
|
dicing_prop_changed = true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2011-04-27 11:58:34 +00:00
|
|
|
BL::BlendData::objects_iterator b_ob;
|
|
|
|
|
2011-08-21 10:32:15 +00:00
|
|
|
for(b_data.objects.begin(b_ob); b_ob != b_data.objects.end(); ++b_ob) {
|
2011-11-03 10:18:58 +00:00
|
|
|
if(b_ob->is_updated()) {
|
2011-04-27 11:58:34 +00:00
|
|
|
object_map.set_recalc(*b_ob);
|
|
|
|
light_map.set_recalc(*b_ob);
|
|
|
|
}
|
2011-09-27 20:37:24 +00:00
|
|
|
|
2011-04-27 11:58:34 +00:00
|
|
|
if(object_is_mesh(*b_ob)) {
|
2016-09-18 12:04:12 -04:00
|
|
|
if(b_ob->is_updated_data() || b_ob->data().is_updated() ||
|
|
|
|
(dicing_prop_changed && object_subdivision_type(*b_ob, preview, experimental) != Mesh::SUBDIVISION_NONE))
|
|
|
|
{
|
2012-05-05 14:33:36 +00:00
|
|
|
BL::ID key = BKE_object_is_modified(*b_ob)? *b_ob: b_ob->data();
|
2011-04-27 11:58:34 +00:00
|
|
|
mesh_map.set_recalc(key);
|
|
|
|
}
|
|
|
|
}
|
2011-09-27 20:37:24 +00:00
|
|
|
else if(object_is_light(*b_ob)) {
|
2011-11-03 10:18:58 +00:00
|
|
|
if(b_ob->is_updated_data() || b_ob->data().is_updated())
|
2011-09-27 20:37:24 +00:00
|
|
|
light_map.set_recalc(*b_ob);
|
|
|
|
}
|
2012-08-31 17:27:08 +00:00
|
|
|
|
2012-09-01 11:30:22 +00:00
|
|
|
if(b_ob->is_updated_data()) {
|
2012-08-31 17:27:08 +00:00
|
|
|
BL::Object::particle_systems_iterator b_psys;
|
2015-03-28 00:15:15 +05:00
|
|
|
for(b_ob->particle_systems.begin(b_psys); b_psys != b_ob->particle_systems.end(); ++b_psys)
|
2012-08-31 17:27:08 +00:00
|
|
|
particle_system_map.set_recalc(*b_ob);
|
|
|
|
}
|
2011-04-27 11:58:34 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
BL::BlendData::meshes_iterator b_mesh;
|
|
|
|
|
2016-04-17 20:15:50 +02:00
|
|
|
for(b_data.meshes.begin(b_mesh); b_mesh != b_data.meshes.end(); ++b_mesh) {
|
|
|
|
if(b_mesh->is_updated()) {
|
2011-04-27 11:58:34 +00:00
|
|
|
mesh_map.set_recalc(*b_mesh);
|
2016-04-17 20:15:50 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2011-04-27 11:58:34 +00:00
|
|
|
BL::BlendData::worlds_iterator b_world;
|
|
|
|
|
2012-06-09 18:56:12 +00:00
|
|
|
for(b_data.worlds.begin(b_world); b_world != b_data.worlds.end(); ++b_world) {
|
2016-03-28 10:45:29 +02:00
|
|
|
if(world_map == b_world->ptr.data) {
|
|
|
|
if(b_world->is_updated() ||
|
|
|
|
(b_world->node_tree() && b_world->node_tree().is_updated()))
|
|
|
|
{
|
|
|
|
world_recalc = true;
|
|
|
|
}
|
|
|
|
else if(b_world->node_tree() && b_world->use_nodes()) {
|
2016-05-14 14:50:03 +02:00
|
|
|
Shader *shader = scene->default_background;
|
|
|
|
if(has_updated_objects && shader->has_object_dependency) {
|
2016-03-28 10:45:29 +02:00
|
|
|
world_recalc = true;
|
|
|
|
}
|
|
|
|
}
|
2012-06-09 18:56:12 +00:00
|
|
|
}
|
|
|
|
}
|
2011-04-27 11:58:34 +00:00
|
|
|
|
|
|
|
bool recalc =
|
|
|
|
shader_map.has_recalc() ||
|
|
|
|
object_map.has_recalc() ||
|
|
|
|
light_map.has_recalc() ||
|
|
|
|
mesh_map.has_recalc() ||
|
2012-08-31 17:27:08 +00:00
|
|
|
particle_system_map.has_recalc() ||
|
2011-11-03 10:18:58 +00:00
|
|
|
BlendDataObjects_is_updated_get(&b_data.ptr) ||
|
2011-04-27 11:58:34 +00:00
|
|
|
world_recalc;
|
|
|
|
|
|
|
|
return recalc;
|
|
|
|
}
|
|
|
|
|
2016-01-30 14:18:29 +01:00
|
|
|
void BlenderSync::sync_data(BL::RenderSettings& b_render,
|
|
|
|
BL::SpaceView3D& b_v3d,
|
|
|
|
BL::Object& b_override,
|
2015-07-21 15:36:35 +02:00
|
|
|
int width, int height,
|
|
|
|
void **python_thread_state,
|
|
|
|
const char *layer)
|
2011-04-27 11:58:34 +00:00
|
|
|
{
|
2012-02-28 16:44:45 +00:00
|
|
|
sync_render_layers(b_v3d, layer);
|
|
|
|
sync_integrator();
|
2011-04-27 11:58:34 +00:00
|
|
|
sync_film();
|
|
|
|
sync_shaders();
|
2015-04-02 19:24:14 +05:00
|
|
|
sync_images();
|
2012-12-28 14:21:30 +00:00
|
|
|
sync_curve_settings();
|
2014-05-12 18:36:01 +02:00
|
|
|
|
|
|
|
mesh_synced.clear(); /* use for objects and motion sync */
|
|
|
|
|
2015-06-29 17:40:13 +02:00
|
|
|
if(scene->need_motion() == Scene::MOTION_PASS ||
|
|
|
|
scene->need_motion() == Scene::MOTION_NONE ||
|
|
|
|
scene->camera->motion_position == Camera::MOTION_POSITION_CENTER)
|
|
|
|
{
|
2017-05-03 12:05:52 +02:00
|
|
|
sync_objects();
|
2015-06-29 17:40:13 +02:00
|
|
|
}
|
2015-07-21 15:36:35 +02:00
|
|
|
sync_motion(b_render,
|
|
|
|
b_override,
|
|
|
|
width, height,
|
|
|
|
python_thread_state);
|
2014-05-12 18:36:01 +02:00
|
|
|
|
|
|
|
mesh_synced.clear();
|
2011-04-27 11:58:34 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/* Integrator */
|
|
|
|
|
2012-02-28 16:44:45 +00:00
|
|
|
void BlenderSync::sync_integrator()
|
2011-04-27 11:58:34 +00:00
|
|
|
{
|
2012-10-09 18:37:14 +00:00
|
|
|
#ifdef __CAMERA_MOTION__
|
|
|
|
BL::RenderSettings r = b_scene.render();
|
|
|
|
#endif
|
2011-04-27 11:58:34 +00:00
|
|
|
PointerRNA cscene = RNA_pointer_get(&b_scene.ptr, "cycles");
|
|
|
|
|
2016-02-10 03:25:53 +05:00
|
|
|
experimental = (get_enum(cscene, "feature_set") != 0);
|
2011-12-01 16:33:21 +00:00
|
|
|
|
2011-04-27 11:58:34 +00:00
|
|
|
Integrator *integrator = scene->integrator;
|
|
|
|
Integrator previntegrator = *integrator;
|
|
|
|
|
2011-09-01 15:53:36 +00:00
|
|
|
integrator->max_bounce = get_int(cscene, "max_bounces");
|
|
|
|
|
|
|
|
integrator->max_diffuse_bounce = get_int(cscene, "diffuse_bounces");
|
|
|
|
integrator->max_glossy_bounce = get_int(cscene, "glossy_bounces");
|
|
|
|
integrator->max_transmission_bounce = get_int(cscene, "transmission_bounces");
|
2013-12-29 15:40:43 +01:00
|
|
|
integrator->max_volume_bounce = get_int(cscene, "volume_bounces");
|
2011-09-01 15:53:36 +00:00
|
|
|
|
|
|
|
integrator->transparent_max_bounce = get_int(cscene, "transparent_max_bounces");
|
|
|
|
|
2013-12-29 22:19:38 +01:00
|
|
|
integrator->volume_max_steps = get_int(cscene, "volume_max_steps");
|
|
|
|
integrator->volume_step_size = get_float(cscene, "volume_step_size");
|
|
|
|
|
2014-09-05 20:39:35 +02:00
|
|
|
integrator->caustics_reflective = get_boolean(cscene, "caustics_reflective");
|
|
|
|
integrator->caustics_refractive = get_boolean(cscene, "caustics_refractive");
|
Cycles: merging features from tomato branch.
=== BVH build time optimizations ===
* BVH building was multithreaded. Not all building is multithreaded, packing
and the initial bounding/splitting is still single threaded, but recursive
splitting is, which was the main bottleneck.
* Object splitting now uses binning rather than sorting of all elements, using
code from the Embree raytracer from Intel.
http://software.intel.com/en-us/articles/embree-photo-realistic-ray-tracing-kernels/
* Other small changes to avoid allocations, pack memory more tightly, avoid
some unnecessary operations, ...
These optimizations do not work yet when Spatial Splits are enabled, for that
more work is needed. There's also other optimizations still needed, in
particular for the case of many low poly objects, the packing step and node
memory allocation.
BVH raytracing time should remain about the same, but BVH build time should be
significantly reduced, test here show speedup of about 5x to 10x on a dual core
and 5x to 25x on an 8-core machine, depending on the scene.
=== Threads ===
Centralized task scheduler for multithreading, which is basically the
CPU device threading code wrapped into something reusable.
Basic idea is that there is a single TaskScheduler that keeps a pool of threads,
one for each core. Other places in the code can then create a TaskPool that they
can drop Tasks in to be executed by the scheduler, and wait for them to complete
or cancel them early.
=== Normal ====
Added a Normal output to the texture coordinate node. This currently
gives the object space normal, which is the same under object animation.
In the future this might become a "generated" normal so it's also stable for
deforming objects, but for now it's already useful for non-deforming objects.
=== Render Layers ===
Per render layer Samples control, leaving it to 0 will use the common scene
setting.
Environment pass will now render environment even if film is set to transparent.
Exclude Layers" added. Scene layers (all object that influence the render,
directly or indirectly) are shared between all render layers. However sometimes
it's useful to leave out some object influence for a particular render layer.
That's what this option allows you to do.
=== Filter Glossy ===
When using a value higher than 0.0, this will blur glossy reflections after
blurry bounces, to reduce noise at the cost of accuracy. 1.0 is a good
starting value to tweak.
Some light paths have a low probability of being found while contributing much
light to the pixel. As a result these light paths will be found in some pixels
and not in others, causing fireflies. An example of such a difficult path might
be a small light that is causing a small specular highlight on a sharp glossy
material, which we are seeing through a rough glossy material. With path tracing
it is difficult to find the specular highlight, but if we increase the roughness
on the material the highlight gets bigger and softer, and so easier to find.
Often this blurring will be hardly noticeable, because we are seeing it through
a blurry material anyway, but there are also cases where this will lead to a
loss of detail in lighting.
2012-04-28 08:53:59 +00:00
|
|
|
integrator->filter_glossy = get_float(cscene, "blur_glossy");
|
|
|
|
|
2011-10-29 14:27:24 +00:00
|
|
|
integrator->seed = get_int(cscene, "seed");
|
2016-11-08 11:16:37 +01:00
|
|
|
if(get_boolean(cscene, "use_animated_seed")) {
|
|
|
|
integrator->seed = hash_int_2d(b_scene.frame_current(),
|
|
|
|
get_int(cscene, "seed"));
|
2016-11-16 15:12:31 +01:00
|
|
|
if(b_scene.frame_subframe() != 0.0f) {
|
|
|
|
/* TODO(sergey): Ideally should be some sort of hash_merge,
|
|
|
|
* but this is good enough for now.
|
|
|
|
*/
|
|
|
|
integrator->seed += hash_int_2d((int)(b_scene.frame_subframe() * (float)INT_MAX),
|
|
|
|
get_int(cscene, "seed"));
|
|
|
|
}
|
2016-11-08 11:16:37 +01:00
|
|
|
}
|
2015-05-15 13:49:17 +02:00
|
|
|
|
2016-02-10 15:09:45 +01:00
|
|
|
integrator->sampling_pattern = (SamplingPattern)get_enum(
|
|
|
|
cscene,
|
|
|
|
"sampling_pattern",
|
|
|
|
SAMPLING_NUM_PATTERNS,
|
|
|
|
SAMPLING_PATTERN_SOBOL);
|
2012-02-07 20:51:33 +00:00
|
|
|
|
2014-02-10 21:44:49 +01:00
|
|
|
integrator->sample_clamp_direct = get_float(cscene, "sample_clamp_direct");
|
|
|
|
integrator->sample_clamp_indirect = get_float(cscene, "sample_clamp_indirect");
|
2012-10-09 18:37:14 +00:00
|
|
|
#ifdef __CAMERA_MOTION__
|
2012-11-15 21:52:17 +00:00
|
|
|
if(!preview) {
|
|
|
|
if(integrator->motion_blur != r.use_motion_blur()) {
|
|
|
|
scene->object_manager->tag_update(scene);
|
|
|
|
scene->camera->tag_update();
|
|
|
|
}
|
2012-10-15 21:12:58 +00:00
|
|
|
|
2012-11-15 21:52:17 +00:00
|
|
|
integrator->motion_blur = r.use_motion_blur();
|
|
|
|
}
|
2012-04-30 12:49:26 +00:00
|
|
|
#endif
|
2012-04-05 15:17:45 +00:00
|
|
|
|
2016-02-10 15:09:45 +01:00
|
|
|
integrator->method = (Integrator::Method)get_enum(cscene,
|
|
|
|
"progressive",
|
|
|
|
Integrator::NUM_METHODS,
|
|
|
|
Integrator::PATH);
|
2014-03-15 17:36:44 +01:00
|
|
|
|
|
|
|
integrator->sample_all_lights_direct = get_boolean(cscene, "sample_all_lights_direct");
|
2014-03-09 22:19:27 +01:00
|
|
|
integrator->sample_all_lights_indirect = get_boolean(cscene, "sample_all_lights_indirect");
|
2016-10-29 23:47:30 +02:00
|
|
|
integrator->light_sampling_threshold = get_float(cscene, "light_sampling_threshold");
|
2012-06-13 11:44:48 +00:00
|
|
|
|
2017-08-20 23:46:05 +02:00
|
|
|
int diffuse_samples = get_int(cscene, "diffuse_samples");
|
|
|
|
int glossy_samples = get_int(cscene, "glossy_samples");
|
|
|
|
int transmission_samples = get_int(cscene, "transmission_samples");
|
|
|
|
int ao_samples = get_int(cscene, "ao_samples");
|
|
|
|
int mesh_light_samples = get_int(cscene, "mesh_light_samples");
|
|
|
|
int subsurface_samples = get_int(cscene, "subsurface_samples");
|
|
|
|
int volume_samples = get_int(cscene, "volume_samples");
|
|
|
|
|
|
|
|
if(get_boolean(cscene, "use_square_samples")) {
|
|
|
|
integrator->diffuse_samples = diffuse_samples * diffuse_samples;
|
|
|
|
integrator->glossy_samples = glossy_samples * glossy_samples;
|
|
|
|
integrator->transmission_samples = transmission_samples * transmission_samples;
|
|
|
|
integrator->ao_samples = ao_samples * ao_samples;
|
|
|
|
integrator->mesh_light_samples = mesh_light_samples * mesh_light_samples;
|
|
|
|
integrator->subsurface_samples = subsurface_samples * subsurface_samples;
|
|
|
|
integrator->volume_samples = volume_samples * volume_samples;
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
integrator->diffuse_samples = diffuse_samples;
|
|
|
|
integrator->glossy_samples = glossy_samples;
|
|
|
|
integrator->transmission_samples = transmission_samples;
|
|
|
|
integrator->ao_samples = ao_samples;
|
|
|
|
integrator->mesh_light_samples = mesh_light_samples;
|
|
|
|
integrator->subsurface_samples = subsurface_samples;
|
|
|
|
integrator->volume_samples = volume_samples;
|
|
|
|
}
|
2013-06-07 16:06:22 +00:00
|
|
|
|
2016-11-25 18:59:43 +01:00
|
|
|
if(b_scene.render().use_simplify()) {
|
|
|
|
if(preview) {
|
|
|
|
integrator->ao_bounces = get_int(cscene, "ao_bounces");
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
integrator->ao_bounces = get_int(cscene, "ao_bounces_render");
|
|
|
|
}
|
|
|
|
}
|
2017-05-23 10:34:03 +02:00
|
|
|
else {
|
|
|
|
integrator->ao_bounces = 0;
|
|
|
|
}
|
2016-11-25 18:59:43 +01:00
|
|
|
|
2011-04-27 11:58:34 +00:00
|
|
|
if(integrator->modified(previntegrator))
|
|
|
|
integrator->tag_update(scene);
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Film */
|
|
|
|
|
|
|
|
void BlenderSync::sync_film()
|
|
|
|
{
|
|
|
|
PointerRNA cscene = RNA_pointer_get(&b_scene.ptr, "cycles");
|
|
|
|
|
|
|
|
Film *film = scene->film;
|
|
|
|
Film prevfilm = *film;
|
2014-02-11 14:14:13 +01:00
|
|
|
|
2011-09-01 15:53:36 +00:00
|
|
|
film->exposure = get_float(cscene, "film_exposure");
|
2016-02-10 15:09:45 +01:00
|
|
|
film->filter_type = (FilterType)get_enum(cscene,
|
|
|
|
"pixel_filter_type",
|
|
|
|
FILTER_NUM_TYPES,
|
|
|
|
FILTER_BLACKMAN_HARRIS);
|
2013-04-01 20:26:43 +00:00
|
|
|
film->filter_width = (film->filter_type == FILTER_BOX)? 1.0f: get_float(cscene, "filter_width");
|
2011-04-27 11:58:34 +00:00
|
|
|
|
2013-06-09 18:05:53 +00:00
|
|
|
if(b_scene.world()) {
|
|
|
|
BL::WorldMistSettings b_mist = b_scene.world().mist_settings();
|
|
|
|
|
|
|
|
film->mist_start = b_mist.start();
|
|
|
|
film->mist_depth = b_mist.depth();
|
|
|
|
|
|
|
|
switch(b_mist.falloff()) {
|
|
|
|
case BL::WorldMistSettings::falloff_QUADRATIC:
|
|
|
|
film->mist_falloff = 2.0f;
|
|
|
|
break;
|
|
|
|
case BL::WorldMistSettings::falloff_LINEAR:
|
|
|
|
film->mist_falloff = 1.0f;
|
|
|
|
break;
|
|
|
|
case BL::WorldMistSettings::falloff_INVERSE_QUADRATIC:
|
|
|
|
film->mist_falloff = 0.5f;
|
|
|
|
break;
|
|
|
|
}
|
2013-06-07 12:45:26 +00:00
|
|
|
}
|
|
|
|
|
2011-04-27 11:58:34 +00:00
|
|
|
if(film->modified(prevfilm))
|
|
|
|
film->tag_update(scene);
|
|
|
|
}
|
|
|
|
|
2011-09-12 13:13:56 +00:00
|
|
|
/* Render Layer */
|
|
|
|
|
2016-01-30 14:18:29 +01:00
|
|
|
void BlenderSync::sync_render_layers(BL::SpaceView3D& b_v3d, const char *layer)
|
2011-09-12 13:13:56 +00:00
|
|
|
{
|
2013-04-16 16:18:14 +00:00
|
|
|
PointerRNA cscene = RNA_pointer_get(&b_scene.ptr, "cycles");
|
2012-03-28 09:07:35 +00:00
|
|
|
string layername;
|
|
|
|
|
|
|
|
/* 3d view */
|
2011-09-12 13:13:56 +00:00
|
|
|
if(b_v3d) {
|
2012-03-28 09:07:35 +00:00
|
|
|
if(RNA_boolean_get(&cscene, "preview_active_layer")) {
|
|
|
|
BL::RenderLayers layers(b_scene.render().ptr);
|
|
|
|
layername = layers.active().name();
|
|
|
|
layer = layername.c_str();
|
|
|
|
}
|
|
|
|
else {
|
2016-05-22 09:57:36 +02:00
|
|
|
render_layer.scene_layer = get_layer(b_v3d.layers(), b_v3d.layers_local_view());
|
2012-03-28 09:07:35 +00:00
|
|
|
render_layer.layer = render_layer.scene_layer;
|
2012-11-09 23:28:51 +00:00
|
|
|
render_layer.exclude_layer = 0;
|
2012-03-28 09:07:35 +00:00
|
|
|
render_layer.holdout_layer = 0;
|
|
|
|
render_layer.material_override = PointerRNA_NULL;
|
2015-11-24 13:21:40 +05:00
|
|
|
render_layer.use_background_shader = true;
|
|
|
|
render_layer.use_background_ao = true;
|
2013-05-10 13:34:49 +00:00
|
|
|
render_layer.use_hair = true;
|
|
|
|
render_layer.use_surfaces = true;
|
2012-05-05 10:17:18 +00:00
|
|
|
render_layer.use_viewport_visibility = true;
|
Cycles: merging features from tomato branch.
=== BVH build time optimizations ===
* BVH building was multithreaded. Not all building is multithreaded, packing
and the initial bounding/splitting is still single threaded, but recursive
splitting is, which was the main bottleneck.
* Object splitting now uses binning rather than sorting of all elements, using
code from the Embree raytracer from Intel.
http://software.intel.com/en-us/articles/embree-photo-realistic-ray-tracing-kernels/
* Other small changes to avoid allocations, pack memory more tightly, avoid
some unnecessary operations, ...
These optimizations do not work yet when Spatial Splits are enabled, for that
more work is needed. There's also other optimizations still needed, in
particular for the case of many low poly objects, the packing step and node
memory allocation.
BVH raytracing time should remain about the same, but BVH build time should be
significantly reduced, test here show speedup of about 5x to 10x on a dual core
and 5x to 25x on an 8-core machine, depending on the scene.
=== Threads ===
Centralized task scheduler for multithreading, which is basically the
CPU device threading code wrapped into something reusable.
Basic idea is that there is a single TaskScheduler that keeps a pool of threads,
one for each core. Other places in the code can then create a TaskPool that they
can drop Tasks in to be executed by the scheduler, and wait for them to complete
or cancel them early.
=== Normal ====
Added a Normal output to the texture coordinate node. This currently
gives the object space normal, which is the same under object animation.
In the future this might become a "generated" normal so it's also stable for
deforming objects, but for now it's already useful for non-deforming objects.
=== Render Layers ===
Per render layer Samples control, leaving it to 0 will use the common scene
setting.
Environment pass will now render environment even if film is set to transparent.
Exclude Layers" added. Scene layers (all object that influence the render,
directly or indirectly) are shared between all render layers. However sometimes
it's useful to leave out some object influence for a particular render layer.
That's what this option allows you to do.
=== Filter Glossy ===
When using a value higher than 0.0, this will blur glossy reflections after
blurry bounces, to reduce noise at the cost of accuracy. 1.0 is a good
starting value to tweak.
Some light paths have a low probability of being found while contributing much
light to the pixel. As a result these light paths will be found in some pixels
and not in others, causing fireflies. An example of such a difficult path might
be a small light that is causing a small specular highlight on a sharp glossy
material, which we are seeing through a rough glossy material. With path tracing
it is difficult to find the specular highlight, but if we increase the roughness
on the material the highlight gets bigger and softer, and so easier to find.
Often this blurring will be hardly noticeable, because we are seeing it through
a blurry material anyway, but there are also cases where this will lead to a
loss of detail in lighting.
2012-04-28 08:53:59 +00:00
|
|
|
render_layer.samples = 0;
|
2013-04-16 16:18:14 +00:00
|
|
|
render_layer.bound_samples = false;
|
2012-03-28 09:07:35 +00:00
|
|
|
return;
|
|
|
|
}
|
2011-09-12 13:13:56 +00:00
|
|
|
}
|
2011-12-21 20:51:55 +00:00
|
|
|
|
2012-03-28 09:07:35 +00:00
|
|
|
/* render layer */
|
|
|
|
BL::RenderSettings r = b_scene.render();
|
|
|
|
BL::RenderSettings::layers_iterator b_rlay;
|
2016-02-10 03:25:53 +05:00
|
|
|
int use_layer_samples = get_enum(cscene, "use_layer_samples");
|
2012-03-28 09:07:35 +00:00
|
|
|
bool first_layer = true;
|
2014-07-04 16:32:17 +06:00
|
|
|
uint layer_override = get_layer(b_engine.layer_override());
|
|
|
|
uint scene_layers = layer_override ? layer_override : get_layer(b_scene.layers());
|
2012-03-28 09:07:35 +00:00
|
|
|
|
|
|
|
for(r.layers.begin(b_rlay); b_rlay != r.layers.end(); ++b_rlay) {
|
|
|
|
if((!layer && first_layer) || (layer && b_rlay->name() == layer)) {
|
|
|
|
render_layer.name = b_rlay->name();
|
2012-11-09 23:28:51 +00:00
|
|
|
|
2012-03-28 09:07:35 +00:00
|
|
|
render_layer.holdout_layer = get_layer(b_rlay->layers_zmask());
|
2012-11-09 23:28:51 +00:00
|
|
|
render_layer.exclude_layer = get_layer(b_rlay->layers_exclude());
|
|
|
|
|
2014-07-04 16:32:17 +06:00
|
|
|
render_layer.scene_layer = scene_layers & ~render_layer.exclude_layer;
|
2012-11-09 23:28:51 +00:00
|
|
|
render_layer.scene_layer |= render_layer.exclude_layer & render_layer.holdout_layer;
|
|
|
|
|
|
|
|
render_layer.layer = get_layer(b_rlay->layers());
|
2012-03-28 09:07:35 +00:00
|
|
|
render_layer.layer |= render_layer.holdout_layer;
|
2012-11-09 23:28:51 +00:00
|
|
|
|
2012-03-28 09:07:35 +00:00
|
|
|
render_layer.material_override = b_rlay->material_override();
|
2015-11-24 13:21:40 +05:00
|
|
|
render_layer.use_background_shader = b_rlay->use_sky();
|
|
|
|
render_layer.use_background_ao = b_rlay->use_ao();
|
2013-05-10 13:34:49 +00:00
|
|
|
render_layer.use_surfaces = b_rlay->use_solid();
|
|
|
|
render_layer.use_hair = b_rlay->use_strand();
|
2012-05-05 10:17:18 +00:00
|
|
|
render_layer.use_viewport_visibility = false;
|
2013-04-16 16:18:14 +00:00
|
|
|
|
|
|
|
render_layer.bound_samples = (use_layer_samples == 1);
|
2013-07-19 22:51:48 +00:00
|
|
|
if(use_layer_samples != 2) {
|
2017-08-20 23:46:05 +02:00
|
|
|
int samples = b_rlay->samples();
|
|
|
|
if(get_boolean(cscene, "use_square_samples"))
|
|
|
|
render_layer.samples = samples * samples;
|
|
|
|
else
|
|
|
|
render_layer.samples = samples;
|
2013-07-19 22:51:48 +00:00
|
|
|
}
|
2011-09-12 13:13:56 +00:00
|
|
|
}
|
2012-03-28 09:07:35 +00:00
|
|
|
|
|
|
|
first_layer = false;
|
2011-09-12 13:13:56 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2015-04-02 19:24:14 +05:00
|
|
|
/* Images */
|
|
|
|
void BlenderSync::sync_images()
|
|
|
|
{
|
|
|
|
/* Sync is a convention for this API, but currently it frees unused buffers. */
|
|
|
|
|
|
|
|
const bool is_interface_locked = b_engine.render() &&
|
|
|
|
b_engine.render().use_lock_interface();
|
|
|
|
if(is_interface_locked == false && BlenderSession::headless == false) {
|
|
|
|
/* If interface is not locked, it's possible image is needed for
|
|
|
|
* the display.
|
|
|
|
*/
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
/* Free buffers used by images which are not needed for render. */
|
|
|
|
BL::BlendData::images_iterator b_image;
|
|
|
|
for(b_data.images.begin(b_image);
|
|
|
|
b_image != b_data.images.end();
|
|
|
|
++b_image)
|
|
|
|
{
|
|
|
|
/* TODO(sergey): Consider making it an utility function to check
|
|
|
|
* whether image is considered builtin.
|
|
|
|
*/
|
|
|
|
const bool is_builtin = b_image->packed_file() ||
|
|
|
|
b_image->source() == BL::Image::source_GENERATED ||
|
Cycles: Experiment with making previews more interactive
There were two major problems with the interactivity of material previews:
- Beckmann tables were re-generated on every material tweak.
This is because preview scene is not set to be persistent, so re-triggering
the render leads to the full scene re-sync.
- Images could take rather noticeable time to load with OIIO from the disk
on every tweak.
This patch addressed this two issues in the following way:
- Beckmann tables are now static on CPU memory.
They're couple of hundred kilobytes only, so wouldn't expect this to be
an issue. And they're needed for almost every render anyway.
This actually also makes blackbody table to be static, but it's even smaller
than beckmann table.
Not totally happy with this approach, but others seems to complicate things
quite a bit with all this render engine life time and so..
- For preview rendering all images are considered to be built-in. This means
instead of OIIO which re-loads images on every re-render they're coming
from ImBuf cache which is fully manageable from blender side and unused
images gets freed later.
This would make it impossible to have mipmapping with OSL for now, but we'll
be working on that later anyway and don't think mipmaps are really so crucial
for the material preview.
This seems to be a better alternative to making preview scene persistent,
because of much optimal memory control from blender side.
Reviewers: brecht, juicyfruit, campbellbarton, dingto
Subscribers: eyecandy, venomgfx
Differential Revision: https://developer.blender.org/D1132
2015-02-21 21:55:24 +05:00
|
|
|
b_image->source() == BL::Image::source_MOVIE ||
|
|
|
|
b_engine.is_preview();
|
2015-04-02 19:24:14 +05:00
|
|
|
if(is_builtin == false) {
|
|
|
|
b_image->buffers_free();
|
|
|
|
}
|
|
|
|
/* TODO(sergey): Free builtin images not used by any shader. */
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
Render API/Cycles: Identify Render Passes by their name instead of a type flag
Previously, every RenderPass would have a bitfield that specified its type. That limits the number of passes to 32, which was reached a while ago.
However, most of the code already supported arbitrary RenderPasses since they were also used to store Multilayer EXR images.
Therefore, this commit completely removes the passflag from RenderPass and changes all code to use the unique pass name for identification.
Since Blender Internal relies on hardcoded passes and to preserve compatibility, 32 pass names are reserved for the old hardcoded passes.
To support these arbitrary passes, the Render Result compositor node now adds dynamic sockets. For compatibility, the old hardcoded sockets are always stored and just hidden when the corresponding pass isn't available.
To use these changes, the Render Engine API now includes a function that allows render engines to add arbitrary passes to the render result. To be able to add options for these passes, addons can now add their own properties to SceneRenderLayers.
To keep the compositor input node updated, render engine plugins have to implement a callback that registers all the passes that will be generated.
From a user perspective, nothing should change with this commit.
Differential Revision: https://developer.blender.org/D2443
Differential Revision: https://developer.blender.org/D2444
2017-05-03 00:21:18 +02:00
|
|
|
/* Passes */
|
|
|
|
PassType BlenderSync::get_pass_type(BL::RenderPass& b_pass)
|
|
|
|
{
|
|
|
|
string name = b_pass.name();
|
|
|
|
#define MAP_PASS(passname, passtype) if(name == passname) return passtype;
|
|
|
|
/* NOTE: Keep in sync with defined names from DNA_scene_types.h */
|
|
|
|
MAP_PASS("Combined", PASS_COMBINED);
|
|
|
|
MAP_PASS("Depth", PASS_DEPTH);
|
|
|
|
MAP_PASS("Mist", PASS_MIST);
|
|
|
|
MAP_PASS("Normal", PASS_NORMAL);
|
|
|
|
MAP_PASS("IndexOB", PASS_OBJECT_ID);
|
|
|
|
MAP_PASS("UV", PASS_UV);
|
|
|
|
MAP_PASS("Vector", PASS_MOTION);
|
|
|
|
MAP_PASS("IndexMA", PASS_MATERIAL_ID);
|
|
|
|
|
|
|
|
MAP_PASS("DiffDir", PASS_DIFFUSE_DIRECT);
|
|
|
|
MAP_PASS("GlossDir", PASS_GLOSSY_DIRECT);
|
|
|
|
MAP_PASS("TransDir", PASS_TRANSMISSION_DIRECT);
|
|
|
|
MAP_PASS("SubsurfaceDir", PASS_SUBSURFACE_DIRECT);
|
|
|
|
|
|
|
|
MAP_PASS("DiffInd", PASS_DIFFUSE_INDIRECT);
|
|
|
|
MAP_PASS("GlossInd", PASS_GLOSSY_INDIRECT);
|
|
|
|
MAP_PASS("TransInd", PASS_TRANSMISSION_INDIRECT);
|
|
|
|
MAP_PASS("SubsurfaceInd", PASS_SUBSURFACE_INDIRECT);
|
|
|
|
|
|
|
|
MAP_PASS("DiffCol", PASS_DIFFUSE_COLOR);
|
|
|
|
MAP_PASS("GlossCol", PASS_GLOSSY_COLOR);
|
|
|
|
MAP_PASS("TransCol", PASS_TRANSMISSION_COLOR);
|
|
|
|
MAP_PASS("SubsurfaceCol", PASS_SUBSURFACE_COLOR);
|
|
|
|
|
|
|
|
MAP_PASS("Emit", PASS_EMISSION);
|
|
|
|
MAP_PASS("Env", PASS_BACKGROUND);
|
|
|
|
MAP_PASS("AO", PASS_AO);
|
|
|
|
MAP_PASS("Shadow", PASS_SHADOW);
|
|
|
|
|
|
|
|
#ifdef __KERNEL_DEBUG__
|
|
|
|
MAP_PASS("Debug BVH Traversed Nodes", PASS_BVH_TRAVERSED_NODES);
|
|
|
|
MAP_PASS("Debug BVH Traversed Instances", PASS_BVH_TRAVERSED_INSTANCES);
|
|
|
|
MAP_PASS("Debug BVH Intersections", PASS_BVH_INTERSECTIONS);
|
|
|
|
MAP_PASS("Debug Ray Bounces", PASS_RAY_BOUNCES);
|
|
|
|
#endif
|
|
|
|
#undef MAP_PASS
|
|
|
|
|
|
|
|
return PASS_NONE;
|
|
|
|
}
|
|
|
|
|
2017-05-07 14:40:58 +02:00
|
|
|
int BlenderSync::get_denoising_pass(BL::RenderPass& b_pass)
|
|
|
|
{
|
|
|
|
string name = b_pass.name();
|
|
|
|
if(name.substr(0, 10) != "Denoising ") {
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
name = name.substr(10);
|
|
|
|
|
|
|
|
#define MAP_PASS(passname, offset) if(name == passname) return offset;
|
|
|
|
MAP_PASS("Normal", DENOISING_PASS_NORMAL);
|
|
|
|
MAP_PASS("Normal Variance", DENOISING_PASS_NORMAL_VAR);
|
|
|
|
MAP_PASS("Albedo", DENOISING_PASS_ALBEDO);
|
|
|
|
MAP_PASS("Albedo Variance", DENOISING_PASS_ALBEDO_VAR);
|
|
|
|
MAP_PASS("Depth", DENOISING_PASS_DEPTH);
|
|
|
|
MAP_PASS("Depth Variance", DENOISING_PASS_DEPTH_VAR);
|
|
|
|
MAP_PASS("Shadow A", DENOISING_PASS_SHADOW_A);
|
|
|
|
MAP_PASS("Shadow B", DENOISING_PASS_SHADOW_B);
|
|
|
|
MAP_PASS("Image", DENOISING_PASS_COLOR);
|
|
|
|
MAP_PASS("Image Variance", DENOISING_PASS_COLOR_VAR);
|
|
|
|
#undef MAP_PASS
|
|
|
|
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
Render API/Cycles: Identify Render Passes by their name instead of a type flag
Previously, every RenderPass would have a bitfield that specified its type. That limits the number of passes to 32, which was reached a while ago.
However, most of the code already supported arbitrary RenderPasses since they were also used to store Multilayer EXR images.
Therefore, this commit completely removes the passflag from RenderPass and changes all code to use the unique pass name for identification.
Since Blender Internal relies on hardcoded passes and to preserve compatibility, 32 pass names are reserved for the old hardcoded passes.
To support these arbitrary passes, the Render Result compositor node now adds dynamic sockets. For compatibility, the old hardcoded sockets are always stored and just hidden when the corresponding pass isn't available.
To use these changes, the Render Engine API now includes a function that allows render engines to add arbitrary passes to the render result. To be able to add options for these passes, addons can now add their own properties to SceneRenderLayers.
To keep the compositor input node updated, render engine plugins have to implement a callback that registers all the passes that will be generated.
From a user perspective, nothing should change with this commit.
Differential Revision: https://developer.blender.org/D2443
Differential Revision: https://developer.blender.org/D2444
2017-05-03 00:21:18 +02:00
|
|
|
array<Pass> BlenderSync::sync_render_passes(BL::RenderLayer& b_rlay,
|
2017-06-09 23:02:56 +02:00
|
|
|
BL::SceneRenderLayer& b_srlay,
|
|
|
|
const SessionParams &session_params)
|
Render API/Cycles: Identify Render Passes by their name instead of a type flag
Previously, every RenderPass would have a bitfield that specified its type. That limits the number of passes to 32, which was reached a while ago.
However, most of the code already supported arbitrary RenderPasses since they were also used to store Multilayer EXR images.
Therefore, this commit completely removes the passflag from RenderPass and changes all code to use the unique pass name for identification.
Since Blender Internal relies on hardcoded passes and to preserve compatibility, 32 pass names are reserved for the old hardcoded passes.
To support these arbitrary passes, the Render Result compositor node now adds dynamic sockets. For compatibility, the old hardcoded sockets are always stored and just hidden when the corresponding pass isn't available.
To use these changes, the Render Engine API now includes a function that allows render engines to add arbitrary passes to the render result. To be able to add options for these passes, addons can now add their own properties to SceneRenderLayers.
To keep the compositor input node updated, render engine plugins have to implement a callback that registers all the passes that will be generated.
From a user perspective, nothing should change with this commit.
Differential Revision: https://developer.blender.org/D2443
Differential Revision: https://developer.blender.org/D2444
2017-05-03 00:21:18 +02:00
|
|
|
{
|
|
|
|
array<Pass> passes;
|
|
|
|
Pass::add(PASS_COMBINED, passes);
|
|
|
|
|
2017-06-09 23:02:56 +02:00
|
|
|
if(!session_params.device.advanced_shading) {
|
|
|
|
return passes;
|
|
|
|
}
|
|
|
|
|
Render API/Cycles: Identify Render Passes by their name instead of a type flag
Previously, every RenderPass would have a bitfield that specified its type. That limits the number of passes to 32, which was reached a while ago.
However, most of the code already supported arbitrary RenderPasses since they were also used to store Multilayer EXR images.
Therefore, this commit completely removes the passflag from RenderPass and changes all code to use the unique pass name for identification.
Since Blender Internal relies on hardcoded passes and to preserve compatibility, 32 pass names are reserved for the old hardcoded passes.
To support these arbitrary passes, the Render Result compositor node now adds dynamic sockets. For compatibility, the old hardcoded sockets are always stored and just hidden when the corresponding pass isn't available.
To use these changes, the Render Engine API now includes a function that allows render engines to add arbitrary passes to the render result. To be able to add options for these passes, addons can now add their own properties to SceneRenderLayers.
To keep the compositor input node updated, render engine plugins have to implement a callback that registers all the passes that will be generated.
From a user perspective, nothing should change with this commit.
Differential Revision: https://developer.blender.org/D2443
Differential Revision: https://developer.blender.org/D2444
2017-05-03 00:21:18 +02:00
|
|
|
/* loop over passes */
|
|
|
|
BL::RenderLayer::passes_iterator b_pass_iter;
|
|
|
|
|
|
|
|
for(b_rlay.passes.begin(b_pass_iter); b_pass_iter != b_rlay.passes.end(); ++b_pass_iter) {
|
|
|
|
BL::RenderPass b_pass(*b_pass_iter);
|
|
|
|
PassType pass_type = get_pass_type(b_pass);
|
|
|
|
|
|
|
|
if(pass_type == PASS_MOTION && scene->integrator->motion_blur)
|
|
|
|
continue;
|
|
|
|
if(pass_type != PASS_NONE)
|
|
|
|
Pass::add(pass_type, passes);
|
|
|
|
}
|
|
|
|
|
|
|
|
PointerRNA crp = RNA_pointer_get(&b_srlay.ptr, "cycles");
|
2017-06-09 23:02:56 +02:00
|
|
|
if(get_boolean(crp, "denoising_store_passes") &&
|
2017-11-07 13:55:58 +01:00
|
|
|
get_boolean(crp, "use_denoising"))
|
|
|
|
{
|
2017-05-07 14:40:58 +02:00
|
|
|
b_engine.add_pass("Denoising Normal", 3, "XYZ", b_srlay.name().c_str());
|
|
|
|
b_engine.add_pass("Denoising Normal Variance", 3, "XYZ", b_srlay.name().c_str());
|
|
|
|
b_engine.add_pass("Denoising Albedo", 3, "RGB", b_srlay.name().c_str());
|
|
|
|
b_engine.add_pass("Denoising Albedo Variance", 3, "RGB", b_srlay.name().c_str());
|
|
|
|
b_engine.add_pass("Denoising Depth", 1, "Z", b_srlay.name().c_str());
|
|
|
|
b_engine.add_pass("Denoising Depth Variance", 1, "Z", b_srlay.name().c_str());
|
|
|
|
b_engine.add_pass("Denoising Shadow A", 3, "XYV", b_srlay.name().c_str());
|
|
|
|
b_engine.add_pass("Denoising Shadow B", 3, "XYV", b_srlay.name().c_str());
|
|
|
|
b_engine.add_pass("Denoising Image", 3, "RGB", b_srlay.name().c_str());
|
|
|
|
b_engine.add_pass("Denoising Image Variance", 3, "RGB", b_srlay.name().c_str());
|
|
|
|
}
|
|
|
|
#ifdef __KERNEL_DEBUG__
|
Render API/Cycles: Identify Render Passes by their name instead of a type flag
Previously, every RenderPass would have a bitfield that specified its type. That limits the number of passes to 32, which was reached a while ago.
However, most of the code already supported arbitrary RenderPasses since they were also used to store Multilayer EXR images.
Therefore, this commit completely removes the passflag from RenderPass and changes all code to use the unique pass name for identification.
Since Blender Internal relies on hardcoded passes and to preserve compatibility, 32 pass names are reserved for the old hardcoded passes.
To support these arbitrary passes, the Render Result compositor node now adds dynamic sockets. For compatibility, the old hardcoded sockets are always stored and just hidden when the corresponding pass isn't available.
To use these changes, the Render Engine API now includes a function that allows render engines to add arbitrary passes to the render result. To be able to add options for these passes, addons can now add their own properties to SceneRenderLayers.
To keep the compositor input node updated, render engine plugins have to implement a callback that registers all the passes that will be generated.
From a user perspective, nothing should change with this commit.
Differential Revision: https://developer.blender.org/D2443
Differential Revision: https://developer.blender.org/D2444
2017-05-03 00:21:18 +02:00
|
|
|
if(get_boolean(crp, "pass_debug_bvh_traversed_nodes")) {
|
|
|
|
b_engine.add_pass("Debug BVH Traversed Nodes", 1, "X", b_srlay.name().c_str());
|
|
|
|
Pass::add(PASS_BVH_TRAVERSED_NODES, passes);
|
|
|
|
}
|
|
|
|
if(get_boolean(crp, "pass_debug_bvh_traversed_instances")) {
|
|
|
|
b_engine.add_pass("Debug BVH Traversed Instances", 1, "X", b_srlay.name().c_str());
|
|
|
|
Pass::add(PASS_BVH_TRAVERSED_INSTANCES, passes);
|
|
|
|
}
|
|
|
|
if(get_boolean(crp, "pass_debug_bvh_intersections")) {
|
|
|
|
b_engine.add_pass("Debug BVH Intersections", 1, "X", b_srlay.name().c_str());
|
|
|
|
Pass::add(PASS_BVH_INTERSECTIONS, passes);
|
|
|
|
}
|
|
|
|
if(get_boolean(crp, "pass_debug_ray_bounces")) {
|
|
|
|
b_engine.add_pass("Debug Ray Bounces", 1, "X", b_srlay.name().c_str());
|
|
|
|
Pass::add(PASS_RAY_BOUNCES, passes);
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
|
|
|
return passes;
|
|
|
|
}
|
|
|
|
|
2011-04-27 11:58:34 +00:00
|
|
|
/* Scene Parameters */
|
|
|
|
|
2016-01-30 14:18:29 +01:00
|
|
|
SceneParams BlenderSync::get_scene_params(BL::Scene& b_scene,
|
2017-10-08 04:32:25 +02:00
|
|
|
bool background)
|
2011-04-27 11:58:34 +00:00
|
|
|
{
|
2012-11-09 23:54:58 +00:00
|
|
|
BL::RenderSettings r = b_scene.render();
|
2011-04-27 11:58:34 +00:00
|
|
|
SceneParams params;
|
|
|
|
PointerRNA cscene = RNA_pointer_get(&b_scene.ptr, "cycles");
|
2014-02-03 18:55:59 +11:00
|
|
|
const bool shadingsystem = RNA_boolean_get(&cscene, "shading_system");
|
2011-04-27 11:58:34 +00:00
|
|
|
|
|
|
|
if(shadingsystem == 0)
|
2014-05-19 13:49:36 +03:00
|
|
|
params.shadingsystem = SHADINGSYSTEM_SVM;
|
2011-04-27 11:58:34 +00:00
|
|
|
else if(shadingsystem == 1)
|
2014-05-19 13:49:36 +03:00
|
|
|
params.shadingsystem = SHADINGSYSTEM_OSL;
|
2011-04-27 11:58:34 +00:00
|
|
|
|
2017-08-21 15:09:03 +02:00
|
|
|
if(background || DebugFlags().viewport_static_bvh)
|
2014-05-19 13:49:36 +03:00
|
|
|
params.bvh_type = SceneParams::BVH_STATIC;
|
2011-11-04 15:46:15 +00:00
|
|
|
else
|
2017-08-21 15:09:03 +02:00
|
|
|
params.bvh_type = SceneParams::BVH_DYNAMIC;
|
2011-11-04 15:46:15 +00:00
|
|
|
|
2011-04-27 11:58:34 +00:00
|
|
|
params.use_bvh_spatial_split = RNA_boolean_get(&cscene, "debug_use_spatial_splits");
|
2016-07-07 18:04:16 +02:00
|
|
|
params.use_bvh_unaligned_nodes = RNA_boolean_get(&cscene, "debug_use_hair_bvh");
|
2017-01-17 15:13:01 +01:00
|
|
|
params.num_bvh_time_steps = RNA_int_get(&cscene, "debug_bvh_time_steps");
|
2011-04-27 11:58:34 +00:00
|
|
|
|
2014-05-19 13:49:36 +03:00
|
|
|
if(background && params.shadingsystem != SHADINGSYSTEM_OSL)
|
2013-02-14 16:48:43 +00:00
|
|
|
params.persistent_data = r.use_persistent_data();
|
2013-02-14 16:11:47 +00:00
|
|
|
else
|
2013-02-14 16:48:43 +00:00
|
|
|
params.persistent_data = false;
|
2012-11-09 08:46:53 +00:00
|
|
|
|
2016-11-17 12:13:22 +01:00
|
|
|
int texture_limit;
|
|
|
|
if(background) {
|
|
|
|
texture_limit = RNA_enum_get(&cscene, "texture_limit_render");
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
texture_limit = RNA_enum_get(&cscene, "texture_limit");
|
|
|
|
}
|
|
|
|
if(texture_limit > 0 && b_scene.render().use_simplify()) {
|
|
|
|
params.texture_limit = 1 << (texture_limit + 6);
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
params.texture_limit = 0;
|
|
|
|
}
|
|
|
|
|
2017-10-08 04:32:25 +02:00
|
|
|
params.use_qbvh = DebugFlags().cpu.qbvh;
|
2014-12-25 00:53:26 +05:00
|
|
|
|
2011-04-27 11:58:34 +00:00
|
|
|
return params;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Session Parameters */
|
|
|
|
|
2016-01-30 14:18:29 +01:00
|
|
|
bool BlenderSync::get_session_pause(BL::Scene& b_scene, bool background)
|
2011-08-29 16:54:13 +00:00
|
|
|
{
|
|
|
|
PointerRNA cscene = RNA_pointer_get(&b_scene.ptr, "cycles");
|
|
|
|
return (background)? false: get_boolean(cscene, "preview_pause");
|
|
|
|
}
|
|
|
|
|
2016-01-30 14:18:29 +01:00
|
|
|
SessionParams BlenderSync::get_session_params(BL::RenderEngine& b_engine,
|
|
|
|
BL::UserPreferences& b_userpref,
|
|
|
|
BL::Scene& b_scene,
|
2015-02-18 21:16:52 +05:00
|
|
|
bool background)
|
2011-04-27 11:58:34 +00:00
|
|
|
{
|
|
|
|
SessionParams params;
|
|
|
|
PointerRNA cscene = RNA_pointer_get(&b_scene.ptr, "cycles");
|
|
|
|
|
2011-12-01 16:33:21 +00:00
|
|
|
/* feature set */
|
2016-02-10 03:25:53 +05:00
|
|
|
params.experimental = (get_enum(cscene, "feature_set") != 0);
|
2011-12-01 16:33:21 +00:00
|
|
|
|
2017-10-21 18:58:59 +02:00
|
|
|
/* threads */
|
2017-10-10 02:28:23 +02:00
|
|
|
BL::RenderSettings b_r = b_scene.render();
|
|
|
|
if(b_r.threads_mode() == BL::RenderSettings::threads_mode_FIXED)
|
|
|
|
params.threads = b_r.threads();
|
2017-10-21 18:58:59 +02:00
|
|
|
else
|
|
|
|
params.threads = 0;
|
|
|
|
|
|
|
|
/* Background */
|
|
|
|
params.background = background;
|
|
|
|
|
2011-04-27 11:58:34 +00:00
|
|
|
/* device type */
|
2012-01-09 16:58:01 +00:00
|
|
|
vector<DeviceInfo>& devices = Device::available_devices();
|
|
|
|
|
|
|
|
/* device default CPU */
|
Cycles: Refactor Device selection to allow individual GPU compute device selection
Previously, it was only possible to choose a single GPU or all of that type (CUDA or OpenCL).
Now, a toggle button is displayed for every device.
These settings are tied to the PCI Bus ID of the devices, so they're consistent across hardware addition and removal (but not when swapping/moving cards).
From the code perspective, the more important change is that now, the compute device properties are stored in the Addon preferences of the Cycles addon, instead of directly in the User Preferences.
This allows for a cleaner implementation, removing the Cycles C API functions that were called by the RNA code to specify the enum items.
Note that this change is neither backwards- nor forwards-compatible, but since it's only a User Preference no existing files are broken.
Reviewers: #cycles, brecht
Reviewed By: #cycles, brecht
Subscribers: brecht, juicyfruit, mib2berlin, Blendify
Differential Revision: https://developer.blender.org/D2338
2016-11-07 02:33:53 +01:00
|
|
|
foreach(DeviceInfo& device, devices) {
|
|
|
|
if(device.type == DEVICE_CPU) {
|
|
|
|
params.device = device;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
2011-04-27 11:58:34 +00:00
|
|
|
|
2016-02-10 03:25:53 +05:00
|
|
|
if(get_enum(cscene, "device") == 2) {
|
2012-12-21 11:13:46 +00:00
|
|
|
/* find network device */
|
|
|
|
foreach(DeviceInfo& info, devices)
|
|
|
|
if(info.type == DEVICE_NETWORK)
|
|
|
|
params.device = info;
|
|
|
|
}
|
2016-02-10 03:25:53 +05:00
|
|
|
else if(get_enum(cscene, "device") == 1) {
|
Cycles: Refactor Device selection to allow individual GPU compute device selection
Previously, it was only possible to choose a single GPU or all of that type (CUDA or OpenCL).
Now, a toggle button is displayed for every device.
These settings are tied to the PCI Bus ID of the devices, so they're consistent across hardware addition and removal (but not when swapping/moving cards).
From the code perspective, the more important change is that now, the compute device properties are stored in the Addon preferences of the Cycles addon, instead of directly in the User Preferences.
This allows for a cleaner implementation, removing the Cycles C API functions that were called by the RNA code to specify the enum items.
Note that this change is neither backwards- nor forwards-compatible, but since it's only a User Preference no existing files are broken.
Reviewers: #cycles, brecht
Reviewed By: #cycles, brecht
Subscribers: brecht, juicyfruit, mib2berlin, Blendify
Differential Revision: https://developer.blender.org/D2338
2016-11-07 02:33:53 +01:00
|
|
|
PointerRNA b_preferences;
|
2012-01-09 16:58:01 +00:00
|
|
|
|
Cycles: Refactor Device selection to allow individual GPU compute device selection
Previously, it was only possible to choose a single GPU or all of that type (CUDA or OpenCL).
Now, a toggle button is displayed for every device.
These settings are tied to the PCI Bus ID of the devices, so they're consistent across hardware addition and removal (but not when swapping/moving cards).
From the code perspective, the more important change is that now, the compute device properties are stored in the Addon preferences of the Cycles addon, instead of directly in the User Preferences.
This allows for a cleaner implementation, removing the Cycles C API functions that were called by the RNA code to specify the enum items.
Note that this change is neither backwards- nor forwards-compatible, but since it's only a User Preference no existing files are broken.
Reviewers: #cycles, brecht
Reviewed By: #cycles, brecht
Subscribers: brecht, juicyfruit, mib2berlin, Blendify
Differential Revision: https://developer.blender.org/D2338
2016-11-07 02:33:53 +01:00
|
|
|
BL::UserPreferences::addons_iterator b_addon_iter;
|
|
|
|
for(b_userpref.addons.begin(b_addon_iter); b_addon_iter != b_userpref.addons.end(); ++b_addon_iter) {
|
|
|
|
if(b_addon_iter->module() == "cycles") {
|
|
|
|
b_preferences = b_addon_iter->preferences().ptr;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
2012-01-09 16:58:01 +00:00
|
|
|
|
2017-10-21 18:58:59 +02:00
|
|
|
enum ComputeDevice {
|
|
|
|
COMPUTE_DEVICE_CPU = 0,
|
|
|
|
COMPUTE_DEVICE_CUDA = 1,
|
|
|
|
COMPUTE_DEVICE_OPENCL = 2,
|
|
|
|
COMPUTE_DEVICE_NUM = 3,
|
|
|
|
};
|
Cycles: Refactor Device selection to allow individual GPU compute device selection
Previously, it was only possible to choose a single GPU or all of that type (CUDA or OpenCL).
Now, a toggle button is displayed for every device.
These settings are tied to the PCI Bus ID of the devices, so they're consistent across hardware addition and removal (but not when swapping/moving cards).
From the code perspective, the more important change is that now, the compute device properties are stored in the Addon preferences of the Cycles addon, instead of directly in the User Preferences.
This allows for a cleaner implementation, removing the Cycles C API functions that were called by the RNA code to specify the enum items.
Note that this change is neither backwards- nor forwards-compatible, but since it's only a User Preference no existing files are broken.
Reviewers: #cycles, brecht
Reviewed By: #cycles, brecht
Subscribers: brecht, juicyfruit, mib2berlin, Blendify
Differential Revision: https://developer.blender.org/D2338
2016-11-07 02:33:53 +01:00
|
|
|
|
2017-10-21 18:58:59 +02:00
|
|
|
ComputeDevice compute_device = (ComputeDevice)get_enum(b_preferences,
|
|
|
|
"compute_device_type",
|
|
|
|
COMPUTE_DEVICE_NUM,
|
|
|
|
COMPUTE_DEVICE_CPU);
|
|
|
|
|
|
|
|
if(compute_device != COMPUTE_DEVICE_CPU) {
|
Cycles: Refactor Device selection to allow individual GPU compute device selection
Previously, it was only possible to choose a single GPU or all of that type (CUDA or OpenCL).
Now, a toggle button is displayed for every device.
These settings are tied to the PCI Bus ID of the devices, so they're consistent across hardware addition and removal (but not when swapping/moving cards).
From the code perspective, the more important change is that now, the compute device properties are stored in the Addon preferences of the Cycles addon, instead of directly in the User Preferences.
This allows for a cleaner implementation, removing the Cycles C API functions that were called by the RNA code to specify the enum items.
Note that this change is neither backwards- nor forwards-compatible, but since it's only a User Preference no existing files are broken.
Reviewers: #cycles, brecht
Reviewed By: #cycles, brecht
Subscribers: brecht, juicyfruit, mib2berlin, Blendify
Differential Revision: https://developer.blender.org/D2338
2016-11-07 02:33:53 +01:00
|
|
|
vector<DeviceInfo> used_devices;
|
|
|
|
RNA_BEGIN(&b_preferences, device, "devices") {
|
2017-10-21 18:58:59 +02:00
|
|
|
ComputeDevice device_type = (ComputeDevice)get_enum(device,
|
|
|
|
"type",
|
|
|
|
COMPUTE_DEVICE_NUM,
|
|
|
|
COMPUTE_DEVICE_CPU);
|
|
|
|
|
|
|
|
if(get_boolean(device, "use") &&
|
|
|
|
(device_type == compute_device || device_type == COMPUTE_DEVICE_CPU)) {
|
Cycles: Refactor Device selection to allow individual GPU compute device selection
Previously, it was only possible to choose a single GPU or all of that type (CUDA or OpenCL).
Now, a toggle button is displayed for every device.
These settings are tied to the PCI Bus ID of the devices, so they're consistent across hardware addition and removal (but not when swapping/moving cards).
From the code perspective, the more important change is that now, the compute device properties are stored in the Addon preferences of the Cycles addon, instead of directly in the User Preferences.
This allows for a cleaner implementation, removing the Cycles C API functions that were called by the RNA code to specify the enum items.
Note that this change is neither backwards- nor forwards-compatible, but since it's only a User Preference no existing files are broken.
Reviewers: #cycles, brecht
Reviewed By: #cycles, brecht
Subscribers: brecht, juicyfruit, mib2berlin, Blendify
Differential Revision: https://developer.blender.org/D2338
2016-11-07 02:33:53 +01:00
|
|
|
string id = get_string(device, "id");
|
|
|
|
foreach(DeviceInfo& info, devices) {
|
|
|
|
if(info.id == id) {
|
|
|
|
used_devices.push_back(info);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
} RNA_END
|
|
|
|
|
|
|
|
if(used_devices.size() == 1) {
|
|
|
|
params.device = used_devices[0];
|
|
|
|
}
|
|
|
|
else if(used_devices.size() > 1) {
|
2017-10-21 18:58:59 +02:00
|
|
|
params.device = Device::get_multi_device(used_devices,
|
|
|
|
params.threads,
|
|
|
|
params.background);
|
Cycles: Refactor Device selection to allow individual GPU compute device selection
Previously, it was only possible to choose a single GPU or all of that type (CUDA or OpenCL).
Now, a toggle button is displayed for every device.
These settings are tied to the PCI Bus ID of the devices, so they're consistent across hardware addition and removal (but not when swapping/moving cards).
From the code perspective, the more important change is that now, the compute device properties are stored in the Addon preferences of the Cycles addon, instead of directly in the User Preferences.
This allows for a cleaner implementation, removing the Cycles C API functions that were called by the RNA code to specify the enum items.
Note that this change is neither backwards- nor forwards-compatible, but since it's only a User Preference no existing files are broken.
Reviewers: #cycles, brecht
Reviewed By: #cycles, brecht
Subscribers: brecht, juicyfruit, mib2berlin, Blendify
Differential Revision: https://developer.blender.org/D2338
2016-11-07 02:33:53 +01:00
|
|
|
}
|
|
|
|
/* Else keep using the CPU device that was set before. */
|
2012-01-09 16:58:01 +00:00
|
|
|
}
|
2011-09-01 19:43:57 +00:00
|
|
|
}
|
2012-01-04 18:06:32 +00:00
|
|
|
|
2011-09-16 13:14:02 +00:00
|
|
|
/* samples */
|
2013-07-19 22:51:48 +00:00
|
|
|
int samples = get_int(cscene, "samples");
|
|
|
|
int aa_samples = get_int(cscene, "aa_samples");
|
|
|
|
int preview_samples = get_int(cscene, "preview_samples");
|
|
|
|
int preview_aa_samples = get_int(cscene, "preview_aa_samples");
|
|
|
|
|
2017-08-20 23:46:05 +02:00
|
|
|
if(get_boolean(cscene, "use_square_samples")) {
|
|
|
|
aa_samples = aa_samples * aa_samples;
|
|
|
|
preview_aa_samples = preview_aa_samples * preview_aa_samples;
|
|
|
|
|
|
|
|
samples = samples * samples;
|
|
|
|
preview_samples = preview_samples * preview_samples;
|
|
|
|
}
|
|
|
|
|
2013-08-24 00:27:20 +00:00
|
|
|
if(get_enum(cscene, "progressive") == 0) {
|
2012-06-13 11:44:48 +00:00
|
|
|
if(background) {
|
2013-07-19 22:51:48 +00:00
|
|
|
params.samples = aa_samples;
|
2012-06-13 11:44:48 +00:00
|
|
|
}
|
|
|
|
else {
|
2013-07-19 22:51:48 +00:00
|
|
|
params.samples = preview_aa_samples;
|
2012-06-13 11:44:48 +00:00
|
|
|
if(params.samples == 0)
|
2016-03-11 21:33:56 +01:00
|
|
|
params.samples = INT_MAX;
|
2012-06-13 11:44:48 +00:00
|
|
|
}
|
2011-08-28 13:55:59 +00:00
|
|
|
}
|
|
|
|
else {
|
2012-06-13 11:44:48 +00:00
|
|
|
if(background) {
|
2013-07-19 22:51:48 +00:00
|
|
|
params.samples = samples;
|
2012-06-13 11:44:48 +00:00
|
|
|
}
|
|
|
|
else {
|
2013-07-19 22:51:48 +00:00
|
|
|
params.samples = preview_samples;
|
2012-06-13 11:44:48 +00:00
|
|
|
if(params.samples == 0)
|
2016-03-11 21:33:56 +01:00
|
|
|
params.samples = INT_MAX;
|
2012-06-13 11:44:48 +00:00
|
|
|
}
|
2011-08-28 13:55:59 +00:00
|
|
|
}
|
2011-04-27 11:58:34 +00:00
|
|
|
|
2012-09-04 13:29:07 +00:00
|
|
|
/* tiles */
|
|
|
|
if(params.device.type != DEVICE_CPU && !background) {
|
|
|
|
/* currently GPU could be much slower than CPU when using tiles,
|
|
|
|
* still need to be investigated, but meanwhile make it possible
|
|
|
|
* to work in viewport smoothly
|
|
|
|
*/
|
|
|
|
int debug_tile_size = get_int(cscene, "debug_tile_size");
|
|
|
|
|
|
|
|
params.tile_size = make_int2(debug_tile_size, debug_tile_size);
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
int tile_x = b_engine.tile_x();
|
|
|
|
int tile_y = b_engine.tile_y();
|
|
|
|
|
|
|
|
params.tile_size = make_int2(tile_x, tile_y);
|
|
|
|
}
|
2015-02-17 16:23:03 +05:00
|
|
|
|
2016-01-01 23:52:37 +01:00
|
|
|
if((BlenderSession::headless == false) && background) {
|
2016-02-10 03:25:53 +05:00
|
|
|
params.tile_order = (TileOrder)get_enum(cscene, "tile_order");
|
2015-02-17 16:23:03 +05:00
|
|
|
}
|
|
|
|
else {
|
|
|
|
params.tile_order = TILE_BOTTOM_TO_TOP;
|
|
|
|
}
|
2012-09-04 13:29:07 +00:00
|
|
|
|
2017-10-21 18:58:59 +02:00
|
|
|
/* other parameters */
|
2012-09-17 10:55:18 +00:00
|
|
|
params.start_resolution = get_int(cscene, "preview_start_resolution");
|
2017-08-15 00:11:52 +02:00
|
|
|
params.pixel_size = b_engine.get_preview_pixel_size(b_scene);
|
2012-09-04 13:29:07 +00:00
|
|
|
|
2017-10-10 02:28:23 +02:00
|
|
|
/* other parameters */
|
2016-05-22 19:11:26 +02:00
|
|
|
params.cancel_timeout = (double)get_float(cscene, "debug_cancel_timeout");
|
|
|
|
params.reset_timeout = (double)get_float(cscene, "debug_reset_timeout");
|
|
|
|
params.text_timeout = (double)get_float(cscene, "debug_text_timeout");
|
2011-04-27 11:58:34 +00:00
|
|
|
|
2017-10-10 02:28:23 +02:00
|
|
|
/* progressive refine */
|
|
|
|
params.progressive_refine = get_boolean(cscene, "use_progressive_refine") &&
|
|
|
|
!b_r.use_save_buffers();
|
|
|
|
|
|
|
|
if(params.progressive_refine) {
|
|
|
|
BL::RenderSettings::layers_iterator b_rlay;
|
|
|
|
for(b_r.layers.begin(b_rlay); b_rlay != b_r.layers.end(); ++b_rlay) {
|
|
|
|
PointerRNA crl = RNA_pointer_get(&b_rlay->ptr, "cycles");
|
|
|
|
if(get_boolean(crl, "use_denoising")) {
|
|
|
|
params.progressive_refine = false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2012-10-13 12:38:32 +00:00
|
|
|
|
2011-04-27 11:58:34 +00:00
|
|
|
if(background) {
|
2012-10-13 12:38:32 +00:00
|
|
|
if(params.progressive_refine)
|
|
|
|
params.progressive = true;
|
|
|
|
else
|
|
|
|
params.progressive = false;
|
|
|
|
|
2012-09-17 10:55:18 +00:00
|
|
|
params.start_resolution = INT_MAX;
|
2017-08-15 00:11:52 +02:00
|
|
|
params.pixel_size = 1;
|
2011-04-27 11:58:34 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
params.progressive = true;
|
2012-10-26 09:25:02 +00:00
|
|
|
|
|
|
|
/* shading system - scene level needs full refresh */
|
2014-02-03 18:55:59 +11:00
|
|
|
const bool shadingsystem = RNA_boolean_get(&cscene, "shading_system");
|
2012-10-26 09:25:02 +00:00
|
|
|
|
|
|
|
if(shadingsystem == 0)
|
2014-05-19 13:49:36 +03:00
|
|
|
params.shadingsystem = SHADINGSYSTEM_SVM;
|
2012-10-26 09:25:02 +00:00
|
|
|
else if(shadingsystem == 1)
|
2014-05-19 13:49:36 +03:00
|
|
|
params.shadingsystem = SHADINGSYSTEM_OSL;
|
2013-08-30 23:49:38 +00:00
|
|
|
|
|
|
|
/* color managagement */
|
2014-10-31 22:28:39 +05:00
|
|
|
#ifdef GLEW_MX
|
|
|
|
/* When using GLEW MX we need to check whether we've got an OpenGL
|
2014-11-14 14:55:45 +01:00
|
|
|
* context for current window. This is because command line rendering
|
2014-10-31 22:28:39 +05:00
|
|
|
* doesn't have OpenGL context actually.
|
|
|
|
*/
|
|
|
|
if(glewGetContext() != NULL)
|
|
|
|
#endif
|
|
|
|
{
|
|
|
|
params.display_buffer_linear = GLEW_ARB_half_float_pixel &&
|
|
|
|
b_engine.support_display_space_shader(b_scene);
|
|
|
|
}
|
2012-10-26 09:25:02 +00:00
|
|
|
|
2015-02-21 17:29:27 +05:00
|
|
|
if(b_engine.is_preview()) {
|
|
|
|
/* For preview rendering we're using same timeout as
|
|
|
|
* blender's job update.
|
|
|
|
*/
|
|
|
|
params.progressive_update_timeout = 0.1;
|
|
|
|
}
|
|
|
|
|
2011-04-27 11:58:34 +00:00
|
|
|
return params;
|
|
|
|
}
|
|
|
|
|
|
|
|
CCL_NAMESPACE_END
|
|
|
|
|