Cycles: remove option to disable transparent shadows globally.
[blender-staging.git] / intern / cycles / blender / addon / __init__.py
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 # <pep8 compliant>
18
19 bl_info = {
20     "name": "Cycles Render Engine",
21     "author": "",
22     "blender": (2, 76, 0),
23     "location": "Info header, render engine menu",
24     "description": "Cycles Render Engine integration",
25     "warning": "",
26     "wiki_url": "https://docs.blender.org/manual/en/dev/render/cycles/",
27     "tracker_url": "",
28     "support": 'OFFICIAL',
29     "category": "Render"}
30
31 # Support 'reload' case.
32 if "bpy" in locals():
33     import importlib
34     if "engine" in locals():
35         importlib.reload(engine)
36     if "version_update" in locals():
37         importlib.reload(version_update)
38     if "ui" in locals():
39         importlib.reload(ui)
40     if "properties" in locals():
41         importlib.reload(properties)
42     if "presets" in locals():
43         importlib.reload(presets)
44
45 import bpy
46
47 from . import (
48         engine,
49         version_update,
50         )
51
52
53 class CyclesRender(bpy.types.RenderEngine):
54     bl_idname = 'CYCLES'
55     bl_label = "Cycles Render"
56     bl_use_shading_nodes = True
57     bl_use_preview = True
58     bl_use_exclude_layers = True
59     bl_use_save_buffers = True
60     bl_use_spherical_stereo = True
61
62     def __init__(self):
63         self.session = None
64
65     def __del__(self):
66         engine.free(self)
67
68     # final render
69     def update(self, data, scene):
70         if not self.session:
71             if self.is_preview:
72                 cscene = bpy.context.scene.cycles
73                 use_osl = cscene.shading_system and cscene.device == 'CPU'
74
75                 engine.create(self, data, scene,
76                               None, None, None, use_osl)
77             else:
78                 engine.create(self, data, scene)
79         else:
80             engine.reset(self, data, scene)
81
82     def render(self, scene):
83         engine.render(self)
84
85     def bake(self, scene, obj, pass_type, pass_filter, object_id, pixel_array, num_pixels, depth, result):
86         engine.bake(self, obj, pass_type, pass_filter, object_id, pixel_array, num_pixels, depth, result)
87
88     # viewport render
89     def view_update(self, context):
90         if not self.session:
91             engine.create(self, context.blend_data, context.scene,
92                           context.region, context.space_data, context.region_data)
93         engine.update(self, context.blend_data, context.scene)
94
95     def view_draw(self, context):
96         engine.draw(self, context.region, context.space_data, context.region_data)
97
98     def update_script_node(self, node):
99         if engine.with_osl():
100             from . import osl
101             osl.update_script_node(node, self.report)
102         else:
103             self.report({'ERROR'}, "OSL support disabled in this build.")
104
105     def update_render_passes(self, scene, srl):
106         engine.register_passes(self, scene, srl)
107
108
109 def engine_exit():
110     engine.exit()
111
112
113 classes = (
114     CyclesRender,
115 )
116
117
118 def register():
119     from bpy.utils import register_class
120     from . import ui
121     from . import properties
122     from . import presets
123     import atexit
124
125     # Make sure we only registered the callback once.
126     atexit.unregister(engine_exit)
127     atexit.register(engine_exit)
128
129     engine.init()
130
131     properties.register()
132     ui.register()
133     presets.register()
134
135     for cls in classes:
136         register_class(cls)
137
138     bpy.app.handlers.version_update.append(version_update.do_versions)
139
140
141 def unregister():
142     from bpy.utils import unregister_class
143     from . import ui
144     from . import properties
145     from . import presets
146     import atexit
147
148     bpy.app.handlers.version_update.remove(version_update.do_versions)
149
150     ui.unregister()
151     properties.unregister()
152     presets.unregister()
153
154     for cls in classes:
155         unregister_class(cls)