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
|
|
|
#
|
|
|
|
|
|
2011-11-15 02:58:01 +00:00
|
|
|
# <pep8 compliant>
|
|
|
|
|
|
2011-04-27 11:58:34 +00:00
|
|
|
bl_info = {
|
|
|
|
|
"name": "Cycles Render Engine",
|
|
|
|
|
"author": "",
|
2017-04-25 16:18:24 +02:00
|
|
|
"blender": (2, 80, 0),
|
2011-04-27 11:58:34 +00:00
|
|
|
"location": "Info header, render engine menu",
|
2012-04-30 19:52:07 +00:00
|
|
|
"description": "Cycles Render Engine integration",
|
2011-04-27 11:58:34 +00:00
|
|
|
"warning": "",
|
2017-01-23 19:09:45 -05:00
|
|
|
"wiki_url": "https://docs.blender.org/manual/en/dev/render/cycles/",
|
2011-04-27 11:58:34 +00:00
|
|
|
"tracker_url": "",
|
2011-11-13 10:05:07 +00:00
|
|
|
"support": 'OFFICIAL',
|
2011-04-27 11:58:34 +00:00
|
|
|
"category": "Render"}
|
|
|
|
|
|
2017-01-22 12:42:14 +01:00
|
|
|
# Support 'reload' case.
|
|
|
|
|
if "bpy" in locals():
|
|
|
|
|
import importlib
|
|
|
|
|
if "engine" in locals():
|
|
|
|
|
importlib.reload(engine)
|
|
|
|
|
if "version_update" in locals():
|
|
|
|
|
importlib.reload(version_update)
|
|
|
|
|
if "ui" in locals():
|
|
|
|
|
importlib.reload(ui)
|
|
|
|
|
if "properties" in locals():
|
|
|
|
|
importlib.reload(properties)
|
|
|
|
|
if "presets" in locals():
|
|
|
|
|
importlib.reload(presets)
|
|
|
|
|
|
2011-04-27 11:58:34 +00:00
|
|
|
import bpy
|
|
|
|
|
|
2015-05-17 17:17:31 +10:00
|
|
|
from . import (
|
|
|
|
|
engine,
|
|
|
|
|
version_update,
|
|
|
|
|
)
|
2013-01-15 23:17:45 +00:00
|
|
|
|
2014-09-17 18:36:17 +10:00
|
|
|
|
2011-04-27 11:58:34 +00:00
|
|
|
class CyclesRender(bpy.types.RenderEngine):
|
2011-08-28 13:55:59 +00:00
|
|
|
bl_idname = 'CYCLES'
|
2018-04-22 10:21:40 +02:00
|
|
|
bl_label = "Cycles"
|
2011-10-11 17:19:55 +00:00
|
|
|
bl_use_shading_nodes = True
|
2013-01-28 17:37:51 +00:00
|
|
|
bl_use_preview = True
|
2013-06-10 13:53:38 +00:00
|
|
|
bl_use_exclude_layers = True
|
2013-07-11 12:22:29 +00:00
|
|
|
bl_use_save_buffers = True
|
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
|
|
|
bl_use_spherical_stereo = True
|
2011-04-27 11:58:34 +00:00
|
|
|
|
2011-08-28 13:55:59 +00:00
|
|
|
def __init__(self):
|
|
|
|
|
self.session = None
|
2011-11-15 02:58:01 +00:00
|
|
|
|
2011-08-28 13:55:59 +00:00
|
|
|
def __del__(self):
|
|
|
|
|
engine.free(self)
|
2011-04-27 11:58:34 +00:00
|
|
|
|
2011-08-28 13:55:59 +00:00
|
|
|
# final render
|
2018-02-26 16:46:48 +01:00
|
|
|
def update(self, data, scene):
|
2015-02-21 19:17:09 +05:00
|
|
|
if not self.session:
|
|
|
|
|
if self.is_preview:
|
2014-01-13 23:29:35 +01:00
|
|
|
cscene = bpy.context.scene.cycles
|
|
|
|
|
use_osl = cscene.shading_system and cscene.device == 'CPU'
|
2013-01-28 17:37:51 +00:00
|
|
|
|
2018-02-26 16:46:48 +01:00
|
|
|
engine.create(self, data, scene,
|
2013-01-28 17:37:51 +00:00
|
|
|
None, None, None, use_osl)
|
|
|
|
|
else:
|
2018-02-26 16:46:48 +01:00
|
|
|
engine.create(self, data, scene)
|
2015-02-21 19:17:09 +05:00
|
|
|
else:
|
|
|
|
|
engine.reset(self, data, scene)
|
2011-04-27 11:58:34 +00:00
|
|
|
|
2018-02-26 16:46:48 +01:00
|
|
|
def render_to_image(self, depsgraph):
|
|
|
|
|
engine.render(self, depsgraph)
|
2011-05-17 14:26:45 +00:00
|
|
|
|
2018-02-26 16:46:48 +01:00
|
|
|
def bake(self, depsgraph, scene, obj, pass_type, pass_filter, object_id, pixel_array, num_pixels, depth, result):
|
|
|
|
|
engine.bake(self, depsgraph, obj, pass_type, pass_filter, object_id, pixel_array, num_pixels, depth, result)
|
2014-01-02 19:05:07 -02:00
|
|
|
|
2011-08-28 13:55:59 +00:00
|
|
|
# viewport render
|
|
|
|
|
def view_update(self, context):
|
|
|
|
|
if not self.session:
|
2018-02-26 16:46:48 +01:00
|
|
|
engine.create(self, context.blend_data, context.scene,
|
2013-01-15 23:17:45 +00:00
|
|
|
context.region, context.space_data, context.region_data)
|
2018-02-26 16:46:48 +01:00
|
|
|
engine.update(self, context.depsgraph, context.blend_data, context.scene)
|
2011-04-27 11:58:34 +00:00
|
|
|
|
2017-04-25 18:02:18 +02:00
|
|
|
def render_to_view(self, context):
|
2017-04-25 16:18:24 +02:00
|
|
|
engine.draw(self, context.depsgraph, context.region, context.space_data, context.region_data)
|
2011-04-27 11:58:34 +00:00
|
|
|
|
2012-11-03 14:32:35 +00:00
|
|
|
def update_script_node(self, node):
|
|
|
|
|
if engine.with_osl():
|
|
|
|
|
from . import osl
|
|
|
|
|
osl.update_script_node(node, self.report)
|
|
|
|
|
else:
|
|
|
|
|
self.report({'ERROR'}, "OSL support disabled in this build.")
|
|
|
|
|
|
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
|
|
|
def update_render_passes(self, scene, srl):
|
|
|
|
|
engine.register_passes(self, scene, srl)
|
|
|
|
|
|
2011-11-15 02:58:01 +00:00
|
|
|
|
2016-02-07 03:40:41 +05:00
|
|
|
def engine_exit():
|
|
|
|
|
engine.exit()
|
|
|
|
|
|
|
|
|
|
|
2017-03-20 12:16:51 +11:00
|
|
|
classes = (
|
|
|
|
|
CyclesRender,
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
|
2011-04-27 11:58:34 +00:00
|
|
|
def register():
|
2017-03-20 12:16:51 +11:00
|
|
|
from bpy.utils import register_class
|
2012-12-13 08:45:55 +00:00
|
|
|
from . import ui
|
|
|
|
|
from . import properties
|
|
|
|
|
from . import presets
|
2016-02-07 03:40:41 +05:00
|
|
|
import atexit
|
|
|
|
|
|
2016-02-16 13:00:44 +01:00
|
|
|
# Make sure we only registered the callback once.
|
2016-02-16 12:47:12 +01:00
|
|
|
atexit.unregister(engine_exit)
|
2016-02-07 03:40:41 +05:00
|
|
|
atexit.register(engine_exit)
|
2012-12-13 08:45:55 +00:00
|
|
|
|
2013-01-14 17:30:33 +00:00
|
|
|
engine.init()
|
|
|
|
|
|
2011-08-28 13:55:59 +00:00
|
|
|
properties.register()
|
|
|
|
|
ui.register()
|
2011-08-29 17:55:14 +00:00
|
|
|
presets.register()
|
2017-03-20 12:16:51 +11:00
|
|
|
|
|
|
|
|
for cls in classes:
|
|
|
|
|
register_class(cls)
|
2011-04-27 11:58:34 +00:00
|
|
|
|
2014-08-28 18:58:21 +06:00
|
|
|
bpy.app.handlers.version_update.append(version_update.do_versions)
|
|
|
|
|
|
2011-11-15 02:58:01 +00:00
|
|
|
|
2011-04-27 11:58:34 +00:00
|
|
|
def unregister():
|
2017-03-20 12:16:51 +11:00
|
|
|
from bpy.utils import unregister_class
|
2012-12-13 08:45:55 +00:00
|
|
|
from . import ui
|
|
|
|
|
from . import properties
|
|
|
|
|
from . import presets
|
2016-02-07 03:40:41 +05:00
|
|
|
import atexit
|
2012-12-13 08:45:55 +00:00
|
|
|
|
2014-08-28 18:58:21 +06:00
|
|
|
bpy.app.handlers.version_update.remove(version_update.do_versions)
|
|
|
|
|
|
2011-08-28 13:55:59 +00:00
|
|
|
ui.unregister()
|
|
|
|
|
properties.unregister()
|
2011-08-29 17:55:14 +00:00
|
|
|
presets.unregister()
|
2017-03-20 12:16:51 +11:00
|
|
|
|
|
|
|
|
for cls in classes:
|
|
|
|
|
unregister_class(cls)
|