OBJ: reintroduce export menu item for the old (pre-3.1) python exporter
[blender-addons.git] / amaranth / render / samples_scene.py
blob0409a771c9f83fce158beb42b1c0c56b48ae681e
1 # This program is free software; you can redistribute it and/or
2 # modify it under the terms of the GNU General Public License
3 # as published by the Free Software Foundation; either version 2
4 # of the License, or (at your option) any later version.
6 # This program is distributed in the hope that it will be useful,
7 # but WITHOUT ANY WARRANTY; without even the implied warranty of
8 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
9 # GNU General Public License for more details.
11 # You should have received a copy of the GNU General Public License
12 # along with this program; if not, write to the Free Software Foundation,
13 # Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
14 """
15 Cycles: Samples per Scene
17 When working in production, it's often more convenient to do lighting and
18 compositing in different scenes (so you can later append the comp scene
19 to bring together nodes, settings, lamps, RenderLayers).
21 This would lead to work with more than one scene. When doing render tests
22 you want to know at a glance how many samples the other scenes have,
23 without manually switching. This is the idea behind the feature.
25 Find it on the Sampling panel, on Render properties.
26 Developed during Caminandes Open Movie Project
27 """
29 import bpy
30 from amaranth import utils
31 from bpy.props import (
32 BoolProperty,
33 IntProperty,
37 def render_cycles_scene_samples(self, context):
39 layout = self.layout
40 scene = context.scene
41 render = scene.render
42 if utils.cycles_exists():
43 cscene = scene.cycles
44 list_sampling = scene.amaranth_cycles_list_sampling
46 # List Samples
47 #if (len(scene.render.layers) > 1) or (len(bpy.data.scenes) > 1):
48 if (len(scene.render.views) > 1) or (len(bpy.data.scenes) > 1):
50 box = layout.box()
51 row = box.row(align=True)
52 col = row.column(align=True)
54 row = col.row(align=True)
55 row.alignment = "LEFT"
56 row.prop(scene, "amaranth_cycles_list_sampling",
57 icon="%s" % "TRIA_DOWN" if list_sampling else "TRIA_RIGHT",
58 emboss=False)
60 if list_sampling:
61 #if len(scene.render.layers) == 1 and render.layers[0].samples == 0:
62 if len(scene.render.views) == 1 and render.view_layers[0].samples == 0:
63 pass
64 else:
65 col.separator()
66 #col.label(text="RenderLayers:", icon="RENDERLAYERS")
67 col.label(text="View Layers:", icon="RENDERLAYERS")
69 #for rl in scene.render.layers:
70 for rl in scene.view_layers:
71 row = col.row(align=True)
72 row.label(text=rl.name, icon="BLANK1")
73 row.prop(
74 rl, "samples", text="%s" %
75 "Samples" if rl.samples > 0 else "Automatic (%s)" %
76 cscene.samples)
78 if (len(bpy.data.scenes) > 1):
79 col.separator()
81 col.label(text="Scenes:", icon="SCENE_DATA")
83 if utils.cycles_exists():
84 for s in bpy.data.scenes:
85 if s != scene:
86 row = col.row(align=True)
87 if s.render.engine == "CYCLES":
88 cscene = s.cycles
90 #row.label(s.name)
91 row.label(text=s.name)
92 row.prop(cscene, "samples", icon="BLANK1")
93 else:
94 row.label(
95 text="Scene: '%s' is not using Cycles" %
96 s.name)
97 else:
98 for s in bpy.data.scenes:
99 if s != scene:
100 row = col.row(align=True)
101 if s.render.engine == "CYCLES":
102 cscene = s.cycles
104 row.label(text=s.name, icon="BLANK1")
105 row.prop(cscene, "aa_samples",
106 text="AA Samples")
107 else:
108 row.label(
109 text="Scene: '%s' is not using Cycles" %
110 s.name)
113 def init():
114 scene = bpy.types.Scene
115 if utils.cycles_exists():
116 scene.amaranth_cycles_list_sampling = bpy.props.BoolProperty(
117 default=False,
118 name="Samples Per:")
119 # Note: add versioning code to address changes introduced in 2.79.1
120 from cycles import properties as _cycles_props
121 _cycles_props.CyclesRenderSettings.use_samples_final = BoolProperty(
122 name="Use Final Render Samples",
123 description="Use current shader samples as final render samples",
124 default=False,
128 def clear():
129 wm = bpy.context.window_manager
130 for p in ("amarath_cycles_list_sampling", "use_samples_final"):
131 if p in wm:
132 del wm[p]
135 def register():
136 init()
137 if utils.cycles_exists():
138 bpy.types.CYCLES_RENDER_PT_sampling.append(render_cycles_scene_samples)
141 def unregister():
142 if utils.cycles_exists():
143 bpy.types.CYCLES_RENDER_PT_sampling.remove(render_cycles_scene_samples)
146 clear()