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"
|
|
|
|
|
|
|
|
|
|
#include "blender_util.h"
|
|
|
|
|
|
|
|
|
|
#include "scene.h"
|
|
|
|
|
#include "session.h"
|
|
|
|
|
|
|
|
|
|
#include "util_map.h"
|
|
|
|
|
#include "util_set.h"
|
|
|
|
|
#include "util_transform.h"
|
|
|
|
|
#include "util_vector.h"
|
|
|
|
|
|
|
|
|
|
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;
|
|
|
|
|
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,
|
|
|
|
|
Progress &progress,
|
|
|
|
|
bool is_cpu);
|
2011-04-27 11:58:34 +00:00
|
|
|
~BlenderSync();
|
|
|
|
|
|
|
|
|
|
/* sync */
|
|
|
|
|
bool sync_recalc();
|
2016-01-30 14:18:29 +01:00
|
|
|
void sync_data(BL::RenderSettings& b_render,
|
|
|
|
|
BL::SpaceView3D& b_v3d,
|
|
|
|
|
BL::Object& b_override,
|
2015-07-21 15:36:35 +02:00
|
|
|
int width, int height,
|
|
|
|
|
void **python_thread_state,
|
|
|
|
|
const char *layer = 0);
|
2016-01-30 14:18:29 +01:00
|
|
|
void sync_render_layers(BL::SpaceView3D& b_v3d, const char *layer);
|
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);
|
|
|
|
|
inline int get_layer_samples() { return render_layer.samples; }
|
|
|
|
|
inline int get_layer_bound_samples() { return render_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,
|
|
|
|
|
bool background,
|
|
|
|
|
bool is_cpu);
|
|
|
|
|
static SessionParams get_session_params(BL::RenderEngine& b_engine,
|
|
|
|
|
BL::UserPreferences& b_userpref,
|
|
|
|
|
BL::Scene& b_scene,
|
2015-02-18 21:16:52 +05:00
|
|
|
bool background);
|
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
|
|
|
|
|
|
|
|
private:
|
|
|
|
|
/* sync */
|
2012-11-21 13:00:51 +00:00
|
|
|
void sync_lamps(bool update_all);
|
|
|
|
|
void sync_materials(bool update_all);
|
2016-01-30 14:18:29 +01:00
|
|
|
void sync_objects(BL::SpaceView3D& b_v3d, float motion_time = 0.0f);
|
|
|
|
|
void sync_motion(BL::RenderSettings& b_render,
|
|
|
|
|
BL::SpaceView3D& b_v3d,
|
|
|
|
|
BL::Object& b_override,
|
2015-07-21 15:36:35 +02:00
|
|
|
int width, int height,
|
|
|
|
|
void **python_thread_state);
|
2011-04-27 11:58:34 +00:00
|
|
|
void sync_film();
|
|
|
|
|
void sync_view();
|
2012-11-21 13:00:51 +00:00
|
|
|
void sync_world(bool update_all);
|
2011-04-27 11:58:34 +00:00
|
|
|
void sync_shaders();
|
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);
|
|
|
|
|
Mesh *sync_mesh(BL::Object& b_ob, bool object_updated, bool hide_tris);
|
|
|
|
|
void sync_curves(Mesh *mesh,
|
|
|
|
|
BL::Mesh& b_mesh,
|
|
|
|
|
BL::Object& b_ob,
|
|
|
|
|
bool motion,
|
|
|
|
|
int time_index = 0);
|
|
|
|
|
Object *sync_object(BL::Object& b_parent,
|
2015-04-10 18:09:58 +05:00
|
|
|
int persistent_id[OBJECT_PERSISTENT_ID_SIZE],
|
2016-01-30 14:18:29 +01:00
|
|
|
BL::DupliObject& b_dupli_ob,
|
2015-04-10 18:09:58 +05:00
|
|
|
Transform& tfm,
|
|
|
|
|
uint layer_flag,
|
|
|
|
|
float motion_time,
|
|
|
|
|
bool hide_tris,
|
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,
|
|
|
|
|
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);
|
2016-07-16 18:56:59 +02:00
|
|
|
void sync_mesh_motion(BL::Object& b_ob,
|
|
|
|
|
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,
|
|
|
|
|
BL::DupliObject& b_dup,
|
|
|
|
|
Object *object);
|
2011-04-27 11:58:34 +00:00
|
|
|
|
2015-04-02 19:24:14 +05:00
|
|
|
/* Images. */
|
|
|
|
|
void sync_images();
|
|
|
|
|
|
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;
|
2012-12-28 14:21:30 +00:00
|
|
|
bool is_cpu;
|
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()
|
2012-11-09 23:28:51 +00:00
|
|
|
: scene_layer(0), layer(0),
|
|
|
|
|
holdout_layer(0), exclude_layer(0),
|
2012-04-13 12:58:12 +00:00
|
|
|
material_override(PointerRNA_NULL),
|
2015-11-24 13:21:40 +05:00
|
|
|
use_background_shader(true),
|
|
|
|
|
use_background_ao(true),
|
2013-05-10 13:34:49 +00:00
|
|
|
use_surfaces(true),
|
|
|
|
|
use_hair(true),
|
2012-05-05 10:17:18 +00:00
|
|
|
use_viewport_visibility(false),
|
2013-04-16 16:18:14 +00:00
|
|
|
samples(0), bound_samples(false)
|
2011-09-12 13:13:56 +00:00
|
|
|
{}
|
|
|
|
|
|
2012-02-07 20:51:33 +00:00
|
|
|
string name;
|
2011-09-12 13:13:56 +00:00
|
|
|
uint scene_layer;
|
|
|
|
|
uint layer;
|
2012-02-28 16:44:45 +00:00
|
|
|
uint holdout_layer;
|
2012-11-09 23:28:51 +00:00
|
|
|
uint exclude_layer;
|
2011-09-12 13:13:56 +00: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;
|
2012-05-05 10:17:18 +00:00
|
|
|
bool use_viewport_visibility;
|
Cycles: merging features from tomato branch.
=== BVH build time optimizations ===
* BVH building was multithreaded. Not all building is multithreaded, packing
and the initial bounding/splitting is still single threaded, but recursive
splitting is, which was the main bottleneck.
* Object splitting now uses binning rather than sorting of all elements, using
code from the Embree raytracer from Intel.
http://software.intel.com/en-us/articles/embree-photo-realistic-ray-tracing-kernels/
* Other small changes to avoid allocations, pack memory more tightly, avoid
some unnecessary operations, ...
These optimizations do not work yet when Spatial Splits are enabled, for that
more work is needed. There's also other optimizations still needed, in
particular for the case of many low poly objects, the packing step and node
memory allocation.
BVH raytracing time should remain about the same, but BVH build time should be
significantly reduced, test here show speedup of about 5x to 10x on a dual core
and 5x to 25x on an 8-core machine, depending on the scene.
=== Threads ===
Centralized task scheduler for multithreading, which is basically the
CPU device threading code wrapped into something reusable.
Basic idea is that there is a single TaskScheduler that keeps a pool of threads,
one for each core. Other places in the code can then create a TaskPool that they
can drop Tasks in to be executed by the scheduler, and wait for them to complete
or cancel them early.
=== Normal ====
Added a Normal output to the texture coordinate node. This currently
gives the object space normal, which is the same under object animation.
In the future this might become a "generated" normal so it's also stable for
deforming objects, but for now it's already useful for non-deforming objects.
=== Render Layers ===
Per render layer Samples control, leaving it to 0 will use the common scene
setting.
Environment pass will now render environment even if film is set to transparent.
Exclude Layers" added. Scene layers (all object that influence the render,
directly or indirectly) are shared between all render layers. However sometimes
it's useful to leave out some object influence for a particular render layer.
That's what this option allows you to do.
=== Filter Glossy ===
When using a value higher than 0.0, this will blur glossy reflections after
blurry bounces, to reduce noise at the cost of accuracy. 1.0 is a good
starting value to tweak.
Some light paths have a low probability of being found while contributing much
light to the pixel. As a result these light paths will be found in some pixels
and not in others, causing fireflies. An example of such a difficult path might
be a small light that is causing a small specular highlight on a sharp glossy
material, which we are seeing through a rough glossy material. With path tracing
it is difficult to find the specular highlight, but if we increase the roughness
on the material the highlight gets bigger and softer, and so easier to find.
Often this blurring will be hardly noticeable, because we are seeing it through
a blurry material anyway, but there are also cases where this will lead to a
loss of detail in lighting.
2012-04-28 08:53:59 +00:00
|
|
|
int samples;
|
2013-04-16 16:18:14 +00:00
|
|
|
bool bound_samples;
|
2012-02-28 16:44:45 +00:00
|
|
|
} render_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
|
|
|
|
|
|
|
|
|
|
#endif /* __BLENDER_SYNC_H__ */
|
|
|
|
|
|