Blender  V2.93
blender_sync.cpp
Go to the documentation of this file.
1 /*
2  * Copyright 2011-2013 Blender Foundation
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16 
17 #include "render/background.h"
18 #include "render/camera.h"
19 #include "render/curves.h"
20 #include "render/film.h"
21 #include "render/graph.h"
22 #include "render/integrator.h"
23 #include "render/light.h"
24 #include "render/mesh.h"
25 #include "render/nodes.h"
26 #include "render/object.h"
27 #include "render/procedural.h"
28 #include "render/scene.h"
29 #include "render/shader.h"
30 
31 #include "device/device.h"
32 
33 #include "blender/blender_device.h"
35 #include "blender/blender_sync.h"
36 #include "blender/blender_util.h"
37 
38 #include "util/util_debug.h"
39 #include "util/util_foreach.h"
40 #include "util/util_hash.h"
41 #include "util/util_logging.h"
42 #include "util/util_opengl.h"
44 
46 
47 static const char *cryptomatte_prefix = "Crypto";
48 
49 /* Constructor */
50 
52  BL::BlendData &b_data,
53  BL::Scene &b_scene,
54  Scene *scene,
55  bool preview,
56  Progress &progress)
57  : b_engine(b_engine),
58  b_data(b_data),
59  b_scene(b_scene),
60  shader_map(scene),
61  object_map(scene),
62  geometry_map(scene),
63  light_map(scene),
64  particle_system_map(scene),
65  world_map(NULL),
66  world_recalc(false),
67  scene(scene),
68  preview(preview),
69  experimental(false),
70  dicing_rate(1.0f),
71  max_subdivisions(12),
72  progress(progress),
73  has_updates_(true)
74 {
75  PointerRNA cscene = RNA_pointer_get(&b_scene.ptr, "cycles");
76  dicing_rate = preview ? RNA_float_get(&cscene, "preview_dicing_rate") :
77  RNA_float_get(&cscene, "dicing_rate");
78  max_subdivisions = RNA_int_get(&cscene, "max_subdivisions");
79 }
80 
82 {
83 }
84 
85 void BlenderSync::reset(BL::BlendData &b_data, BL::Scene &b_scene)
86 {
87  /* Update data and scene pointers in case they change in session reset,
88  * for example after undo.
89  * Note that we do not modify the `has_updates_` flag here because the sync
90  * reset is also used during viewport navigation. */
91  this->b_data = b_data;
92  this->b_scene = b_scene;
93 }
94 
96 {
97  has_updates_ = true;
98 }
99 
100 /* Sync */
101 
102 void BlenderSync::sync_recalc(BL::Depsgraph &b_depsgraph, BL::SpaceView3D &b_v3d)
103 {
104  /* Sync recalc flags from blender to cycles. Actual update is done separate,
105  * so we can do it later on if doing it immediate is not suitable. */
106 
107  if (experimental) {
108  /* Mark all meshes as needing to be exported again if dicing changed. */
109  PointerRNA cscene = RNA_pointer_get(&b_scene.ptr, "cycles");
110  bool dicing_prop_changed = false;
111 
112  float updated_dicing_rate = preview ? RNA_float_get(&cscene, "preview_dicing_rate") :
113  RNA_float_get(&cscene, "dicing_rate");
114 
115  if (dicing_rate != updated_dicing_rate) {
116  dicing_rate = updated_dicing_rate;
117  dicing_prop_changed = true;
118  }
119 
120  int updated_max_subdivisions = RNA_int_get(&cscene, "max_subdivisions");
121 
122  if (max_subdivisions != updated_max_subdivisions) {
123  max_subdivisions = updated_max_subdivisions;
124  dicing_prop_changed = true;
125  }
126 
127  if (dicing_prop_changed) {
128  has_updates_ = true;
129 
130  for (const pair<const GeometryKey, Geometry *> &iter : geometry_map.key_to_scene_data()) {
131  Geometry *geom = iter.second;
132  if (geom->is_mesh()) {
133  Mesh *mesh = static_cast<Mesh *>(geom);
134  if (mesh->get_subdivision_type() != Mesh::SUBDIVISION_NONE) {
135  PointerRNA id_ptr;
136  RNA_id_pointer_create((::ID *)iter.first.id, &id_ptr);
137  geometry_map.set_recalc(BL::ID(id_ptr));
138  }
139  }
140  }
141  }
142  }
143 
144  /* Iterate over all IDs in this depsgraph. */
145  for (BL::DepsgraphUpdate &b_update : b_depsgraph.updates) {
146  /* TODO(sergey): Can do more selective filter here. For example, ignore changes made to
147  * screen datablock. Note that sync_data() needs to be called after object deletion, and
148  * currently this is ensured by the scene ID tagged for update, which sets the `has_updates_`
149  * flag. */
150  has_updates_ = true;
151 
152  BL::ID b_id(b_update.id());
153 
154  /* Material */
155  if (b_id.is_a(&RNA_Material)) {
156  BL::Material b_mat(b_id);
157  shader_map.set_recalc(b_mat);
158  }
159  /* Light */
160  else if (b_id.is_a(&RNA_Light)) {
161  BL::Light b_light(b_id);
162  shader_map.set_recalc(b_light);
163  }
164  /* Object */
165  else if (b_id.is_a(&RNA_Object)) {
166  BL::Object b_ob(b_id);
167  const bool is_geometry = object_is_geometry(b_ob);
168  const bool is_light = !is_geometry && object_is_light(b_ob);
169 
170  if (b_ob.is_instancer() && b_update.is_updated_shading()) {
171  /* Needed for e.g. object color updates on instancer. */
172  object_map.set_recalc(b_ob);
173  }
174 
175  if (is_geometry || is_light) {
176  const bool updated_geometry = b_update.is_updated_geometry();
177 
178  /* Geometry (mesh, hair, volume). */
179  if (is_geometry) {
180  if (b_update.is_updated_transform() || b_update.is_updated_shading()) {
181  object_map.set_recalc(b_ob);
182  }
183 
184  if (updated_geometry ||
185  (object_subdivision_type(b_ob, preview, experimental) != Mesh::SUBDIVISION_NONE)) {
186  BL::ID key = BKE_object_is_modified(b_ob) ? b_ob : b_ob.data();
187  geometry_map.set_recalc(key);
188  }
189 
190  if (updated_geometry) {
191  BL::Object::particle_systems_iterator b_psys;
192  for (b_ob.particle_systems.begin(b_psys); b_psys != b_ob.particle_systems.end();
193  ++b_psys) {
194  particle_system_map.set_recalc(b_ob);
195  }
196  }
197  }
198  /* Light */
199  else if (is_light) {
200  if (b_update.is_updated_transform() || b_update.is_updated_shading()) {
201  object_map.set_recalc(b_ob);
202  light_map.set_recalc(b_ob);
203  }
204 
205  if (updated_geometry) {
206  light_map.set_recalc(b_ob);
207  }
208  }
209  }
210  }
211  /* Mesh */
212  else if (b_id.is_a(&RNA_Mesh)) {
213  BL::Mesh b_mesh(b_id);
214  geometry_map.set_recalc(b_mesh);
215  }
216  /* World */
217  else if (b_id.is_a(&RNA_World)) {
218  BL::World b_world(b_id);
219  if (world_map == b_world.ptr.data) {
220  world_recalc = true;
221  }
222  }
223  /* Volume */
224  else if (b_id.is_a(&RNA_Volume)) {
225  BL::Volume b_volume(b_id);
226  geometry_map.set_recalc(b_volume);
227  }
228  }
229 
230  if (b_v3d) {
231  BlenderViewportParameters new_viewport_parameters(b_v3d);
232 
233  if (viewport_parameters.modified(new_viewport_parameters)) {
234  world_recalc = true;
235  has_updates_ = true;
236  }
237 
238  if (!has_updates_) {
239  Film *film = scene->film;
240 
241  const PassType new_display_pass = new_viewport_parameters.get_viewport_display_render_pass(
242  b_v3d);
243  has_updates_ |= film->get_display_pass() != new_display_pass;
244  }
245  }
246 }
247 
248 void BlenderSync::sync_data(BL::RenderSettings &b_render,
249  BL::Depsgraph &b_depsgraph,
250  BL::SpaceView3D &b_v3d,
251  BL::Object &b_override,
252  int width,
253  int height,
254  void **python_thread_state)
255 {
256  if (!has_updates_) {
257  return;
258  }
259 
260  scoped_timer timer;
261 
262  BL::ViewLayer b_view_layer = b_depsgraph.view_layer_eval();
263 
264  sync_view_layer(b_v3d, b_view_layer);
265  sync_integrator();
266  sync_film(b_v3d);
267  sync_shaders(b_depsgraph, b_v3d);
268  sync_images();
269 
270  geometry_synced.clear(); /* use for objects and motion sync */
271 
272  if (scene->need_motion() == Scene::MOTION_PASS || scene->need_motion() == Scene::MOTION_NONE ||
273  scene->camera->get_motion_position() == Camera::MOTION_POSITION_CENTER) {
274  sync_objects(b_depsgraph, b_v3d);
275  }
276  sync_motion(b_render, b_depsgraph, b_v3d, b_override, width, height, python_thread_state);
277 
278  geometry_synced.clear();
279 
280  /* Shader sync done at the end, since object sync uses it.
281  * false = don't delete unused shaders, not supported. */
282  shader_map.post_sync(false);
283 
284  free_data_after_sync(b_depsgraph);
285 
286  VLOG(1) << "Total time spent synchronizing data: " << timer.get_time();
287 
288  has_updates_ = false;
289 }
290 
291 /* Integrator */
292 
294 {
295  BL::RenderSettings r = b_scene.render();
296  PointerRNA cscene = RNA_pointer_get(&b_scene.ptr, "cycles");
297 
298  experimental = (get_enum(cscene, "feature_set") != 0);
299 
300  Integrator *integrator = scene->integrator;
301 
302  integrator->set_min_bounce(get_int(cscene, "min_light_bounces"));
303  integrator->set_max_bounce(get_int(cscene, "max_bounces"));
304 
305  integrator->set_max_diffuse_bounce(get_int(cscene, "diffuse_bounces"));
306  integrator->set_max_glossy_bounce(get_int(cscene, "glossy_bounces"));
307  integrator->set_max_transmission_bounce(get_int(cscene, "transmission_bounces"));
308  integrator->set_max_volume_bounce(get_int(cscene, "volume_bounces"));
309 
310  integrator->set_transparent_min_bounce(get_int(cscene, "min_transparent_bounces"));
311  integrator->set_transparent_max_bounce(get_int(cscene, "transparent_max_bounces"));
312 
313  integrator->set_volume_max_steps(get_int(cscene, "volume_max_steps"));
314  float volume_step_rate = (preview) ? get_float(cscene, "volume_preview_step_rate") :
315  get_float(cscene, "volume_step_rate");
316  integrator->set_volume_step_rate(volume_step_rate);
317 
318  integrator->set_caustics_reflective(get_boolean(cscene, "caustics_reflective"));
319  integrator->set_caustics_refractive(get_boolean(cscene, "caustics_refractive"));
320  integrator->set_filter_glossy(get_float(cscene, "blur_glossy"));
321 
322  int seed = get_int(cscene, "seed");
323  if (get_boolean(cscene, "use_animated_seed")) {
324  seed = hash_uint2(b_scene.frame_current(), get_int(cscene, "seed"));
325  if (b_scene.frame_subframe() != 0.0f) {
326  /* TODO(sergey): Ideally should be some sort of hash_merge,
327  * but this is good enough for now.
328  */
329  seed += hash_uint2((int)(b_scene.frame_subframe() * (float)INT_MAX),
330  get_int(cscene, "seed"));
331  }
332  }
333 
334  integrator->set_seed(seed);
335 
336  integrator->set_sample_clamp_direct(get_float(cscene, "sample_clamp_direct"));
337  integrator->set_sample_clamp_indirect(get_float(cscene, "sample_clamp_indirect"));
338  if (!preview) {
339  integrator->set_motion_blur(r.use_motion_blur());
340  }
341 
342  integrator->set_method((Integrator::Method)get_enum(
343  cscene, "progressive", Integrator::NUM_METHODS, Integrator::PATH));
344 
345  integrator->set_sample_all_lights_direct(get_boolean(cscene, "sample_all_lights_direct"));
346  integrator->set_sample_all_lights_indirect(get_boolean(cscene, "sample_all_lights_indirect"));
347  integrator->set_light_sampling_threshold(get_float(cscene, "light_sampling_threshold"));
348 
349  SamplingPattern sampling_pattern = (SamplingPattern)get_enum(
350  cscene, "sampling_pattern", SAMPLING_NUM_PATTERNS, SAMPLING_PATTERN_SOBOL);
351 
352  int adaptive_min_samples = INT_MAX;
353 
354  if (RNA_boolean_get(&cscene, "use_adaptive_sampling")) {
355  sampling_pattern = SAMPLING_PATTERN_PMJ;
356  adaptive_min_samples = get_int(cscene, "adaptive_min_samples");
357  integrator->set_adaptive_threshold(get_float(cscene, "adaptive_threshold"));
358  }
359  else {
360  integrator->set_adaptive_threshold(0.0f);
361  }
362 
363  integrator->set_sampling_pattern(sampling_pattern);
364 
365  int diffuse_samples = get_int(cscene, "diffuse_samples");
366  int glossy_samples = get_int(cscene, "glossy_samples");
367  int transmission_samples = get_int(cscene, "transmission_samples");
368  int ao_samples = get_int(cscene, "ao_samples");
369  int mesh_light_samples = get_int(cscene, "mesh_light_samples");
370  int subsurface_samples = get_int(cscene, "subsurface_samples");
371  int volume_samples = get_int(cscene, "volume_samples");
372 
373  if (get_boolean(cscene, "use_square_samples")) {
374  integrator->set_diffuse_samples(diffuse_samples * diffuse_samples);
375  integrator->set_glossy_samples(glossy_samples * glossy_samples);
376  integrator->set_transmission_samples(transmission_samples * transmission_samples);
377  integrator->set_ao_samples(ao_samples * ao_samples);
378  integrator->set_mesh_light_samples(mesh_light_samples * mesh_light_samples);
379  integrator->set_subsurface_samples(subsurface_samples * subsurface_samples);
380  integrator->set_volume_samples(volume_samples * volume_samples);
381  adaptive_min_samples = min(adaptive_min_samples * adaptive_min_samples, INT_MAX);
382  }
383  else {
384  integrator->set_diffuse_samples(diffuse_samples);
385  integrator->set_glossy_samples(glossy_samples);
386  integrator->set_transmission_samples(transmission_samples);
387  integrator->set_ao_samples(ao_samples);
388  integrator->set_mesh_light_samples(mesh_light_samples);
389  integrator->set_subsurface_samples(subsurface_samples);
390  integrator->set_volume_samples(volume_samples);
391  }
392 
393  integrator->set_adaptive_min_samples(adaptive_min_samples);
394 
395  if (get_boolean(cscene, "use_fast_gi")) {
396  if (preview) {
397  integrator->set_ao_bounces(get_int(cscene, "ao_bounces"));
398  }
399  else {
400  integrator->set_ao_bounces(get_int(cscene, "ao_bounces_render"));
401  }
402  }
403  else {
404  integrator->set_ao_bounces(0);
405  }
406 
407  /* UPDATE_NONE as we don't want to tag the integrator as modified, just tag dependent things */
408  integrator->tag_update(scene, Integrator::UPDATE_NONE);
409 }
410 
411 /* Film */
412 
413 void BlenderSync::sync_film(BL::SpaceView3D &b_v3d)
414 {
415  PointerRNA cscene = RNA_pointer_get(&b_scene.ptr, "cycles");
416 
417  Film *film = scene->film;
418 
419  vector<Pass> prevpasses = scene->passes;
420 
421  if (b_v3d) {
422  film->set_display_pass(update_viewport_display_passes(b_v3d, scene->passes));
423  }
424 
425  film->set_exposure(get_float(cscene, "film_exposure"));
426  film->set_filter_type(
427  (FilterType)get_enum(cscene, "pixel_filter_type", FILTER_NUM_TYPES, FILTER_BLACKMAN_HARRIS));
428  float filter_width = (film->get_filter_type() == FILTER_BOX) ? 1.0f :
429  get_float(cscene, "filter_width");
430  film->set_filter_width(filter_width);
431 
432  if (b_scene.world()) {
433  BL::WorldMistSettings b_mist = b_scene.world().mist_settings();
434 
435  film->set_mist_start(b_mist.start());
436  film->set_mist_depth(b_mist.depth());
437 
438  switch (b_mist.falloff()) {
439  case BL::WorldMistSettings::falloff_QUADRATIC:
440  film->set_mist_falloff(2.0f);
441  break;
442  case BL::WorldMistSettings::falloff_LINEAR:
443  film->set_mist_falloff(1.0f);
444  break;
445  case BL::WorldMistSettings::falloff_INVERSE_QUADRATIC:
446  film->set_mist_falloff(0.5f);
447  break;
448  }
449  }
450 
451  if (!Pass::equals(prevpasses, scene->passes)) {
452  film->tag_passes_update(scene, prevpasses, false);
453  film->tag_modified();
454  }
455 }
456 
457 /* Render Layer */
458 
459 void BlenderSync::sync_view_layer(BL::SpaceView3D & /*b_v3d*/, BL::ViewLayer &b_view_layer)
460 {
461  view_layer.name = b_view_layer.name();
462 
463  /* Filter. */
464  view_layer.use_background_shader = b_view_layer.use_sky();
465  view_layer.use_background_ao = b_view_layer.use_ao();
466  /* Always enable surfaces for baking, otherwise there is nothing to bake to. */
467  view_layer.use_surfaces = b_view_layer.use_solid() || scene->bake_manager->get_baking();
468  view_layer.use_hair = b_view_layer.use_strand();
469  view_layer.use_volumes = b_view_layer.use_volumes();
470 
471  /* Material override. */
472  view_layer.material_override = b_view_layer.material_override();
473 
474  /* Sample override. */
475  PointerRNA cscene = RNA_pointer_get(&b_scene.ptr, "cycles");
476  int use_layer_samples = get_enum(cscene, "use_layer_samples");
477 
478  view_layer.bound_samples = (use_layer_samples == 1);
479  view_layer.samples = 0;
480 
481  if (use_layer_samples != 2) {
482  int samples = b_view_layer.samples();
483  if (get_boolean(cscene, "use_square_samples"))
484  view_layer.samples = samples * samples;
485  else
486  view_layer.samples = samples;
487  }
488 }
489 
490 /* Images */
491 void BlenderSync::sync_images()
492 {
493  /* Sync is a convention for this API, but currently it frees unused buffers. */
494 
495  const bool is_interface_locked = b_engine.render() && b_engine.render().use_lock_interface();
496  if (is_interface_locked == false && BlenderSession::headless == false) {
497  /* If interface is not locked, it's possible image is needed for
498  * the display.
499  */
500  return;
501  }
502  /* Free buffers used by images which are not needed for render. */
503  for (BL::Image &b_image : b_data.images) {
504  /* TODO(sergey): Consider making it an utility function to check
505  * whether image is considered builtin.
506  */
507  const bool is_builtin = b_image.packed_file() ||
508  b_image.source() == BL::Image::source_GENERATED ||
509  b_image.source() == BL::Image::source_MOVIE || b_engine.is_preview();
510  if (is_builtin == false) {
511  b_image.buffers_free();
512  }
513  /* TODO(sergey): Free builtin images not used by any shader. */
514  }
515 }
516 
517 /* Passes */
519 {
520  string name = b_pass.name();
521 #define MAP_PASS(passname, passtype) \
522  if (name == passname) { \
523  return passtype; \
524  } \
525  ((void)0)
526  /* NOTE: Keep in sync with defined names from DNA_scene_types.h */
527  MAP_PASS("Combined", PASS_COMBINED);
528  MAP_PASS("Depth", PASS_DEPTH);
529  MAP_PASS("Mist", PASS_MIST);
530  MAP_PASS("Normal", PASS_NORMAL);
531  MAP_PASS("IndexOB", PASS_OBJECT_ID);
532  MAP_PASS("UV", PASS_UV);
533  MAP_PASS("Vector", PASS_MOTION);
534  MAP_PASS("IndexMA", PASS_MATERIAL_ID);
535 
536  MAP_PASS("DiffDir", PASS_DIFFUSE_DIRECT);
537  MAP_PASS("GlossDir", PASS_GLOSSY_DIRECT);
538  MAP_PASS("TransDir", PASS_TRANSMISSION_DIRECT);
539  MAP_PASS("VolumeDir", PASS_VOLUME_DIRECT);
540 
541  MAP_PASS("DiffInd", PASS_DIFFUSE_INDIRECT);
542  MAP_PASS("GlossInd", PASS_GLOSSY_INDIRECT);
544  MAP_PASS("VolumeInd", PASS_VOLUME_INDIRECT);
545 
546  MAP_PASS("DiffCol", PASS_DIFFUSE_COLOR);
547  MAP_PASS("GlossCol", PASS_GLOSSY_COLOR);
548  MAP_PASS("TransCol", PASS_TRANSMISSION_COLOR);
549 
550  MAP_PASS("Emit", PASS_EMISSION);
551  MAP_PASS("Env", PASS_BACKGROUND);
552  MAP_PASS("AO", PASS_AO);
553  MAP_PASS("Shadow", PASS_SHADOW);
554 
555  MAP_PASS("BakePrimitive", PASS_BAKE_PRIMITIVE);
556  MAP_PASS("BakeDifferential", PASS_BAKE_DIFFERENTIAL);
557 
558 #ifdef __KERNEL_DEBUG__
559  MAP_PASS("Debug BVH Traversed Nodes", PASS_BVH_TRAVERSED_NODES);
560  MAP_PASS("Debug BVH Traversed Instances", PASS_BVH_TRAVERSED_INSTANCES);
561  MAP_PASS("Debug BVH Intersections", PASS_BVH_INTERSECTIONS);
562  MAP_PASS("Debug Ray Bounces", PASS_RAY_BOUNCES);
563 #endif
564  MAP_PASS("Debug Render Time", PASS_RENDER_TIME);
565  MAP_PASS("AdaptiveAuxBuffer", PASS_ADAPTIVE_AUX_BUFFER);
566  MAP_PASS("Debug Sample Count", PASS_SAMPLE_COUNT);
568  return PASS_CRYPTOMATTE;
569  }
570 #undef MAP_PASS
571 
572  return PASS_NONE;
573 }
574 
576 {
577  string name = b_pass.name();
578 
579  if (name == "Noisy Image")
581 
582  if (name.substr(0, 10) != "Denoising ") {
583  return -1;
584  }
585  name = name.substr(10);
586 
587 #define MAP_PASS(passname, offset) \
588  if (name == passname) { \
589  return offset; \
590  } \
591  ((void)0)
598  MAP_PASS("Clean", DENOISING_PASS_CLEAN);
599 #undef MAP_PASS
600 
601  return -1;
602 }
603 
605  BL::RenderLayer &b_rlay,
606  BL::ViewLayer &b_view_layer,
607  bool adaptive_sampling,
608  const DenoiseParams &denoising)
609 {
610  vector<Pass> passes;
611 
612  /* loop over passes */
613  for (BL::RenderPass &b_pass : b_rlay.passes) {
614  PassType pass_type = get_pass_type(b_pass);
615 
616  if (pass_type == PASS_MOTION && b_scene.render().use_motion_blur())
617  continue;
618  if (pass_type != PASS_NONE)
619  Pass::add(pass_type, passes, b_pass.name().c_str());
620  }
621 
622  PointerRNA crl = RNA_pointer_get(&b_view_layer.ptr, "cycles");
623 
624  int denoising_flags = 0;
625  if (denoising.use || denoising.store_passes) {
626  if (denoising.type == DENOISER_NLM) {
627 #define MAP_OPTION(name, flag) \
628  if (!get_boolean(crl, name)) { \
629  denoising_flags |= flag; \
630  } \
631  ((void)0)
632  MAP_OPTION("denoising_diffuse_direct", DENOISING_CLEAN_DIFFUSE_DIR);
633  MAP_OPTION("denoising_diffuse_indirect", DENOISING_CLEAN_DIFFUSE_IND);
634  MAP_OPTION("denoising_glossy_direct", DENOISING_CLEAN_GLOSSY_DIR);
635  MAP_OPTION("denoising_glossy_indirect", DENOISING_CLEAN_GLOSSY_IND);
636  MAP_OPTION("denoising_transmission_direct", DENOISING_CLEAN_TRANSMISSION_DIR);
637  MAP_OPTION("denoising_transmission_indirect", DENOISING_CLEAN_TRANSMISSION_IND);
638 #undef MAP_OPTION
639  }
640  b_engine.add_pass("Noisy Image", 4, "RGBA", b_view_layer.name().c_str());
641  }
642  scene->film->set_denoising_flags(denoising_flags);
643 
644  if (denoising.store_passes) {
645  b_engine.add_pass("Denoising Normal", 3, "XYZ", b_view_layer.name().c_str());
646  b_engine.add_pass("Denoising Albedo", 3, "RGB", b_view_layer.name().c_str());
647  b_engine.add_pass("Denoising Depth", 1, "Z", b_view_layer.name().c_str());
648  if (denoising.type == DENOISER_NLM) {
649  b_engine.add_pass("Denoising Shadowing", 1, "X", b_view_layer.name().c_str());
650  b_engine.add_pass("Denoising Variance", 3, "RGB", b_view_layer.name().c_str());
651  b_engine.add_pass("Denoising Intensity", 1, "X", b_view_layer.name().c_str());
652  }
653 
654  if (scene->film->get_denoising_flags() & DENOISING_CLEAN_ALL_PASSES) {
655  b_engine.add_pass("Denoising Clean", 3, "RGB", b_view_layer.name().c_str());
656  }
657  }
658 
659 #ifdef __KERNEL_DEBUG__
660  if (get_boolean(crl, "pass_debug_bvh_traversed_nodes")) {
661  b_engine.add_pass("Debug BVH Traversed Nodes", 1, "X", b_view_layer.name().c_str());
662  Pass::add(PASS_BVH_TRAVERSED_NODES, passes, "Debug BVH Traversed Nodes");
663  }
664  if (get_boolean(crl, "pass_debug_bvh_traversed_instances")) {
665  b_engine.add_pass("Debug BVH Traversed Instances", 1, "X", b_view_layer.name().c_str());
666  Pass::add(PASS_BVH_TRAVERSED_INSTANCES, passes, "Debug BVH Traversed Instances");
667  }
668  if (get_boolean(crl, "pass_debug_bvh_intersections")) {
669  b_engine.add_pass("Debug BVH Intersections", 1, "X", b_view_layer.name().c_str());
670  Pass::add(PASS_BVH_INTERSECTIONS, passes, "Debug BVH Intersections");
671  }
672  if (get_boolean(crl, "pass_debug_ray_bounces")) {
673  b_engine.add_pass("Debug Ray Bounces", 1, "X", b_view_layer.name().c_str());
674  Pass::add(PASS_RAY_BOUNCES, passes, "Debug Ray Bounces");
675  }
676 #endif
677  if (get_boolean(crl, "pass_debug_render_time")) {
678  b_engine.add_pass("Debug Render Time", 1, "X", b_view_layer.name().c_str());
679  Pass::add(PASS_RENDER_TIME, passes, "Debug Render Time");
680  }
681  if (get_boolean(crl, "pass_debug_sample_count")) {
682  b_engine.add_pass("Debug Sample Count", 1, "X", b_view_layer.name().c_str());
683  Pass::add(PASS_SAMPLE_COUNT, passes, "Debug Sample Count");
684  }
685  if (get_boolean(crl, "use_pass_volume_direct")) {
686  b_engine.add_pass("VolumeDir", 3, "RGB", b_view_layer.name().c_str());
687  Pass::add(PASS_VOLUME_DIRECT, passes, "VolumeDir");
688  }
689  if (get_boolean(crl, "use_pass_volume_indirect")) {
690  b_engine.add_pass("VolumeInd", 3, "RGB", b_view_layer.name().c_str());
691  Pass::add(PASS_VOLUME_INDIRECT, passes, "VolumeInd");
692  }
693 
694  /* Cryptomatte stores two ID/weight pairs per RGBA layer.
695  * User facing parameter is the number of pairs. */
696  int crypto_depth = divide_up(min(16, b_view_layer.pass_cryptomatte_depth()), 2);
697  scene->film->set_cryptomatte_depth(crypto_depth);
698  CryptomatteType cryptomatte_passes = CRYPT_NONE;
699  if (b_view_layer.use_pass_cryptomatte_object()) {
700  for (int i = 0; i < crypto_depth; i++) {
701  string passname = cryptomatte_prefix + string_printf("Object%02d", i);
702  b_engine.add_pass(passname.c_str(), 4, "RGBA", b_view_layer.name().c_str());
703  Pass::add(PASS_CRYPTOMATTE, passes, passname.c_str());
704  }
705  cryptomatte_passes = (CryptomatteType)(cryptomatte_passes | CRYPT_OBJECT);
706  }
707  if (b_view_layer.use_pass_cryptomatte_material()) {
708  for (int i = 0; i < crypto_depth; i++) {
709  string passname = cryptomatte_prefix + string_printf("Material%02d", i);
710  b_engine.add_pass(passname.c_str(), 4, "RGBA", b_view_layer.name().c_str());
711  Pass::add(PASS_CRYPTOMATTE, passes, passname.c_str());
712  }
713  cryptomatte_passes = (CryptomatteType)(cryptomatte_passes | CRYPT_MATERIAL);
714  }
715  if (b_view_layer.use_pass_cryptomatte_asset()) {
716  for (int i = 0; i < crypto_depth; i++) {
717  string passname = cryptomatte_prefix + string_printf("Asset%02d", i);
718  b_engine.add_pass(passname.c_str(), 4, "RGBA", b_view_layer.name().c_str());
719  Pass::add(PASS_CRYPTOMATTE, passes, passname.c_str());
720  }
721  cryptomatte_passes = (CryptomatteType)(cryptomatte_passes | CRYPT_ASSET);
722  }
723  if (b_view_layer.use_pass_cryptomatte_accurate() && cryptomatte_passes != CRYPT_NONE) {
724  cryptomatte_passes = (CryptomatteType)(cryptomatte_passes | CRYPT_ACCURATE);
725  }
726  scene->film->set_cryptomatte_passes(cryptomatte_passes);
727 
728  if (adaptive_sampling) {
730  if (!get_boolean(crl, "pass_debug_sample_count")) {
731  Pass::add(PASS_SAMPLE_COUNT, passes);
732  }
733  }
734 
735  BL::ViewLayer::aovs_iterator b_aov_iter;
736  for (b_view_layer.aovs.begin(b_aov_iter); b_aov_iter != b_view_layer.aovs.end(); ++b_aov_iter) {
737  BL::AOV b_aov(*b_aov_iter);
738  if (!b_aov.is_valid()) {
739  continue;
740  }
741 
742  string name = b_aov.name();
743  bool is_color = b_aov.type() == BL::AOV::type_COLOR;
744 
745  if (is_color) {
746  b_engine.add_pass(name.c_str(), 4, "RGBA", b_view_layer.name().c_str());
747  Pass::add(PASS_AOV_COLOR, passes, name.c_str());
748  }
749  else {
750  b_engine.add_pass(name.c_str(), 1, "X", b_view_layer.name().c_str());
751  Pass::add(PASS_AOV_VALUE, passes, name.c_str());
752  }
753  }
754 
755  scene->film->set_denoising_data_pass(denoising.use || denoising.store_passes);
756  scene->film->set_denoising_clean_pass(scene->film->get_denoising_flags() &
758  scene->film->set_denoising_prefiltered_pass(denoising.store_passes &&
759  denoising.type == DENOISER_NLM);
760 
761  scene->film->set_pass_alpha_threshold(b_view_layer.pass_alpha_threshold());
762  scene->film->tag_passes_update(scene, passes);
764 
765  return passes;
766 }
767 
768 void BlenderSync::free_data_after_sync(BL::Depsgraph &b_depsgraph)
769 {
770  /* When viewport display is not needed during render we can force some
771  * caches to be releases from blender side in order to reduce peak memory
772  * footprint during synchronization process.
773  */
774 
775  const bool is_interface_locked = b_engine.render() && b_engine.render().use_lock_interface();
776  const bool is_persistent_data = b_engine.render() && b_engine.render().use_persistent_data();
777  const bool can_free_caches =
778  (BlenderSession::headless || is_interface_locked) &&
779  /* Baking re-uses the depsgraph multiple times, clearing crashes
780  * reading un-evaluated mesh data which isn't aligned with the
781  * geometry we're baking, see T71012. */
782  !scene->bake_manager->get_baking() &&
783  /* Persistent data must main caches for performance and correctness. */
784  !is_persistent_data;
785 
786  if (!can_free_caches) {
787  return;
788  }
789  /* TODO(sergey): We can actually remove the whole dependency graph,
790  * but that will need some API support first.
791  */
792  for (BL::Object &b_ob : b_depsgraph.objects) {
793  b_ob.cache_release();
794  }
795 }
796 
797 /* Scene Parameters */
798 
800 {
802  PointerRNA cscene = RNA_pointer_get(&b_scene.ptr, "cycles");
803  const bool shadingsystem = RNA_boolean_get(&cscene, "shading_system");
804 
805  if (shadingsystem == 0)
806  params.shadingsystem = SHADINGSYSTEM_SVM;
807  else if (shadingsystem == 1)
808  params.shadingsystem = SHADINGSYSTEM_OSL;
809 
810  if (background || DebugFlags().viewport_static_bvh)
811  params.bvh_type = SceneParams::BVH_STATIC;
812  else
813  params.bvh_type = SceneParams::BVH_DYNAMIC;
814 
815  params.use_bvh_spatial_split = RNA_boolean_get(&cscene, "debug_use_spatial_splits");
816  params.use_bvh_unaligned_nodes = RNA_boolean_get(&cscene, "debug_use_hair_bvh");
817  params.num_bvh_time_steps = RNA_int_get(&cscene, "debug_bvh_time_steps");
818 
819  PointerRNA csscene = RNA_pointer_get(&b_scene.ptr, "cycles_curves");
820  params.hair_subdivisions = get_int(csscene, "subdivisions");
821  params.hair_shape = (CurveShapeType)get_enum(
822  csscene, "shape", CURVE_NUM_SHAPE_TYPES, CURVE_THICK);
823 
824  int texture_limit;
825  if (background) {
826  texture_limit = RNA_enum_get(&cscene, "texture_limit_render");
827  }
828  else {
829  texture_limit = RNA_enum_get(&cscene, "texture_limit");
830  }
831  if (texture_limit > 0 && b_scene.render().use_simplify()) {
832  params.texture_limit = 1 << (texture_limit + 6);
833  }
834  else {
835  params.texture_limit = 0;
836  }
837 
838  params.bvh_layout = DebugFlags().cpu.bvh_layout;
839 
840  params.background = background;
841 
842  return params;
843 }
844 
845 /* Session Parameters */
846 
847 bool BlenderSync::get_session_pause(BL::Scene &b_scene, bool background)
848 {
849  PointerRNA cscene = RNA_pointer_get(&b_scene.ptr, "cycles");
850  return (background) ? false : get_boolean(cscene, "preview_pause");
851 }
852 
854  BL::Preferences &b_preferences,
855  BL::Scene &b_scene,
856  bool background,
857  BL::ViewLayer b_view_layer)
858 {
860  PointerRNA cscene = RNA_pointer_get(&b_scene.ptr, "cycles");
861 
862  /* feature set */
863  params.experimental = (get_enum(cscene, "feature_set") != 0);
864 
865  /* Background */
866  params.background = background;
867 
868  /* Device */
869  params.threads = blender_device_threads(b_scene);
870  params.device = blender_device_info(b_preferences, b_scene, params.background);
871 
872  /* samples */
873  int samples = get_int(cscene, "samples");
874  int aa_samples = get_int(cscene, "aa_samples");
875  int preview_samples = get_int(cscene, "preview_samples");
876  int preview_aa_samples = get_int(cscene, "preview_aa_samples");
877 
878  if (get_boolean(cscene, "use_square_samples")) {
880  preview_aa_samples = preview_aa_samples * preview_aa_samples;
881 
882  samples = samples * samples;
883  preview_samples = preview_samples * preview_samples;
884  }
885 
886  if (get_enum(cscene, "progressive") == 0 && params.device.has_branched_path) {
887  if (background) {
888  params.samples = aa_samples;
889  }
890  else {
891  params.samples = preview_aa_samples;
892  if (params.samples == 0)
893  params.samples = INT_MAX;
894  }
895  }
896  else {
897  if (background) {
898  params.samples = samples;
899  }
900  else {
901  params.samples = preview_samples;
902  if (params.samples == 0)
903  params.samples = INT_MAX;
904  }
905  }
906 
907  /* Clamp samples. */
908  params.samples = min(params.samples, Integrator::MAX_SAMPLES);
909 
910  /* Adaptive sampling. */
911  params.adaptive_sampling = RNA_boolean_get(&cscene, "use_adaptive_sampling");
912 
913  /* tiles */
914  const bool is_cpu = (params.device.type == DEVICE_CPU);
915  if (!is_cpu && !background) {
916  /* currently GPU could be much slower than CPU when using tiles,
917  * still need to be investigated, but meanwhile make it possible
918  * to work in viewport smoothly
919  */
920  int debug_tile_size = get_int(cscene, "debug_tile_size");
921 
922  params.tile_size = make_int2(debug_tile_size, debug_tile_size);
923  }
924  else {
925  int tile_x = b_engine.tile_x();
926  int tile_y = b_engine.tile_y();
927 
928  params.tile_size = make_int2(tile_x, tile_y);
929  }
930 
931  if ((BlenderSession::headless == false) && background) {
932  params.tile_order = (TileOrder)get_enum(cscene, "tile_order");
933  }
934  else {
935  params.tile_order = TILE_BOTTOM_TO_TOP;
936  }
937 
938  /* Denoising */
939  params.denoising = get_denoise_params(b_scene, b_view_layer, background);
940 
941  if (params.denoising.use) {
942  /* Add additional denoising devices if we are rendering and denoising
943  * with different devices. */
944  params.device.add_denoising_devices(params.denoising.type);
945 
946  /* Check if denoiser is supported by device. */
947  if (!(params.device.denoisers & params.denoising.type)) {
948  params.denoising.use = false;
949  }
950  }
951 
952  /* Viewport Performance */
953  params.start_resolution = get_int(cscene, "preview_start_resolution");
954  params.pixel_size = b_engine.get_preview_pixel_size(b_scene);
955 
956  /* other parameters */
957  params.cancel_timeout = (double)get_float(cscene, "debug_cancel_timeout");
958  params.reset_timeout = (double)get_float(cscene, "debug_reset_timeout");
959  params.text_timeout = (double)get_float(cscene, "debug_text_timeout");
960 
961  /* progressive refine */
962  BL::RenderSettings b_r = b_scene.render();
963  params.progressive_refine = b_engine.is_preview() ||
964  get_boolean(cscene, "use_progressive_refine");
965  if (b_r.use_save_buffers() || params.adaptive_sampling)
966  params.progressive_refine = false;
967 
968  if (background) {
969  if (params.progressive_refine)
970  params.progressive = true;
971  else
972  params.progressive = false;
973 
974  params.start_resolution = INT_MAX;
975  params.pixel_size = 1;
976  }
977  else
978  params.progressive = true;
979 
980  /* shading system - scene level needs full refresh */
981  const bool shadingsystem = RNA_boolean_get(&cscene, "shading_system");
982 
983  if (shadingsystem == 0)
984  params.shadingsystem = SHADINGSYSTEM_SVM;
985  else if (shadingsystem == 1)
986  params.shadingsystem = SHADINGSYSTEM_OSL;
987 
988  /* Color management. */
989  params.display_buffer_linear = b_engine.support_display_space_shader(b_scene);
990 
991  if (b_engine.is_preview()) {
992  /* For preview rendering we're using same timeout as
993  * blender's job update.
994  */
995  params.progressive_update_timeout = 0.1;
996  }
997 
998  params.use_profiling = params.device.has_profiling && !b_engine.is_preview() && background &&
1000 
1001  return params;
1002 }
1003 
1004 DenoiseParams BlenderSync::get_denoise_params(BL::Scene &b_scene,
1005  BL::ViewLayer &b_view_layer,
1006  bool background)
1007 {
1008  DenoiseParams denoising;
1009  PointerRNA cscene = RNA_pointer_get(&b_scene.ptr, "cycles");
1010 
1011  if (background) {
1012  /* Final Render Denoising */
1013  denoising.use = get_boolean(cscene, "use_denoising");
1014  denoising.type = (DenoiserType)get_enum(cscene, "denoiser", DENOISER_NUM, DENOISER_NONE);
1015 
1016  if (b_view_layer) {
1017  PointerRNA clayer = RNA_pointer_get(&b_view_layer.ptr, "cycles");
1018  if (!get_boolean(clayer, "use_denoising")) {
1019  denoising.use = false;
1020  }
1021 
1022  denoising.radius = get_int(clayer, "denoising_radius");
1023  denoising.strength = get_float(clayer, "denoising_strength");
1024  denoising.feature_strength = get_float(clayer, "denoising_feature_strength");
1025  denoising.relative_pca = get_boolean(clayer, "denoising_relative_pca");
1026 
1027  denoising.input_passes = (DenoiserInput)get_enum(
1028  clayer,
1029  (denoising.type == DENOISER_OPTIX) ? "denoising_optix_input_passes" :
1030  "denoising_openimagedenoise_input_passes",
1033 
1034  denoising.store_passes = get_boolean(clayer, "denoising_store_passes");
1035  }
1036  }
1037  else {
1038  /* Viewport Denoising */
1039  denoising.use = get_boolean(cscene, "use_preview_denoising");
1040  denoising.type = (DenoiserType)get_enum(
1041  cscene, "preview_denoiser", DENOISER_NUM, DENOISER_NONE);
1042  denoising.start_sample = get_int(cscene, "preview_denoising_start_sample");
1043 
1044  denoising.input_passes = (DenoiserInput)get_enum(
1045  cscene, "preview_denoising_input_passes", DENOISER_INPUT_NUM, (int)denoising.input_passes);
1046 
1047  /* Auto select fastest denoiser. */
1048  if (denoising.type == DENOISER_NONE) {
1050  denoising.type = DENOISER_OPTIX;
1051  }
1052  else if (openimagedenoise_supported()) {
1053  denoising.type = DENOISER_OPENIMAGEDENOISE;
1054  }
1055  else {
1056  denoising.use = false;
1057  }
1058  }
1059  }
1060 
1061  return denoising;
1062 }
1063 
typedef double(DMatrix)[4][4]
struct Depsgraph Depsgraph
Definition: DEG_depsgraph.h:51
struct ID ID
struct Image Image
struct ViewLayer ViewLayer
struct Light Light
struct Material Material
struct Mesh Mesh
struct Object Object
struct Scene Scene
struct Volume Volume
struct World World
_GL_VOID GLfloat value _GL_VOID_RET _GL_VOID const GLuint GLboolean *residences _GL_BOOL_RET _GL_VOID GLsizei GLfloat GLfloat GLfloat GLfloat const GLubyte *bitmap _GL_VOID_RET _GL_VOID GLenum const void *lists _GL_VOID_RET _GL_VOID const GLdouble *equation _GL_VOID_RET _GL_VOID GLdouble GLdouble blue _GL_VOID_RET _GL_VOID GLfloat GLfloat blue _GL_VOID_RET _GL_VOID GLint GLint blue _GL_VOID_RET _GL_VOID GLshort GLshort blue _GL_VOID_RET _GL_VOID GLubyte GLubyte blue _GL_VOID_RET _GL_VOID GLuint GLuint blue _GL_VOID_RET _GL_VOID GLushort GLushort blue _GL_VOID_RET _GL_VOID GLbyte GLbyte GLbyte alpha _GL_VOID_RET _GL_VOID GLdouble GLdouble GLdouble alpha _GL_VOID_RET _GL_VOID GLfloat GLfloat GLfloat alpha _GL_VOID_RET _GL_VOID GLint GLint GLint alpha _GL_VOID_RET _GL_VOID GLshort GLshort GLshort alpha _GL_VOID_RET _GL_VOID GLubyte GLubyte GLubyte alpha _GL_VOID_RET _GL_VOID GLuint GLuint GLuint alpha _GL_VOID_RET _GL_VOID GLushort GLushort GLushort alpha _GL_VOID_RET _GL_VOID GLenum mode _GL_VOID_RET _GL_VOID GLint GLsizei GLsizei GLenum type _GL_VOID_RET _GL_VOID GLsizei GLenum GLenum const void *pixels _GL_VOID_RET _GL_VOID const void *pointer _GL_VOID_RET _GL_VOID GLdouble v _GL_VOID_RET _GL_VOID GLfloat v _GL_VOID_RET _GL_VOID GLint GLint i2 _GL_VOID_RET _GL_VOID GLint j _GL_VOID_RET _GL_VOID GLfloat param _GL_VOID_RET _GL_VOID GLint param _GL_VOID_RET _GL_VOID GLdouble GLdouble GLdouble GLdouble GLdouble zFar _GL_VOID_RET _GL_UINT GLdouble *equation _GL_VOID_RET _GL_VOID GLenum GLint *params _GL_VOID_RET _GL_VOID GLenum GLfloat *v _GL_VOID_RET _GL_VOID GLenum GLfloat *params _GL_VOID_RET _GL_VOID GLfloat *values _GL_VOID_RET _GL_VOID GLushort *values _GL_VOID_RET _GL_VOID GLenum GLfloat *params _GL_VOID_RET _GL_VOID GLenum GLdouble *params _GL_VOID_RET _GL_VOID GLenum GLint *params _GL_VOID_RET _GL_VOID GLsizei const void *pointer _GL_VOID_RET _GL_VOID GLsizei const void *pointer _GL_VOID_RET _GL_BOOL GLfloat param _GL_VOID_RET _GL_VOID GLint param _GL_VOID_RET _GL_VOID GLenum GLfloat param _GL_VOID_RET _GL_VOID GLenum GLint param _GL_VOID_RET _GL_VOID GLushort pattern _GL_VOID_RET _GL_VOID GLdouble GLdouble GLint GLint const GLdouble *points _GL_VOID_RET _GL_VOID GLdouble GLdouble GLint GLint GLdouble GLdouble GLint GLint const GLdouble *points _GL_VOID_RET _GL_VOID GLdouble GLdouble u2 _GL_VOID_RET _GL_VOID GLdouble GLdouble GLint GLdouble GLdouble v2 _GL_VOID_RET _GL_VOID GLenum GLfloat param _GL_VOID_RET _GL_VOID GLenum GLint param _GL_VOID_RET _GL_VOID GLenum mode _GL_VOID_RET _GL_VOID GLdouble GLdouble nz _GL_VOID_RET _GL_VOID GLfloat GLfloat nz _GL_VOID_RET _GL_VOID GLint GLint nz _GL_VOID_RET _GL_VOID GLshort GLshort nz _GL_VOID_RET _GL_VOID GLsizei const void *pointer _GL_VOID_RET _GL_VOID GLsizei const GLfloat *values _GL_VOID_RET _GL_VOID GLsizei const GLushort *values _GL_VOID_RET _GL_VOID GLint param _GL_VOID_RET _GL_VOID const GLuint const GLclampf *priorities _GL_VOID_RET _GL_VOID GLdouble y _GL_VOID_RET _GL_VOID GLfloat y _GL_VOID_RET _GL_VOID GLint y _GL_VOID_RET _GL_VOID GLshort y _GL_VOID_RET _GL_VOID GLdouble GLdouble z _GL_VOID_RET _GL_VOID GLfloat GLfloat z _GL_VOID_RET _GL_VOID GLint GLint z _GL_VOID_RET _GL_VOID GLshort GLshort z _GL_VOID_RET _GL_VOID GLdouble GLdouble GLdouble w _GL_VOID_RET _GL_VOID GLfloat GLfloat GLfloat w _GL_VOID_RET _GL_VOID GLint GLint GLint w _GL_VOID_RET _GL_VOID GLshort GLshort GLshort w _GL_VOID_RET _GL_VOID GLdouble GLdouble GLdouble y2 _GL_VOID_RET _GL_VOID GLfloat GLfloat GLfloat y2 _GL_VOID_RET _GL_VOID GLint GLint GLint y2 _GL_VOID_RET _GL_VOID GLshort GLshort GLshort y2 _GL_VOID_RET _GL_VOID GLdouble GLdouble GLdouble z _GL_VOID_RET _GL_VOID GLdouble GLdouble z _GL_VOID_RET _GL_VOID GLuint *buffer _GL_VOID_RET _GL_VOID GLdouble t _GL_VOID_RET _GL_VOID GLfloat t _GL_VOID_RET _GL_VOID GLint t _GL_VOID_RET _GL_VOID GLshort t _GL_VOID_RET _GL_VOID GLdouble GLdouble r _GL_VOID_RET _GL_VOID GLfloat GLfloat r _GL_VOID_RET _GL_VOID GLint GLint r _GL_VOID_RET _GL_VOID GLshort GLshort r _GL_VOID_RET _GL_VOID GLdouble GLdouble r
_GL_VOID GLfloat value _GL_VOID_RET _GL_VOID const GLuint GLboolean *residences _GL_BOOL_RET _GL_VOID GLsizei GLfloat GLfloat GLfloat GLfloat const GLubyte *bitmap _GL_VOID_RET _GL_VOID GLenum const void *lists _GL_VOID_RET _GL_VOID const GLdouble *equation _GL_VOID_RET _GL_VOID GLdouble GLdouble blue _GL_VOID_RET _GL_VOID GLfloat GLfloat blue _GL_VOID_RET _GL_VOID GLint GLint blue _GL_VOID_RET _GL_VOID GLshort GLshort blue _GL_VOID_RET _GL_VOID GLubyte GLubyte blue _GL_VOID_RET _GL_VOID GLuint GLuint blue _GL_VOID_RET _GL_VOID GLushort GLushort blue _GL_VOID_RET _GL_VOID GLbyte GLbyte GLbyte alpha _GL_VOID_RET _GL_VOID GLdouble GLdouble GLdouble alpha _GL_VOID_RET _GL_VOID GLfloat GLfloat GLfloat alpha _GL_VOID_RET _GL_VOID GLint GLint GLint alpha _GL_VOID_RET _GL_VOID GLshort GLshort GLshort alpha _GL_VOID_RET _GL_VOID GLubyte GLubyte GLubyte alpha _GL_VOID_RET _GL_VOID GLuint GLuint GLuint alpha _GL_VOID_RET _GL_VOID GLushort GLushort GLushort alpha _GL_VOID_RET _GL_VOID GLenum mode _GL_VOID_RET _GL_VOID GLint GLsizei width
_GL_VOID GLfloat value _GL_VOID_RET _GL_VOID const GLuint GLboolean *residences _GL_BOOL_RET _GL_VOID GLsizei height
struct RenderEngine RenderEngine
struct RenderLayer RenderLayer
struct RenderPass RenderPass
StructRNA RNA_Material
StructRNA RNA_Mesh
StructRNA RNA_Light
StructRNA RNA_Object
StructRNA RNA_World
StructRNA RNA_Volume
static CCL_NAMESPACE_BEGIN int aa_samples(Scene *scene, Object *object, ShaderEvalType type)
Definition: bake.cpp:29
int blender_device_threads(BL::Scene &b_scene)
DeviceInfo blender_device_info(BL::Preferences &b_preferences, BL::Scene &b_scene, bool background)
#define MAP_OPTION(name, flag)
static CCL_NAMESPACE_BEGIN const char * cryptomatte_prefix
#define MAP_PASS(passname, passtype)
static float get_float(PointerRNA &ptr, const char *name)
Definition: blender_util.h:359
static bool get_boolean(PointerRNA &ptr, const char *name)
Definition: blender_util.h:349
static int get_int(PointerRNA &ptr, const char *name)
Definition: blender_util.h:369
static int get_enum(PointerRNA &ptr, const char *name, int num_values=-1, int default_value=-1)
Definition: blender_util.h:386
static Mesh::SubdivisionType object_subdivision_type(BL::Object &b_ob, bool preview, bool experimental)
Definition: blender_util.h:571
PassType update_viewport_display_passes(BL::SpaceView3D &b_v3d, vector< Pass > &passes)
static unsigned long seed
Definition: btSoftBody.h:39
bool get_baking()
Definition: bake.cpp:88
static bool headless
static bool print_render_stats
static bool get_session_pause(BL::Scene &b_scene, bool background)
static SessionParams get_session_params(BL::RenderEngine &b_engine, BL::Preferences &b_userpref, BL::Scene &b_scene, bool background, BL::ViewLayer b_view_layer=BL::ViewLayer(PointerRNA_NULL))
void sync_recalc(BL::Depsgraph &b_depsgraph, BL::SpaceView3D &b_v3d)
void tag_update()
BlenderSync(BL::RenderEngine &b_engine, BL::BlendData &b_data, BL::Scene &b_scene, Scene *scene, bool preview, Progress &progress)
static SceneParams get_scene_params(BL::Scene &b_scene, bool background)
vector< Pass > sync_render_passes(BL::Scene &b_scene, BL::RenderLayer &b_render_layer, BL::ViewLayer &b_view_layer, bool adaptive_sampling, const DenoiseParams &denoising)
static int get_denoising_pass(BL::RenderPass &b_pass)
static PassType get_pass_type(BL::RenderPass &b_pass)
void sync_data(BL::RenderSettings &b_render, BL::Depsgraph &b_depsgraph, BL::SpaceView3D &b_v3d, BL::Object &b_override, int width, int height, void **python_thread_state)
void reset(BL::BlendData &b_data, BL::Scene &b_scene)
void sync_view_layer(BL::SpaceView3D &b_v3d, BL::ViewLayer &b_view_layer)
void sync_integrator()
static PassType get_viewport_display_render_pass(BL::SpaceView3D &b_v3d)
bool relative_pca
Definition: device_task.h:78
DenoiserType type
Definition: device_task.h:63
float feature_strength
Definition: device_task.h:75
bool store_passes
Definition: device_task.h:60
DenoiserInput input_passes
Definition: device_task.h:87
float strength
Definition: device_task.h:73
static vector< DeviceInfo > available_devices(uint device_type_mask=DEVICE_MASK_ALL)
Definition: device.cpp:488
Definition: film.h:59
void tag_passes_update(Scene *scene, const vector< Pass > &passes_, bool update_passes=true)
Definition: film.cpp:688
bool is_mesh() const
Definition: geometry.h:170
void tag_update(Scene *scene, uint32_t flag)
Definition: integrator.cpp:292
static NODE_DECLARE const int MAX_SAMPLES
Definition: integrator.h:62
static bool equals(const vector< Pass > &A, const vector< Pass > &B)
Definition: film.cpp:283
static void add(PassType type, vector< Pass > &passes, const char *name=NULL)
Definition: film.cpp:103
@ BVH_STATIC
Definition: scene.h:161
@ BVH_DYNAMIC
Definition: scene.h:154
const map< K, T * > & key_to_scene_data()
void set_recalc(const BL::ID &id)
void post_sync(bool do_delete=true)
double get_time() const
Definition: util_time.h:54
Scene scene
@ DEVICE_MASK_OPTIX
Definition: device.h:58
@ DEVICE_CPU
Definition: device.h:45
DenoiserType
Definition: device_task.h:35
@ DENOISER_NONE
Definition: device_task.h:41
@ DENOISER_OPTIX
Definition: device_task.h:37
@ DENOISER_NLM
Definition: device_task.h:36
@ DENOISER_OPENIMAGEDENOISE
Definition: device_task.h:38
@ DENOISER_NUM
Definition: device_task.h:39
DenoiserInput
Definition: device_task.h:45
@ DENOISER_INPUT_NUM
Definition: device_task.h:50
@ DENOISER_INPUT_RGB_ALBEDO_NORMAL
Definition: device_task.h:48
FilterType
Definition: film.h:33
@ FILTER_NUM_TYPES
Definition: film.h:38
@ FILTER_BOX
Definition: film.h:34
@ FILTER_BLACKMAN_HARRIS
Definition: film.h:36
uiWidgetBaseParameters params[MAX_WIDGET_BASE_BATCH]
#define CCL_NAMESPACE_END
#define make_int2(x, y)
CryptomatteType
Definition: kernel_types.h:400
@ CRYPT_ASSET
Definition: kernel_types.h:404
@ CRYPT_NONE
Definition: kernel_types.h:401
@ CRYPT_ACCURATE
Definition: kernel_types.h:405
@ CRYPT_OBJECT
Definition: kernel_types.h:402
@ CRYPT_MATERIAL
Definition: kernel_types.h:403
CurveShapeType
Definition: kernel_types.h:713
@ CURVE_THICK
Definition: kernel_types.h:715
@ CURVE_NUM_SHAPE_TYPES
Definition: kernel_types.h:717
@ DENOISING_CLEAN_GLOSSY_IND
Definition: kernel_types.h:462
@ DENOISING_CLEAN_DIFFUSE_DIR
Definition: kernel_types.h:459
@ DENOISING_CLEAN_ALL_PASSES
Definition: kernel_types.h:465
@ DENOISING_CLEAN_TRANSMISSION_IND
Definition: kernel_types.h:464
@ DENOISING_CLEAN_DIFFUSE_IND
Definition: kernel_types.h:460
@ DENOISING_CLEAN_TRANSMISSION_DIR
Definition: kernel_types.h:463
@ DENOISING_CLEAN_GLOSSY_DIR
Definition: kernel_types.h:461
SamplingPattern
Definition: kernel_types.h:254
@ SAMPLING_PATTERN_PMJ
Definition: kernel_types.h:257
@ SAMPLING_PATTERN_SOBOL
Definition: kernel_types.h:255
@ SAMPLING_NUM_PATTERNS
Definition: kernel_types.h:259
PassType
Definition: kernel_types.h:347
@ PASS_EMISSION
Definition: kernel_types.h:374
@ PASS_BACKGROUND
Definition: kernel_types.h:375
@ PASS_TRANSMISSION_DIRECT
Definition: kernel_types.h:385
@ PASS_VOLUME_DIRECT
Definition: kernel_types.h:388
@ PASS_UV
Definition: kernel_types.h:354
@ PASS_TRANSMISSION_COLOR
Definition: kernel_types.h:387
@ PASS_DEPTH
Definition: kernel_types.h:352
@ PASS_MIST
Definition: kernel_types.h:373
@ PASS_TRANSMISSION_INDIRECT
Definition: kernel_types.h:386
@ PASS_DIFFUSE_DIRECT
Definition: kernel_types.h:379
@ PASS_MOTION
Definition: kernel_types.h:357
@ PASS_MATERIAL_ID
Definition: kernel_types.h:356
@ PASS_AO
Definition: kernel_types.h:376
@ PASS_COMBINED
Definition: kernel_types.h:351
@ PASS_DIFFUSE_INDIRECT
Definition: kernel_types.h:380
@ PASS_RENDER_TIME
Definition: kernel_types.h:365
@ PASS_ADAPTIVE_AUX_BUFFER
Definition: kernel_types.h:369
@ PASS_OBJECT_ID
Definition: kernel_types.h:355
@ PASS_AOV_COLOR
Definition: kernel_types.h:367
@ PASS_NONE
Definition: kernel_types.h:348
@ PASS_VOLUME_INDIRECT
Definition: kernel_types.h:389
@ PASS_NORMAL
Definition: kernel_types.h:353
@ PASS_CRYPTOMATTE
Definition: kernel_types.h:366
@ PASS_DIFFUSE_COLOR
Definition: kernel_types.h:381
@ PASS_SAMPLE_COUNT
Definition: kernel_types.h:370
@ PASS_GLOSSY_DIRECT
Definition: kernel_types.h:382
@ PASS_AOV_VALUE
Definition: kernel_types.h:368
@ PASS_GLOSSY_COLOR
Definition: kernel_types.h:384
@ PASS_SHADOW
Definition: kernel_types.h:377
@ PASS_GLOSSY_INDIRECT
Definition: kernel_types.h:383
@ PASS_BAKE_DIFFERENTIAL
Definition: kernel_types.h:394
@ PASS_BAKE_PRIMITIVE
Definition: kernel_types.h:393
@ DENOISING_PASS_PREFILTERED_VARIANCE
Definition: kernel_types.h:426
@ DENOISING_PASS_PREFILTERED_NORMAL
Definition: kernel_types.h:422
@ DENOISING_PASS_PREFILTERED_SHADOWING
Definition: kernel_types.h:423
@ DENOISING_PASS_PREFILTERED_DEPTH
Definition: kernel_types.h:421
@ DENOISING_PASS_PREFILTERED_ALBEDO
Definition: kernel_types.h:424
@ DENOISING_PASS_CLEAN
Definition: kernel_types.h:419
@ DENOISING_PASS_PREFILTERED_COLOR
Definition: kernel_types.h:425
@ DENOISING_PASS_PREFILTERED_INTENSITY
Definition: kernel_types.h:427
PointerRNA RNA_pointer_get(PointerRNA *ptr, const char *name)
Definition: rna_access.c:6562
void RNA_id_pointer_create(ID *id, PointerRNA *r_ptr)
Definition: rna_access.c:122
int RNA_int_get(PointerRNA *ptr, const char *name)
Definition: rna_access.c:6308
float RNA_float_get(PointerRNA *ptr, const char *name)
Definition: rna_access.c:6355
bool RNA_boolean_get(PointerRNA *ptr, const char *name)
Definition: rna_access.c:6261
int RNA_enum_get(PointerRNA *ptr, const char *name)
Definition: rna_access.c:6402
@ SHADINGSYSTEM_OSL
Definition: shader.h:48
@ SHADINGSYSTEM_SVM
Definition: shader.h:48
#define min(a, b)
Definition: sort.c:51
@ MOTION_POSITION_CENTER
Definition: camera.h:51
BVHLayout bvh_layout
Definition: util_debug.h:81
Definition: DNA_ID.h:273
@ SUBDIVISION_NONE
Definition: mesh.h:133
void tag_modified()
Definition: node.cpp:786
BakeManager * bake_manager
Definition: scene.h:249
Film * film
Definition: scene.h:229
vector< Pass > passes
Definition: scene.h:239
MotionType need_motion()
Definition: scene.cpp:358
@ MOTION_PASS
Definition: scene.h:280
@ MOTION_NONE
Definition: scene.h:280
Integrator * integrator
Definition: scene.h:231
struct Object * camera
TileOrder
Definition: tile.h:56
@ TILE_BOTTOM_TO_TOP
Definition: tile.h:61
DebugFlags & DebugFlags()
Definition: util_debug.h:205
ccl_device_inline uint hash_uint2(uint kx, uint ky)
Definition: util_hash.h:83
#define VLOG(severity)
Definition: util_logging.h:50
static CCL_NAMESPACE_BEGIN bool openimagedenoise_supported()
bool string_startswith(const string &s, const char *start)
CCL_NAMESPACE_BEGIN string string_printf(const char *format,...)
Definition: util_string.cpp:32
ccl_device_inline size_t divide_up(size_t x, size_t y)
Definition: util_types.h:70