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
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
#ifndef __BLENDER_SYNC_H__
|
|
|
|
|
#define __BLENDER_SYNC_H__
|
|
|
|
|
|
|
|
|
|
#include "MEM_guardedalloc.h"
|
|
|
|
|
#include "RNA_types.h"
|
|
|
|
|
#include "RNA_access.h"
|
|
|
|
|
#include "RNA_blender_cpp.h"
|
|
|
|
|
|
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_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 "render/scene.h"
|
|
|
|
|
#include "render/session.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_map.h"
|
|
|
|
|
#include "util/util_set.h"
|
|
|
|
|
#include "util/util_transform.h"
|
|
|
|
|
#include "util/util_vector.h"
|
2011-04-27 11:58:34 +00:00
|
|
|
|
|
|
|
|
CCL_NAMESPACE_BEGIN
|
|
|
|
|
|
|
|
|
|
class Background;
|
2016-11-13 00:45:16 +01:00
|
|
|
class BlenderObjectCulling;
|
2011-04-27 11:58:34 +00:00
|
|
|
class Camera;
|
|
|
|
|
class Film;
|
|
|
|
|
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;
|
2017-11-22 10:52:39 -02:00
|
|
|
class ViewLayer;
|
2011-04-27 11:58:34 +00:00
|
|
|
class Shader;
|
|
|
|
|
class ShaderGraph;
|
|
|
|
|
class ShaderNode;
|
|
|
|
|
|
|
|
|
|
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,
|
2017-10-08 04:32:25 +02:00
|
|
|
Progress &progress);
|
2011-04-27 11:58:34 +00:00
|
|
|
~BlenderSync();
|
|
|
|
|
|
|
|
|
|
/* sync */
|
2018-05-29 15:57:14 +02:00
|
|
|
void sync_recalc(BL::Depsgraph& b_depsgraph);
|
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,
|
2015-07-21 15:36:35 +02:00
|
|
|
int width, int height,
|
2018-02-26 16:46:48 +01:00
|
|
|
void **python_thread_state);
|
|
|
|
|
void sync_view_layer(BL::SpaceView3D& b_v3d, BL::ViewLayer& b_view_layer);
|
2018-10-28 16:41:30 +01:00
|
|
|
vector<Pass> sync_render_passes(BL::RenderLayer& b_render_layer,
|
|
|
|
|
BL::ViewLayer& b_view_layer,
|
2018-10-28 05:37:41 -04:00
|
|
|
const SessionParams &session_params);
|
2013-06-12 20:47:48 +00:00
|
|
|
void sync_integrator();
|
2016-01-30 14:18:29 +01:00
|
|
|
void sync_camera(BL::RenderSettings& b_render,
|
|
|
|
|
BL::Object& b_override,
|
Multi-View: Cycles - Spherical Stereo support (VR Panoramas)
This is a new option for panorama cameras to render
stereo that can be used in virtual reality devices
The option is available under the camera panel when Multi-View is enabled (Views option in the Render Layers panel)
Known limitations:
------------------
* Parallel convergence is not supported (you need to set a convergence distance really high to simulate this effect).
* Pivot was not supposed to affect the render but it does, this has to be looked at, but for now set it to CENTER
* Derivatives in perspective camera need to be pre-computed or we shuld get rid of kcam->dx/dy (Sergey words, I don't fully grasp the implication shere)
* This works in perspective mode and in panorama mode. However, for fully benefit from this effect in perspective mode you need to render a cube map. (there is an addon for this, developed separately, perhaps we could include it in master).
* We have no support for "neck distance" at the moment. This is supposed to help with objects at short distances.
* We have no support to rotate the "Up Axis" of the stereo plane. Meaning, we hardcode 0,0,1 as UP, and create the stereo pair related to that. (although we could take the camera local UP when rendering panoramas, this wouldn't work for perspective cameras.
* We have no support for interocular distance attenuation based on the proximity of the poles (which helps to reduce the pole rotation effect/artifact).
THIS NEEDS DOCS - both in 2.78 release log and the Blender manual.
Meanwhile you can read about it here: http://code.blender.org/2015/03/1451
This patch specifically dates from March 2015, as you can see in the code.blender.org post. Many thanks to all the reviewers, testers and minor sponsors who helped me maintain spherical-stereo for 1 year.
All that said, have fun with this. This feature was what got me started with Multi-View development (at the time what I was looking for was Fulldome stereo support, but the implementation is the same). In order to make this into Blender I had to make it aiming at a less-specic user-case Thus Multi-View started. (this was December 2012, during Siggraph Asia and a chat I had with Paul Bourke during the conference). I don't have the original patch anymore, but you can find a re-based version of it from March 2013, right before I start with the Multi-View project https://developer.blender.org/P332
Reviewers: sergey, dingto
Subscribers: #cycles
Differential Revision: https://developer.blender.org/D1223
2016-03-10 09:28:29 -03:00
|
|
|
int width, int height,
|
2016-03-12 15:00:06 +05:00
|
|
|
const char *viewname);
|
2016-01-30 14:18:29 +01:00
|
|
|
void sync_view(BL::SpaceView3D& b_v3d,
|
|
|
|
|
BL::RegionView3D& b_rv3d,
|
|
|
|
|
int width, int height);
|
2018-12-28 18:37:05 +01:00
|
|
|
inline int get_layer_samples() { return view_layer.samples; }
|
|
|
|
|
inline int get_layer_bound_samples() { return view_layer.bound_samples; }
|
2011-04-27 11:58:34 +00:00
|
|
|
|
|
|
|
|
/* get parameters */
|
2016-01-30 14:18:29 +01:00
|
|
|
static SceneParams get_scene_params(BL::Scene& b_scene,
|
2017-10-08 04:32:25 +02:00
|
|
|
bool background);
|
2016-01-30 14:18:29 +01:00
|
|
|
static SessionParams get_session_params(BL::RenderEngine& b_engine,
|
2018-12-21 12:47:44 +11:00
|
|
|
BL::Preferences& b_userpref,
|
2016-01-30 14:18:29 +01:00
|
|
|
BL::Scene& b_scene,
|
2015-02-18 21:16:52 +05:00
|
|
|
bool background);
|
2016-01-30 14:18:29 +01:00
|
|
|
static bool get_session_pause(BL::Scene& b_scene, bool background);
|
|
|
|
|
static BufferParams get_buffer_params(BL::RenderSettings& b_render,
|
|
|
|
|
BL::SpaceView3D& b_v3d,
|
|
|
|
|
BL::RegionView3D& b_rv3d,
|
|
|
|
|
Camera *cam,
|
|
|
|
|
int width, int height);
|
2011-04-27 11:58:34 +00:00
|
|
|
|
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
|
|
|
static PassType get_pass_type(BL::RenderPass& b_pass);
|
2017-05-07 14:40:58 +02:00
|
|
|
static int get_denoising_pass(BL::RenderPass& b_pass);
|
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
|
|
|
|
2011-04-27 11:58:34 +00:00
|
|
|
private:
|
|
|
|
|
/* 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);
|
|
|
|
|
void sync_objects(BL::Depsgraph& b_depsgraph, 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,
|
2016-01-30 14:18:29 +01:00
|
|
|
BL::Object& b_override,
|
2015-07-21 15:36:35 +02:00
|
|
|
int width, int height,
|
|
|
|
|
void **python_thread_state);
|
2011-04-27 11:58:34 +00:00
|
|
|
void sync_film();
|
|
|
|
|
void sync_view();
|
2018-02-27 18:20:55 -03:00
|
|
|
void sync_world(BL::Depsgraph& b_depsgraph, bool update_all);
|
2018-02-26 16:46:48 +01:00
|
|
|
void sync_shaders(BL::Depsgraph& b_depsgraph);
|
2012-12-28 14:21:30 +00:00
|
|
|
void sync_curve_settings();
|
2011-04-27 11:58:34 +00:00
|
|
|
|
2016-01-30 14:18:29 +01:00
|
|
|
void sync_nodes(Shader *shader, BL::ShaderNodeTree& b_ntree);
|
2018-02-26 16:46:48 +01:00
|
|
|
Mesh *sync_mesh(BL::Depsgraph& b_depsgrpah,
|
|
|
|
|
BL::Object& b_ob,
|
2017-06-06 16:27:02 +02:00
|
|
|
BL::Object& b_ob_instance,
|
|
|
|
|
bool object_updated,
|
2018-12-18 18:18:00 +01:00
|
|
|
bool show_self,
|
|
|
|
|
bool show_particles);
|
2018-04-08 09:28:52 +02:00
|
|
|
void sync_curves(Mesh *mesh,
|
2016-01-30 14:18:29 +01:00
|
|
|
BL::Mesh& b_mesh,
|
|
|
|
|
BL::Object& b_ob,
|
|
|
|
|
bool motion,
|
2018-03-10 00:37:07 +01:00
|
|
|
int motion_step = 0);
|
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,
|
2015-04-10 18:09:58 +05:00
|
|
|
float motion_time,
|
2018-12-18 18:18:00 +01:00
|
|
|
bool show_self,
|
|
|
|
|
bool show_particles,
|
2016-11-13 00:45:16 +01:00
|
|
|
BlenderObjectCulling& culling,
|
2015-04-10 18:09:58 +05:00
|
|
|
bool *use_portal);
|
2016-01-30 14:18:29 +01:00
|
|
|
void sync_light(BL::Object& b_parent,
|
|
|
|
|
int persistent_id[OBJECT_PERSISTENT_ID_SIZE],
|
|
|
|
|
BL::Object& b_ob,
|
2017-06-06 16:27:02 +02:00
|
|
|
BL::Object& b_ob_instance,
|
2017-11-15 07:11:01 -02:00
|
|
|
int random_id,
|
2016-01-30 14:18:29 +01:00
|
|
|
Transform& tfm,
|
|
|
|
|
bool *use_portal);
|
Cycles: Added support for light portals
This patch adds support for light portals: objects that help sampling the
environment light, therefore improving convergence. Using them tor other
lights in a unidirectional pathtracer is virtually useless.
The sampling is done with the area-preserving code already used for area lamps.
MIS is used both for combination of different portals and for combining portal-
and envmap-sampling.
The direction of portals is considered, they aren't used if the sampling point
is behind them.
Reviewers: sergey, dingto, #cycles
Reviewed By: dingto, #cycles
Subscribers: Lapineige, nutel, jtheninja, dsisco11, januz, vitorbalbio, candreacchio, TARDISMaker, lichtwerk, ace_dragon, marcog, mib2berlin, Tunge, lopataasdf, lordodin, sergey, dingto
Differential Revision: https://developer.blender.org/D1133
2015-04-28 00:51:55 +05:00
|
|
|
void sync_background_light(bool use_portal);
|
2018-02-26 16:46:48 +01:00
|
|
|
void sync_mesh_motion(BL::Depsgraph& b_depsgraph,
|
|
|
|
|
BL::Object& b_ob,
|
2016-07-16 18:56:59 +02:00
|
|
|
Object *object,
|
|
|
|
|
float motion_time);
|
2016-01-30 14:18:29 +01:00
|
|
|
void sync_camera_motion(BL::RenderSettings& b_render,
|
|
|
|
|
BL::Object& b_ob,
|
2015-07-21 15:36:35 +02:00
|
|
|
int width, int height,
|
|
|
|
|
float motion_time);
|
2012-11-08 16:35:28 +00: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);
|
2011-04-27 11:58:34 +00:00
|
|
|
|
2015-04-02 19:24:14 +05:00
|
|
|
/* Images. */
|
|
|
|
|
void sync_images();
|
|
|
|
|
|
2018-07-18 16:09:19 +02:00
|
|
|
/* Early data free. */
|
|
|
|
|
void free_data_after_sync(BL::Depsgraph& b_depsgraph);
|
|
|
|
|
|
2011-04-27 11:58:34 +00:00
|
|
|
/* util */
|
2016-05-14 14:50:03 +02:00
|
|
|
void find_shader(BL::ID& id, vector<Shader*>& used_shaders, Shader *default_shader);
|
2016-01-30 14:18:29 +01:00
|
|
|
bool BKE_object_is_modified(BL::Object& b_ob);
|
|
|
|
|
bool object_is_mesh(BL::Object& b_ob);
|
|
|
|
|
bool object_is_light(BL::Object& b_ob);
|
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;
|
|
|
|
|
|
|
|
|
|
id_map<void*, Shader> shader_map;
|
|
|
|
|
id_map<ObjectKey, Object> object_map;
|
|
|
|
|
id_map<void*, Mesh> mesh_map;
|
2011-05-31 10:41:01 +00:00
|
|
|
id_map<ObjectKey, Light> light_map;
|
2012-08-31 17:27:08 +00:00
|
|
|
id_map<ParticleSystemKey, ParticleSystem> particle_system_map;
|
2011-05-31 10:57:43 +00:00
|
|
|
set<Mesh*> mesh_synced;
|
2013-10-17 16:05:57 +00:00
|
|
|
set<Mesh*> mesh_motion_synced;
|
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;
|
|
|
|
|
|
|
|
|
|
Scene *scene;
|
|
|
|
|
bool preview;
|
2011-12-01 16:33:21 +00:00
|
|
|
bool experimental;
|
2011-09-12 13:13:56 +00:00
|
|
|
|
2016-04-17 20:15:50 +02:00
|
|
|
float dicing_rate;
|
2016-04-18 22:35:49 +02:00
|
|
|
int max_subdivisions;
|
2016-04-17 20:15:50 +02:00
|
|
|
|
2011-09-12 13:13:56 +00:00
|
|
|
struct RenderLayerInfo {
|
|
|
|
|
RenderLayerInfo()
|
2018-12-28 18:37:05 +01:00
|
|
|
: material_override(PointerRNA_NULL),
|
|
|
|
|
use_background_shader(true),
|
2015-11-24 13:21:40 +05:00
|
|
|
use_background_ao(true),
|
2013-05-10 13:34:49 +00:00
|
|
|
use_surfaces(true),
|
2018-12-28 18:37:05 +01:00
|
|
|
use_hair(true),
|
|
|
|
|
samples(0),
|
|
|
|
|
bound_samples(false)
|
2011-09-12 13:13:56 +00:00
|
|
|
{}
|
|
|
|
|
|
2012-02-07 20:51:33 +00:00
|
|
|
string name;
|
2018-12-28 18:37:05 +01:00
|
|
|
BL::Material material_override;
|
2015-11-24 13:21:40 +05:00
|
|
|
bool use_background_shader;
|
|
|
|
|
bool use_background_ao;
|
2013-05-10 13:34:49 +00:00
|
|
|
bool use_surfaces;
|
|
|
|
|
bool use_hair;
|
2018-12-28 18:37:05 +01:00
|
|
|
int samples;
|
|
|
|
|
bool bound_samples;
|
2017-11-22 10:52:39 -02:00
|
|
|
} view_layer;
|
2011-04-27 11:58:34 +00:00
|
|
|
|
2012-09-04 13:29:07 +00:00
|
|
|
Progress &progress;
|
|
|
|
|
};
|
2012-07-23 14:48:19 +00:00
|
|
|
|
2011-04-27 11:58:34 +00:00
|
|
|
CCL_NAMESPACE_END
|
|
|
|
|
|
2018-11-09 11:34:54 +01:00
|
|
|
#endif /* __BLENDER_SYNC_H__ */
|