2023-06-14 16:52:36 +10:00
|
|
|
/* SPDX-FileCopyrightText: 2011-2022 Blender Foundation
|
|
|
|
|
*
|
|
|
|
|
* SPDX-License-Identifier: Apache-2.0 */
|
2011-04-27 11:58:34 +00:00
|
|
|
|
2024-12-26 17:53:56 +01:00
|
|
|
#pragma once
|
2011-04-27 11:58:34 +00:00
|
|
|
|
2024-07-10 18:30:02 +02:00
|
|
|
#include "RNA_blender_cpp.hh"
|
2023-08-10 22:40:27 +02:00
|
|
|
#include "RNA_types.hh"
|
2011-04-27 11:58:34 +00:00
|
|
|
|
2021-10-24 14:19:19 +02:00
|
|
|
#include "blender/id_map.h"
|
|
|
|
|
#include "blender/util.h"
|
|
|
|
|
#include "blender/viewport.h"
|
2011-04-27 11:58:34 +00:00
|
|
|
|
2021-10-24 14:19:19 +02:00
|
|
|
#include "scene/scene.h"
|
|
|
|
|
#include "session/session.h"
|
2011-04-27 11:58:34 +00:00
|
|
|
|
2021-10-24 14:19:19 +02:00
|
|
|
#include "util/map.h"
|
|
|
|
|
#include "util/set.h"
|
|
|
|
|
#include "util/transform.h"
|
2011-04-27 11:58:34 +00:00
|
|
|
|
|
|
|
|
CCL_NAMESPACE_BEGIN
|
|
|
|
|
|
|
|
|
|
class Background;
|
2016-11-13 00:45:16 +01:00
|
|
|
class BlenderObjectCulling;
|
2019-08-27 15:47:30 +02:00
|
|
|
class BlenderViewportParameters;
|
2011-04-27 11:58:34 +00:00
|
|
|
class Camera;
|
|
|
|
|
class Film;
|
2020-02-02 12:04:19 +01:00
|
|
|
class Hair;
|
2011-04-27 11:58:34 +00:00
|
|
|
class Light;
|
|
|
|
|
class Mesh;
|
|
|
|
|
class Object;
|
2012-11-08 16:35:28 +00:00
|
|
|
class ParticleSystem;
|
2011-04-27 11:58:34 +00:00
|
|
|
class Scene;
|
|
|
|
|
class Shader;
|
|
|
|
|
class ShaderGraph;
|
2020-10-21 16:38:36 +02:00
|
|
|
class TaskPool;
|
2011-04-27 11:58:34 +00:00
|
|
|
|
|
|
|
|
class BlenderSync {
|
|
|
|
|
public:
|
2016-01-30 14:18:29 +01:00
|
|
|
BlenderSync(BL::RenderEngine &b_engine,
|
|
|
|
|
BL::BlendData &b_data,
|
|
|
|
|
BL::Scene &b_scene,
|
|
|
|
|
Scene *scene,
|
|
|
|
|
bool preview,
|
Cycles: merge of cycles-x branch, a major update to the renderer
This includes much improved GPU rendering performance, viewport interactivity,
new shadow catcher, revamped sampling settings, subsurface scattering anisotropy,
new GPU volume sampling, improved PMJ sampling pattern, and more.
Some features have also been removed or changed, breaking backwards compatibility.
Including the removal of the OpenCL backend, for which alternatives are under
development.
Release notes and code docs:
https://wiki.blender.org/wiki/Reference/Release_Notes/3.0/Cycles
https://wiki.blender.org/wiki/Source/Render/Cycles
Credits:
* Sergey Sharybin
* Brecht Van Lommel
* Patrick Mours (OptiX backend)
* Christophe Hery (subsurface scattering anisotropy)
* William Leeson (PMJ sampling pattern)
* Alaska (various fixes and tweaks)
* Thomas Dinges (various fixes)
For the full commit history, see the cycles-x branch. This squashes together
all the changes since intermediate changes would often fail building or tests.
Ref T87839, T87837, T87836
Fixes T90734, T89353, T80267, T80267, T77185, T69800
2021-09-20 17:59:20 +02:00
|
|
|
bool use_developer_ui,
|
2017-10-08 04:32:25 +02:00
|
|
|
Progress &progress);
|
2011-04-27 11:58:34 +00:00
|
|
|
~BlenderSync();
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2020-05-27 18:00:59 +02:00
|
|
|
void reset(BL::BlendData &b_data, BL::Scene &b_scene);
|
|
|
|
|
|
2021-12-15 20:25:41 +01:00
|
|
|
void tag_update();
|
|
|
|
|
|
2025-01-02 12:48:21 +01:00
|
|
|
void set_bake_target(BL::Object &b_object);
|
|
|
|
|
|
2011-04-27 11:58:34 +00:00
|
|
|
/* sync */
|
2019-08-27 15:47:30 +02:00
|
|
|
void sync_recalc(BL::Depsgraph &b_depsgraph, BL::SpaceView3D &b_v3d);
|
2016-01-30 14:18:29 +01:00
|
|
|
void sync_data(BL::RenderSettings &b_render,
|
2018-02-26 16:46:48 +01:00
|
|
|
BL::Depsgraph &b_depsgraph,
|
2016-01-30 14:18:29 +01:00
|
|
|
BL::SpaceView3D &b_v3d,
|
|
|
|
|
BL::Object &b_override,
|
2025-01-01 18:15:54 +01:00
|
|
|
const int width,
|
|
|
|
|
const int height,
|
2024-03-08 16:26:52 +01:00
|
|
|
void **python_thread_state,
|
2024-06-24 11:28:02 +02:00
|
|
|
const DeviceInfo &denoise_device_info);
|
2021-05-26 10:45:27 +02:00
|
|
|
void sync_view_layer(BL::ViewLayer &b_view_layer);
|
2024-12-26 17:53:59 +01:00
|
|
|
void sync_render_passes(BL::RenderLayer &b_rlay, BL::ViewLayer &b_view_layer);
|
2024-03-08 16:26:52 +01:00
|
|
|
void sync_integrator(BL::ViewLayer &b_view_layer,
|
|
|
|
|
bool background,
|
2024-06-24 11:28:02 +02:00
|
|
|
const DeviceInfo &denoise_device_info);
|
2016-01-30 14:18:29 +01:00
|
|
|
void sync_camera(BL::RenderSettings &b_render,
|
|
|
|
|
BL::Object &b_override,
|
2025-01-01 18:15:54 +01:00
|
|
|
const int width,
|
|
|
|
|
const int height,
|
2016-03-12 15:00:06 +05:00
|
|
|
const char *viewname);
|
2025-01-01 18:15:54 +01:00
|
|
|
void sync_view(BL::SpaceView3D &b_v3d,
|
|
|
|
|
BL::RegionView3D &b_rv3d,
|
|
|
|
|
const int width,
|
|
|
|
|
const int height);
|
2024-12-26 17:53:59 +01:00
|
|
|
int get_layer_samples()
|
2018-12-28 18:37:05 +01:00
|
|
|
{
|
|
|
|
|
return view_layer.samples;
|
|
|
|
|
}
|
2024-12-26 17:53:59 +01:00
|
|
|
int get_layer_bound_samples()
|
2018-12-28 18:37:05 +01:00
|
|
|
{
|
|
|
|
|
return view_layer.bound_samples;
|
2019-04-17 06:17:24 +02:00
|
|
|
}
|
|
|
|
|
|
2024-04-15 17:40:53 +02:00
|
|
|
/* Early data free. */
|
|
|
|
|
void free_data_after_sync(BL::Depsgraph &b_depsgraph);
|
|
|
|
|
|
2011-04-27 11:58:34 +00:00
|
|
|
/* get parameters */
|
2022-08-11 16:59:29 +02:00
|
|
|
static SceneParams get_scene_params(BL::Scene &b_scene,
|
|
|
|
|
const bool background,
|
|
|
|
|
const bool use_developer_ui);
|
Cycles: merge of cycles-x branch, a major update to the renderer
This includes much improved GPU rendering performance, viewport interactivity,
new shadow catcher, revamped sampling settings, subsurface scattering anisotropy,
new GPU volume sampling, improved PMJ sampling pattern, and more.
Some features have also been removed or changed, breaking backwards compatibility.
Including the removal of the OpenCL backend, for which alternatives are under
development.
Release notes and code docs:
https://wiki.blender.org/wiki/Reference/Release_Notes/3.0/Cycles
https://wiki.blender.org/wiki/Source/Render/Cycles
Credits:
* Sergey Sharybin
* Brecht Van Lommel
* Patrick Mours (OptiX backend)
* Christophe Hery (subsurface scattering anisotropy)
* William Leeson (PMJ sampling pattern)
* Alaska (various fixes and tweaks)
* Thomas Dinges (various fixes)
For the full commit history, see the cycles-x branch. This squashes together
all the changes since intermediate changes would often fail building or tests.
Ref T87839, T87837, T87836
Fixes T90734, T89353, T80267, T80267, T77185, T69800
2021-09-20 17:59:20 +02:00
|
|
|
static SessionParams get_session_params(BL::RenderEngine &b_engine,
|
2024-12-26 17:53:59 +01:00
|
|
|
BL::Preferences &b_preferences,
|
Cycles: merge of cycles-x branch, a major update to the renderer
This includes much improved GPU rendering performance, viewport interactivity,
new shadow catcher, revamped sampling settings, subsurface scattering anisotropy,
new GPU volume sampling, improved PMJ sampling pattern, and more.
Some features have also been removed or changed, breaking backwards compatibility.
Including the removal of the OpenCL backend, for which alternatives are under
development.
Release notes and code docs:
https://wiki.blender.org/wiki/Reference/Release_Notes/3.0/Cycles
https://wiki.blender.org/wiki/Source/Render/Cycles
Credits:
* Sergey Sharybin
* Brecht Van Lommel
* Patrick Mours (OptiX backend)
* Christophe Hery (subsurface scattering anisotropy)
* William Leeson (PMJ sampling pattern)
* Alaska (various fixes and tweaks)
* Thomas Dinges (various fixes)
For the full commit history, see the cycles-x branch. This squashes together
all the changes since intermediate changes would often fail building or tests.
Ref T87839, T87837, T87836
Fixes T90734, T89353, T80267, T80267, T77185, T69800
2021-09-20 17:59:20 +02:00
|
|
|
BL::Scene &b_scene,
|
|
|
|
|
bool background);
|
2016-01-30 14:18:29 +01:00
|
|
|
static bool get_session_pause(BL::Scene &b_scene, bool background);
|
2025-01-01 18:15:54 +01:00
|
|
|
static BufferParams get_buffer_params(BL::SpaceView3D &b_v3d,
|
|
|
|
|
BL::RegionView3D &b_rv3d,
|
|
|
|
|
Camera *cam,
|
|
|
|
|
const int width,
|
|
|
|
|
const int height);
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2020-05-31 23:49:10 +02:00
|
|
|
static DenoiseParams get_denoise_params(BL::Scene &b_scene,
|
|
|
|
|
BL::ViewLayer &b_view_layer,
|
2024-03-08 16:26:52 +01:00
|
|
|
bool background,
|
2024-06-24 11:28:02 +02:00
|
|
|
const DeviceInfo &denoise_device);
|
2020-05-31 23:49:10 +02:00
|
|
|
|
2022-01-04 21:39:54 +01:00
|
|
|
private:
|
2011-04-27 11:58:34 +00:00
|
|
|
/* sync */
|
2018-06-27 14:41:53 +02:00
|
|
|
void sync_lights(BL::Depsgraph &b_depsgraph, bool update_all);
|
2018-02-26 16:46:48 +01:00
|
|
|
void sync_materials(BL::Depsgraph &b_depsgraph, bool update_all);
|
2025-01-01 18:15:54 +01:00
|
|
|
void sync_objects(BL::Depsgraph &b_depsgraph,
|
|
|
|
|
BL::SpaceView3D &b_v3d,
|
|
|
|
|
const float motion_time = 0.0f);
|
2016-01-30 14:18:29 +01:00
|
|
|
void sync_motion(BL::RenderSettings &b_render,
|
2018-02-26 16:46:48 +01:00
|
|
|
BL::Depsgraph &b_depsgraph,
|
2019-08-27 15:47:30 +02:00
|
|
|
BL::SpaceView3D &b_v3d,
|
2016-01-30 14:18:29 +01:00
|
|
|
BL::Object &b_override,
|
2025-01-01 18:15:54 +01:00
|
|
|
const int width,
|
|
|
|
|
const int height,
|
2015-07-21 15:36:35 +02:00
|
|
|
void **python_thread_state);
|
Cycles: merge of cycles-x branch, a major update to the renderer
This includes much improved GPU rendering performance, viewport interactivity,
new shadow catcher, revamped sampling settings, subsurface scattering anisotropy,
new GPU volume sampling, improved PMJ sampling pattern, and more.
Some features have also been removed or changed, breaking backwards compatibility.
Including the removal of the OpenCL backend, for which alternatives are under
development.
Release notes and code docs:
https://wiki.blender.org/wiki/Reference/Release_Notes/3.0/Cycles
https://wiki.blender.org/wiki/Source/Render/Cycles
Credits:
* Sergey Sharybin
* Brecht Van Lommel
* Patrick Mours (OptiX backend)
* Christophe Hery (subsurface scattering anisotropy)
* William Leeson (PMJ sampling pattern)
* Alaska (various fixes and tweaks)
* Thomas Dinges (various fixes)
For the full commit history, see the cycles-x branch. This squashes together
all the changes since intermediate changes would often fail building or tests.
Ref T87839, T87837, T87836
Fixes T90734, T89353, T80267, T80267, T77185, T69800
2021-09-20 17:59:20 +02:00
|
|
|
void sync_film(BL::ViewLayer &b_view_layer, BL::SpaceView3D &b_v3d);
|
2011-04-27 11:58:34 +00:00
|
|
|
void sync_view();
|
2020-02-02 13:09:18 +01:00
|
|
|
|
|
|
|
|
/* Shader */
|
2021-01-25 14:47:56 +01:00
|
|
|
array<Node *> find_used_shaders(BL::Object &b_ob);
|
2019-08-27 15:47:30 +02:00
|
|
|
void sync_world(BL::Depsgraph &b_depsgraph, BL::SpaceView3D &b_v3d, bool update_all);
|
2022-03-01 19:45:36 +01:00
|
|
|
void sync_shaders(BL::Depsgraph &b_depsgraph, BL::SpaceView3D &b_v3d, bool update_all);
|
2016-01-30 14:18:29 +01:00
|
|
|
void sync_nodes(Shader *shader, BL::ShaderNodeTree &b_ntree);
|
2020-02-02 13:09:18 +01:00
|
|
|
|
Attribute Node: support accessing attributes of View Layer and Scene.
The attribute node already allows accessing attributes associated
with objects and meshes, which allows changing the behavior of the
same material between different objects or instances. The same idea
can be extended to an even more global level of layers and scenes.
Currently view layers provide an option to replace all materials
with a different one. However, since the same material will be applied
to all objects in the layer, varying the behavior between layers while
preserving distinct materials requires duplicating objects.
Providing access to properties of layers and scenes via the attribute
node enables making materials with built-in switches or settings that
can be controlled globally at the view layer level. This is probably
most useful for complex NPR shading and compositing. Like with objects,
the node can also access built-in scene properties, like render resolution
or FOV of the active camera. Lookup is also attempted in World, similar
to how the Object mode checks the Mesh datablock.
In Cycles this mode is implemented by replacing the attribute node with
the attribute value during sync, allowing constant folding to take the
values into account. This means however that materials that use this
feature have to be re-synced upon any changes to scene, world or camera.
The Eevee version uses a new uniform buffer containing a sorted array
mapping name hashes to values, with binary search lookup. The array
is limited to 512 entries, which is effectively limitless even
considering it is shared by all materials in the scene; it is also
just 16KB of memory so no point trying to optimize further.
The buffer has to be rebuilt when new attributes are detected in a
material, so the draw engine keeps a table of recently seen attribute
names to minimize the chance of extra rebuilds mid-draw.
Differential Revision: https://developer.blender.org/D15941
2022-09-12 00:30:58 +03:00
|
|
|
bool scene_attr_needs_recalc(Shader *shader, BL::Depsgraph &b_depsgraph);
|
|
|
|
|
void resolve_view_layer_attributes(Shader *shader,
|
|
|
|
|
ShaderGraph *graph,
|
|
|
|
|
BL::Depsgraph &b_depsgraph);
|
|
|
|
|
|
2020-02-02 13:09:18 +01:00
|
|
|
/* Object */
|
2018-02-26 16:46:48 +01:00
|
|
|
Object *sync_object(BL::Depsgraph &b_depsgraph,
|
2018-07-25 12:26:09 +02:00
|
|
|
BL::ViewLayer &b_view_layer,
|
2018-05-30 15:21:21 +02:00
|
|
|
BL::DepsgraphObjectInstance &b_instance,
|
2025-01-01 18:15:54 +01:00
|
|
|
const float motion_time,
|
2020-02-02 13:09:18 +01:00
|
|
|
bool use_particle_hair,
|
2019-08-27 15:47:30 +02:00
|
|
|
bool show_lights,
|
2016-11-13 00:45:16 +01:00
|
|
|
BlenderObjectCulling &culling,
|
2020-10-21 16:38:36 +02:00
|
|
|
TaskPool *geom_task_pool);
|
2021-05-11 14:22:40 +02:00
|
|
|
void sync_object_motion_init(BL::Object &b_parent, BL::Object &b_ob, Object *object);
|
2020-02-02 13:09:18 +01:00
|
|
|
|
2021-08-20 02:30:50 +02:00
|
|
|
void sync_procedural(BL::Object &b_ob,
|
|
|
|
|
BL::MeshSequenceCacheModifier &b_mesh_cache,
|
|
|
|
|
bool has_subdivision);
|
2021-08-19 14:34:01 +02:00
|
|
|
|
Materials: add custom object properties as uniform attributes.
This patch allows the user to type a property name into the
Attribute node, which will then output the value of the property
for each individual object, allowing to e.g. customize shaders
by object without duplicating the shader.
In order to make supporting this easier for Eevee, it is necessary
to explicitly choose whether the attribute is varying or uniform
via a dropdown option of the Attribute node. The dropdown also
allows choosing whether instancing should be taken into account.
The Cycles design treats all attributes as one common namespace,
so the Blender interface converts the enum to a name prefix that
can't be entered using keyboard.
In Eevee, the attributes are provided to the shader via a UBO indexed
with resource_id, similar to the existing Object Info data. Unlike it,
however, it is necessary to maintain a separate buffer for every
requested combination of attributes.
This is done using a hash table with the attribute set as the key,
as it is expected that technically different but similar materials
may use the same set of attributes. In addition, in order to minimize
wasted memory, a sparse UBO pool is implemented, so that chunks that
don't contain any data don't have to be allocated.
The back-end Cycles code is already refactored and committed by Brecht.
Differential Revision: https://developer.blender.org/D2057
2020-08-05 19:14:40 +03:00
|
|
|
bool sync_object_attributes(BL::DepsgraphObjectInstance &b_instance, Object *object);
|
|
|
|
|
|
2020-02-02 13:09:18 +01:00
|
|
|
/* Volume */
|
2021-09-06 18:22:24 +02:00
|
|
|
void sync_volume(BObjectInfo &b_ob_info, Volume *volume);
|
2020-02-02 13:09:18 +01:00
|
|
|
|
|
|
|
|
/* Mesh */
|
2021-09-06 18:22:24 +02:00
|
|
|
void sync_mesh(BL::Depsgraph b_depsgraph, BObjectInfo &b_ob_info, Mesh *mesh);
|
|
|
|
|
void sync_mesh_motion(BL::Depsgraph b_depsgraph,
|
|
|
|
|
BObjectInfo &b_ob_info,
|
|
|
|
|
Mesh *mesh,
|
|
|
|
|
int motion_step);
|
2020-02-02 13:09:18 +01:00
|
|
|
|
|
|
|
|
/* Hair */
|
2021-09-06 18:22:24 +02:00
|
|
|
void sync_hair(BL::Depsgraph b_depsgraph, BObjectInfo &b_ob_info, Hair *hair);
|
|
|
|
|
void sync_hair_motion(BL::Depsgraph b_depsgraph,
|
|
|
|
|
BObjectInfo &b_ob_info,
|
|
|
|
|
Hair *hair,
|
|
|
|
|
int motion_step);
|
2025-01-01 18:15:54 +01:00
|
|
|
void sync_hair(Hair *hair, BObjectInfo &b_ob_info, bool motion, const int motion_step = 0);
|
|
|
|
|
void sync_particle_hair(Hair *hair,
|
|
|
|
|
BL::Mesh &b_mesh,
|
|
|
|
|
BObjectInfo &b_ob_info,
|
|
|
|
|
bool motion,
|
|
|
|
|
const int motion_step = 0);
|
2020-02-02 13:09:18 +01:00
|
|
|
bool object_has_particle_hair(BL::Object b_ob);
|
|
|
|
|
|
2021-12-01 17:30:46 +01:00
|
|
|
/* Point Cloud */
|
|
|
|
|
void sync_pointcloud(PointCloud *pointcloud, BObjectInfo &b_ob_info);
|
2025-01-01 18:15:54 +01:00
|
|
|
void sync_pointcloud_motion(PointCloud *pointcloud,
|
|
|
|
|
BObjectInfo &b_ob_info,
|
|
|
|
|
const int motion_step = 0);
|
2021-12-01 17:30:46 +01:00
|
|
|
|
2020-02-02 13:09:18 +01:00
|
|
|
/* Camera */
|
2025-01-01 18:15:54 +01:00
|
|
|
void sync_camera_motion(BL::RenderSettings &b_render,
|
|
|
|
|
BL::Object &b_ob,
|
|
|
|
|
const int width,
|
|
|
|
|
const int height,
|
|
|
|
|
const float motion_time);
|
2020-02-02 13:09:18 +01:00
|
|
|
|
|
|
|
|
/* Geometry */
|
2021-12-01 17:30:46 +01:00
|
|
|
Geometry *sync_geometry(BL::Depsgraph &b_depsgraph,
|
2021-09-06 18:22:24 +02:00
|
|
|
BObjectInfo &b_ob_info,
|
2020-02-02 12:04:19 +01:00
|
|
|
bool object_updated,
|
2020-10-21 16:38:36 +02:00
|
|
|
bool use_particle_hair,
|
|
|
|
|
TaskPool *task_pool);
|
|
|
|
|
|
2020-02-02 13:09:18 +01:00
|
|
|
void sync_geometry_motion(BL::Depsgraph &b_depsgraph,
|
2021-09-06 18:22:24 +02:00
|
|
|
BObjectInfo &b_ob_info,
|
2020-02-02 13:09:18 +01:00
|
|
|
Object *object,
|
2025-01-01 18:15:54 +01:00
|
|
|
const float motion_time,
|
2020-10-21 16:38:36 +02:00
|
|
|
bool use_particle_hair,
|
|
|
|
|
TaskPool *task_pool);
|
2020-02-02 13:09:18 +01:00
|
|
|
|
|
|
|
|
/* Light */
|
2025-02-24 23:44:14 +01:00
|
|
|
void sync_light(BL::Depsgraph b_depsgraph, BObjectInfo &b_ob_info, Light *light);
|
|
|
|
|
void sync_background_light(BL::SpaceView3D &b_v3d);
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2020-02-02 13:09:18 +01:00
|
|
|
/* Particles */
|
2016-01-30 14:18:29 +01:00
|
|
|
bool sync_dupli_particle(BL::Object &b_ob,
|
2018-05-30 15:21:21 +02:00
|
|
|
BL::DepsgraphObjectInstance &b_instance,
|
2016-01-30 14:18:29 +01:00
|
|
|
Object *object);
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2015-04-02 19:24:14 +05:00
|
|
|
/* Images. */
|
|
|
|
|
void sync_images();
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2011-04-27 11:58:34 +00:00
|
|
|
/* util */
|
2025-02-24 23:44:14 +01:00
|
|
|
void find_shader(const BL::ID &id, array<Node *> &used_shaders, Shader *default_shader);
|
2016-01-30 14:18:29 +01:00
|
|
|
bool BKE_object_is_modified(BL::Object &b_ob);
|
2021-11-10 13:38:07 +01:00
|
|
|
bool object_is_geometry(BObjectInfo &b_ob_info);
|
|
|
|
|
bool object_can_have_geometry(BL::Object &b_ob);
|
2016-01-30 14:18:29 +01:00
|
|
|
bool object_is_light(BL::Object &b_ob);
|
Attribute Node: support accessing attributes of View Layer and Scene.
The attribute node already allows accessing attributes associated
with objects and meshes, which allows changing the behavior of the
same material between different objects or instances. The same idea
can be extended to an even more global level of layers and scenes.
Currently view layers provide an option to replace all materials
with a different one. However, since the same material will be applied
to all objects in the layer, varying the behavior between layers while
preserving distinct materials requires duplicating objects.
Providing access to properties of layers and scenes via the attribute
node enables making materials with built-in switches or settings that
can be controlled globally at the view layer level. This is probably
most useful for complex NPR shading and compositing. Like with objects,
the node can also access built-in scene properties, like render resolution
or FOV of the active camera. Lookup is also attempted in World, similar
to how the Object mode checks the Mesh datablock.
In Cycles this mode is implemented by replacing the attribute node with
the attribute value during sync, allowing constant folding to take the
values into account. This means however that materials that use this
feature have to be re-synced upon any changes to scene, world or camera.
The Eevee version uses a new uniform buffer containing a sorted array
mapping name hashes to values, with binary search lookup. The array
is limited to 512 entries, which is effectively limitless even
considering it is shared by all materials in the scene; it is also
just 16KB of memory so no point trying to optimize further.
The buffer has to be rebuilt when new attributes are detected in a
material, so the draw engine keeps a table of recently seen attribute
names to minimize the chance of extra rebuilds mid-draw.
Differential Revision: https://developer.blender.org/D15941
2022-09-12 00:30:58 +03:00
|
|
|
bool object_is_camera(BL::Object &b_ob);
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2011-04-27 11:58:34 +00:00
|
|
|
/* variables */
|
2012-09-04 13:29:07 +00:00
|
|
|
BL::RenderEngine b_engine;
|
2011-04-27 11:58:34 +00:00
|
|
|
BL::BlendData b_data;
|
|
|
|
|
BL::Scene b_scene;
|
2025-01-02 12:48:21 +01:00
|
|
|
BL::Object b_bake_target;
|
2019-04-17 06:17:24 +02:00
|
|
|
|
Attribute Node: support accessing attributes of View Layer and Scene.
The attribute node already allows accessing attributes associated
with objects and meshes, which allows changing the behavior of the
same material between different objects or instances. The same idea
can be extended to an even more global level of layers and scenes.
Currently view layers provide an option to replace all materials
with a different one. However, since the same material will be applied
to all objects in the layer, varying the behavior between layers while
preserving distinct materials requires duplicating objects.
Providing access to properties of layers and scenes via the attribute
node enables making materials with built-in switches or settings that
can be controlled globally at the view layer level. This is probably
most useful for complex NPR shading and compositing. Like with objects,
the node can also access built-in scene properties, like render resolution
or FOV of the active camera. Lookup is also attempted in World, similar
to how the Object mode checks the Mesh datablock.
In Cycles this mode is implemented by replacing the attribute node with
the attribute value during sync, allowing constant folding to take the
values into account. This means however that materials that use this
feature have to be re-synced upon any changes to scene, world or camera.
The Eevee version uses a new uniform buffer containing a sorted array
mapping name hashes to values, with binary search lookup. The array
is limited to 512 entries, which is effectively limitless even
considering it is shared by all materials in the scene; it is also
just 16KB of memory so no point trying to optimize further.
The buffer has to be rebuilt when new attributes are detected in a
material, so the draw engine keeps a table of recently seen attribute
names to minimize the chance of extra rebuilds mid-draw.
Differential Revision: https://developer.blender.org/D15941
2022-09-12 00:30:58 +03:00
|
|
|
enum ShaderFlags { SHADER_WITH_LAYER_ATTRS };
|
|
|
|
|
|
|
|
|
|
id_map<void *, Shader, ShaderFlags> shader_map;
|
2011-04-27 11:58:34 +00:00
|
|
|
id_map<ObjectKey, Object> object_map;
|
2021-08-19 14:34:01 +02:00
|
|
|
id_map<void *, Procedural> procedural_map;
|
2020-02-02 12:04:19 +01:00
|
|
|
id_map<GeometryKey, Geometry> geometry_map;
|
2012-08-31 17:27:08 +00:00
|
|
|
id_map<ParticleSystemKey, ParticleSystem> particle_system_map;
|
2020-02-02 12:04:19 +01:00
|
|
|
set<Geometry *> geometry_synced;
|
|
|
|
|
set<Geometry *> geometry_motion_synced;
|
2021-09-09 17:22:20 +02:00
|
|
|
set<Geometry *> geometry_motion_attribute_synced;
|
2021-11-04 18:32:01 +01:00
|
|
|
/** Remember which geometries come from which objects to be able to sync them after changes. */
|
|
|
|
|
map<void *, set<BL::ID>> instance_geometries_by_object;
|
2016-10-24 12:31:11 +02:00
|
|
|
set<float> motion_times;
|
2011-04-27 11:58:34 +00:00
|
|
|
void *world_map;
|
|
|
|
|
bool world_recalc;
|
2025-02-24 23:44:14 +01:00
|
|
|
bool world_use_portal = false;
|
2019-08-27 15:47:30 +02:00
|
|
|
BlenderViewportParameters viewport_parameters;
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2011-04-27 11:58:34 +00:00
|
|
|
Scene *scene;
|
|
|
|
|
bool preview;
|
2011-12-01 16:33:21 +00:00
|
|
|
bool experimental;
|
Cycles: merge of cycles-x branch, a major update to the renderer
This includes much improved GPU rendering performance, viewport interactivity,
new shadow catcher, revamped sampling settings, subsurface scattering anisotropy,
new GPU volume sampling, improved PMJ sampling pattern, and more.
Some features have also been removed or changed, breaking backwards compatibility.
Including the removal of the OpenCL backend, for which alternatives are under
development.
Release notes and code docs:
https://wiki.blender.org/wiki/Reference/Release_Notes/3.0/Cycles
https://wiki.blender.org/wiki/Source/Render/Cycles
Credits:
* Sergey Sharybin
* Brecht Van Lommel
* Patrick Mours (OptiX backend)
* Christophe Hery (subsurface scattering anisotropy)
* William Leeson (PMJ sampling pattern)
* Alaska (various fixes and tweaks)
* Thomas Dinges (various fixes)
For the full commit history, see the cycles-x branch. This squashes together
all the changes since intermediate changes would often fail building or tests.
Ref T87839, T87837, T87836
Fixes T90734, T89353, T80267, T80267, T77185, T69800
2021-09-20 17:59:20 +02:00
|
|
|
bool use_developer_ui;
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2016-04-17 20:15:50 +02:00
|
|
|
float dicing_rate;
|
2016-04-18 22:35:49 +02:00
|
|
|
int max_subdivisions;
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2011-09-12 13:13:56 +00:00
|
|
|
struct RenderLayerInfo {
|
2024-12-26 17:53:59 +01:00
|
|
|
RenderLayerInfo() : material_override(PointerRNA_NULL), world_override(PointerRNA_NULL) {}
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2012-02-07 20:51:33 +00:00
|
|
|
string name;
|
2018-12-28 18:37:05 +01:00
|
|
|
BL::Material material_override;
|
2024-02-09 12:16:16 +01:00
|
|
|
BL::World world_override;
|
2024-12-26 17:53:59 +01:00
|
|
|
bool use_background_shader = true;
|
|
|
|
|
bool use_surfaces = true;
|
|
|
|
|
bool use_hair = true;
|
|
|
|
|
bool use_volumes = true;
|
|
|
|
|
bool use_motion_blur = true;
|
|
|
|
|
int samples = 0;
|
|
|
|
|
bool bound_samples = false;
|
2017-11-22 10:52:39 -02:00
|
|
|
} view_layer;
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2012-09-04 13:29:07 +00:00
|
|
|
Progress &progress;
|
2021-05-17 18:23:44 +02:00
|
|
|
|
|
|
|
|
/* Indicates that `sync_recalc()` detected changes in the scene.
|
|
|
|
|
* If this flag is false then the data is considered to be up-to-date and will not be
|
|
|
|
|
* synchronized at all. */
|
|
|
|
|
bool has_updates_ = true;
|
2012-09-04 13:29:07 +00:00
|
|
|
};
|
2012-07-23 14:48:19 +00:00
|
|
|
|
2011-04-27 11:58:34 +00:00
|
|
|
CCL_NAMESPACE_END
|