also update sphinx doc generator.
"active_base": ("ObjectBase", False),
"active_bone": ("Bone", False),
"active_object": ("Object", False),
+ "active_operator": ("Operator", False),
"active_pose_bone": ("PoseBone", False),
"armature": ("Armature", False),
"bone": ("Bone", False),
"cloth": ("ClothModifier", False),
"collision": ("CollisionModifier", False),
"curve": ("Curve", False),
+ "dynamic_paint": ("DynamicPaintModifier", False),
"edit_bone": ("EditBone", False),
"edit_image": ("Image", False),
"edit_object": ("Object", False),
"speaker": ("Speaker", False),
"texture": ("Texture", False),
"texture_slot": ("MaterialTextureSlot", False),
+ "texture_user": ("ID", False),
"vertex_paint_object": ("Object", False),
"visible_bases": ("ObjectBase", True),
"visible_bones": ("Object", True),
# Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
#
+# <pep8 compliant>
+
bl_info = {
"name": "Cycles Render Engine",
"author": "",
- "version": (0,0),
+ "version": (0, 0),
"blender": (2, 6, 0),
"api": 41670,
"location": "Info header, render engine menu",
from cycles import engine
from cycles import presets
+
class CyclesRender(bpy.types.RenderEngine):
bl_idname = 'CYCLES'
bl_label = "Cycles"
def __init__(self):
engine.init()
self.session = None
-
+
def __del__(self):
engine.free(self)
#
# def preview_render(self):
# pass
-
+
# viewport render
def view_update(self, context):
if not self.session:
def view_draw(self, context):
engine.draw(self, context.region, context.space_data, context.region_data)
+
def register():
properties.register()
ui.register()
presets.register()
bpy.utils.register_module(__name__)
+
def unregister():
xml.unregister()
ui.unregister()
properties.unregister()
presets.unregister()
bpy.utils.unregister_module(__name__)
-
# Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
#
+# <pep8 compliant>
+
import bpy
+
def init():
import bcycles
import os.path
bcycles.init(path, user_path)
-def create(engine, data, scene, region = 0, v3d = 0, rv3d = 0):
+
+def create(engine, data, scene, region=0, v3d=0, rv3d=0):
import bcycles
data = data.as_pointer()
engine.session = bcycles.create(engine.as_pointer(), data, scene, region, v3d, rv3d)
+
def free(engine):
- if "session" in dir(engine):
+ if hasattr(engine, "session"):
if engine.session:
import bcycles
bcycles.free(engine.session)
del engine.session
+
def render(engine):
import bcycles
if "session" in dir(engine):
bcycles.render(engine.session)
+
def update(engine, data, scene):
import bcycles
if scene.render.use_border:
else:
bcycles.sync(engine.session)
+
def draw(engine, region, v3d, rv3d):
import bcycles
v3d = v3d.as_pointer()
# draw render image
bcycles.draw(engine.session, v3d, rv3d)
+
def available_devices():
import bcycles
return bcycles.available_devices()
+
def with_osl():
import bcycles
return bcycles.with_osl()
-
# Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
#
+# <pep8 compliant>
+
from cycles import engine
+
def get_gpu_device():
available_devices = engine.available_devices()
cuda = 'cuda' in available_devices
gpu_string = "CUDA GPU"
else:
gpu_string = "OpenCL GPU"
-
+
return gpu_string
devices = (
-("CPU", "CPU", "Processor"),
-("GPU", get_gpu_device(), "Graphics card"))
+ ("CPU", "CPU", "Processor"),
+ ("GPU", get_gpu_device(), "Graphics card"),
+ )
gpu_type = (
-("CUDA", "CUDA", "NVidia only"),
-("OPENCL", "OpenCL (incomplete)", ""))
+ ("CUDA", "CUDA", "NVidia only"),
+ ("OPENCL", "OpenCL (incomplete)", ""),
+ )
shading_systems = (
-("GPU_COMPATIBLE", "GPU Compatible", "Restricted shading system compatible with GPU rendering"),
-("OSL", "Open Shading Language", "Open Shading Language shading system that only runs on the CPU"))
+ ("GPU_COMPATIBLE", "GPU Compatible", "Restricted shading system compatible with GPU rendering"),
+ ("OSL", "Open Shading Language", "Open Shading Language shading system that only runs on the CPU"),
+ )
displacement_methods = (
-("BUMP", "Bump", "Bump mapping to simulate the appearance of displacement"),
-("TRUE", "True", "Use true displacement only, requires fine subdivision"),
-("BOTH", "Both", "Combination of displacement and bump mapping"))
+ ("BUMP", "Bump", "Bump mapping to simulate the appearance of displacement"),
+ ("TRUE", "True", "Use true displacement only, requires fine subdivision"),
+ ("BOTH", "Both", "Combination of displacement and bump mapping"),
+ )
bvh_types = (
-("DYNAMIC_BVH", "Dynamic BVH", "Objects can be individually updated, at the cost of slower render time"),
-("STATIC_BVH", "Static BVH", "Any object modification requires a complete BVH rebuild, but renders faster"))
+ ("DYNAMIC_BVH", "Dynamic BVH", "Objects can be individually updated, at the cost of slower render time"),
+ ("STATIC_BVH", "Static BVH", "Any object modification requires a complete BVH rebuild, but renders faster"),
+ )
filter_types = (
-("BOX", "Box", "Box filter"),
-("GAUSSIAN", "Gaussian", "Gaussian filter"))
-
-
+ ("BOX", "Box", "Box filter"),
+ ("GAUSSIAN", "Gaussian", "Gaussian filter"),
+ )
# Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
#
+# <pep8 compliant>
+
from bl_operators.presets import AddPresetBase
from bpy.types import Operator
+
class AddPresetIntegrator(AddPresetBase, Operator):
'''Add an Integrator Preset'''
bl_idname = "render.cycles_integrator_preset_add"
]
preset_subdir = "cycles/integrator"
-
+
+
def register():
pass
+
def unregister():
pass
-
+
if __name__ == "__main__":
register()
-
# Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
#
+# <pep8 compliant>
+
import bpy
from bpy.props import *
from cycles import enums
+
class CyclesRenderSettings(bpy.types.PropertyGroup):
@classmethod
def register(cls):
cls.device = EnumProperty(name="Device", description="Device to use for rendering",
items=enums.devices, default="CPU")
-
+
cls.gpu_type = EnumProperty(name="GPU Type", description="Processing system to use on the GPU",
items=enums.gpu_type, default="CUDA")
def unregister(cls):
del bpy.types.Scene.cycles
+
class CyclesCameraSettings(bpy.types.PropertyGroup):
@classmethod
def register(cls):
default=0, min=0, max=100)
cls.aperture_rotation = FloatProperty(name="Aperture Rotation", description="Rotation of blades in aperture",
default=0, soft_min=-math.pi, soft_max=math.pi, subtype='ANGLE')
-
+
@classmethod
def unregister(cls):
del bpy.types.Camera.cycles
+
class CyclesMaterialSettings(bpy.types.PropertyGroup):
@classmethod
def register(cls):
def unregister(cls):
del bpy.types.Material.cycles
+
class CyclesLampSettings(bpy.types.PropertyGroup):
@classmethod
def register(cls):
def unregister(cls):
del bpy.types.Lamp.cycles
+
class CyclesWorldSettings(bpy.types.PropertyGroup):
@classmethod
def register(cls):
def unregister(cls):
del bpy.types.World.cycles
+
class CyclesVisibilitySettings(bpy.types.PropertyGroup):
@classmethod
def register(cls):
def unregister(cls):
del bpy.types.Object.cycles_visibility
+
class CyclesMeshSettings(bpy.types.PropertyGroup):
@classmethod
def register(cls):
del bpy.types.Curve.cycles
del bpy.types.MetaBall.cycles
+
def register():
bpy.utils.register_class(CyclesRenderSettings)
bpy.utils.register_class(CyclesCameraSettings)
bpy.utils.register_class(CyclesWorldSettings)
bpy.utils.register_class(CyclesVisibilitySettings)
bpy.utils.register_class(CyclesMeshSettings)
-
+
+
def unregister():
bpy.utils.unregister_class(CyclesRenderSettings)
bpy.utils.unregister_class(CyclesCameraSettings)
bpy.utils.unregister_class(CyclesWorldSettings)
bpy.utils.unregister_class(CyclesMeshSettings)
bpy.utils.unregister_class(CyclesVisibilitySettings)
-
# Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
#
+# <pep8 compliant>
+
import bpy
from bpy.types import Panel, Menu
from cycles import enums
from cycles import engine
+
class CYCLES_MT_integrator_presets(Menu):
bl_label = "Integrator Presets"
preset_subdir = "cycles/integrator"
COMPAT_ENGINES = {'CYCLES'}
draw = Menu.draw_preset
+
class CyclesButtonsPanel():
bl_space_type = "PROPERTIES"
bl_region_type = "WINDOW"
bl_context = "render"
-
+
@classmethod
def poll(cls, context):
rd = context.scene.render
return rd.engine == 'CYCLES'
+
class CyclesRender_PT_integrator(CyclesButtonsPanel, Panel):
bl_label = "Integrator"
bl_options = {'DEFAULT_CLOSED'}
scene = context.scene
cscene = scene.cycles
-
+
row = layout.row(align=True)
row.menu("CYCLES_MT_integrator_presets", text=bpy.types.CYCLES_MT_integrator_presets.bl_label)
row.operator("render.cycles_integrator_preset_add", text="", icon="ZOOMIN")
#row = col.row()
#row.prop(cscene, "blur_caustics")
#row.active = not cscene.no_caustics
-
+
+
class CyclesRender_PT_film(CyclesButtonsPanel, Panel):
bl_label = "Film"
split = layout.split()
- col = split.column();
+ col = split.column()
col.prop(cscene, "film_exposure")
col.prop(cscene, "film_transparent")
if cscene.filter_type != 'BOX':
sub.prop(cscene, "filter_width", text="Width")
+
class CyclesRender_PT_performance(CyclesButtonsPanel, Panel):
bl_label = "Performance"
bl_options = {'DEFAULT_CLOSED'}
sub.prop(cscene, "debug_bvh_type", text="")
sub.prop(cscene, "debug_use_spatial_splits")
+
class CyclesRender_PT_layers(CyclesButtonsPanel, Panel):
bl_label = "Layers"
bl_options = {'DEFAULT_CLOSED'}
layout.prop(rl, "material_override", text="Material")
+
class Cycles_PT_post_processing(CyclesButtonsPanel, Panel):
bl_label = "Post Processing"
bl_options = {'DEFAULT_CLOSED'}
col = split.column()
col.prop(rd, "dither_intensity", text="Dither", slider=True)
+
class CyclesCamera_PT_dof(CyclesButtonsPanel, Panel):
bl_label = "Depth of Field"
bl_context = "data"
sub.prop(ccam, "aperture_blades", text="Blades")
sub.prop(ccam, "aperture_rotation", text="Rotation")
+
class Cycles_PT_context_material(CyclesButtonsPanel, Panel):
bl_label = "Surface"
bl_context = "material"
split.template_ID(space, "pin_id")
split.separator()
+
class Cycles_PT_mesh_displacement(CyclesButtonsPanel, Panel):
bl_label = "Displacement"
bl_context = "data"
cdata = mball.cycles
layout.prop(cdata, "displacement_method", text="Method")
- layout.prop(cdata, "use_subdivision");
- layout.prop(cdata, "dicing_rate");
+ layout.prop(cdata, "use_subdivision")
+ layout.prop(cdata, "dicing_rate")
+
class CyclesObject_PT_ray_visibility(CyclesButtonsPanel, Panel):
bl_label = "Ray Visibility"
@classmethod
def poll(cls, context):
ob = context.object
- return CyclesButtonsPanel.poll(context) and ob and ob.type in ('MESH', 'CURVE', 'CURVE', 'SURFACE', 'FONT', 'META') # todo: 'LAMP'
+ return CyclesButtonsPanel.poll(context) and ob and ob.type in ('MESH', 'CURVE', 'CURVE', 'SURFACE', 'FONT', 'META') # todo: 'LAMP'
def draw(self, context):
layout = self.layout
col.prop(visibility, "transmission")
col.prop(visibility, "shadow")
+
def find_node(material, nodetype):
if material and material.node_tree:
ntree = material.node_tree
for node in ntree.nodes:
if hasattr(node, 'type') and node.type == nodetype:
return node
-
+
return None
+
def find_node_input(node, name):
for input in node.inputs:
if input.name == name:
return input
-
+
return None
+
def panel_node_draw(layout, id, output_type, input_name):
if not id.node_tree:
layout.prop(id, "use_nodes", icon='NODETREE')
layout.label(text="No output node.")
else:
input = find_node_input(node, input_name)
- layout.template_node_view(ntree, node, input);
-
+ layout.template_node_view(ntree, node, input)
+
return True
+
class CyclesLamp_PT_lamp(CyclesButtonsPanel, Panel):
bl_label = "Lamp"
bl_context = "data"
layout.label(text="Not supported, interpreted as point lamp.")
elif lamp.type == 'HEMI':
layout.label(text="Not supported, interpreted as sun lamp.")
-
+
+
class CyclesLamp_PT_nodes(CyclesButtonsPanel, Panel):
bl_label = "Nodes"
bl_context = "data"
if not panel_node_draw(layout, lamp, 'OUTPUT_LAMP', 'Surface'):
layout.prop(lamp, "color")
+
class CyclesWorld_PT_surface(CyclesButtonsPanel, Panel):
bl_label = "Surface"
bl_context = "world"
if not panel_node_draw(layout, world, 'OUTPUT_WORLD', 'Surface'):
layout.prop(world, "horizon_color", text="Color")
+
class CyclesWorld_PT_volume(CyclesButtonsPanel, Panel):
bl_label = "Volume"
bl_context = "world"
@classmethod
def poll(cls, context):
world = context.world
- return False # world and world.node_tree and CyclesButtonsPanel.poll(context)
+ return False # world and world.node_tree and CyclesButtonsPanel.poll(context)
def draw(self, context):
layout = self.layout
world = context.world
panel_node_draw(layout, world, 'OUTPUT_WORLD', 'Volume')
+
class CyclesMaterial_PT_surface(CyclesButtonsPanel, Panel):
bl_label = "Surface"
bl_context = "material"
if not panel_node_draw(layout, mat, 'OUTPUT_MATERIAL', 'Surface'):
layout.prop(mat, "diffuse_color")
+
class CyclesMaterial_PT_volume(CyclesButtonsPanel, Panel):
bl_label = "Volume"
bl_context = "material"
@classmethod
def poll(cls, context):
mat = context.material
- return False #mat and mat.node_tree and CyclesButtonsPanel.poll(context)
+ return False # mat and mat.node_tree and CyclesButtonsPanel.poll(context)
def draw(self, context):
layout = self.layout
layout.prop(cmat, "homogeneous_volume")
+
class CyclesMaterial_PT_displacement(CyclesButtonsPanel, Panel):
bl_label = "Displacement"
bl_context = "material"
mat = context.material
panel_node_draw(layout, mat, 'OUTPUT_MATERIAL', 'Displacement')
+
class CyclesMaterial_PT_settings(CyclesButtonsPanel, Panel):
bl_label = "Settings"
bl_context = "material"
col = split.column()
col.prop(cmat, "sample_as_light")
+
class CyclesTexture_PT_context(CyclesButtonsPanel, Panel):
bl_label = ""
bl_context = "texture"
tex = context.texture
space = context.space_data
pin_id = space.pin_id
- use_pin_id = space.use_pin_id;
+ use_pin_id = space.use_pin_id
user = context.texture_user
node = context.texture_node
col.template_ID(space, "pin_id")
elif user:
col.template_ID(user, "texture", new="texture.new")
-
+
if tex:
row = split.row()
row.prop(tex, "use_nodes", icon="NODETREE", text="")
split.label(text="Type:")
split.prop(tex, "type", text="")
+
class CyclesTexture_PT_nodes(CyclesButtonsPanel, Panel):
bl_label = "Nodes"
bl_context = "texture"
tex = context.texture
panel_node_draw(layout, tex, 'OUTPUT_TEXTURE', 'Color')
+
class CyclesTexture_PT_node(CyclesButtonsPanel, Panel):
bl_label = "Node"
bl_context = "texture"
ntree = node.id_data
layout.template_node_view(ntree, node, None)
+
class CyclesTexture_PT_mapping(CyclesButtonsPanel, Panel):
bl_label = "Mapping"
bl_context = "texture"
row.prop(mapping, "mapping_y", text="")
row.prop(mapping, "mapping_z", text="")
+
class CyclesTexture_PT_colors(CyclesButtonsPanel, Panel):
bl_label = "Color"
bl_context = "texture"
if mapping.use_color_ramp:
layout.template_color_ramp(mapping, "color_ramp", expand=True)
+
def draw_device(self, context):
scene = context.scene
layout = self.layout
if cscene.device == 'CPU' and engine.with_osl():
layout.prop(cscene, "shading_system")
+
def draw_pause(self, context):
layout = self.layout
scene = context.scene
cscene = scene.cycles
layout.prop(cscene, "preview_pause", icon="PAUSE", text="")
+
def get_panels():
return [
bpy.types.RENDER_PT_render,
bpy.types.PARTICLE_PT_vertexgroups,
bpy.types.PARTICLE_PT_custom_props]
+
def register():
bpy.types.RENDER_PT_render.append(draw_device)
bpy.types.VIEW3D_HT_header.append(draw_pause)
for panel in get_panels():
panel.COMPAT_ENGINES.add('CYCLES')
-
+
+
def unregister():
bpy.types.RENDER_PT_render.remove(draw_device)
bpy.types.VIEW3D_HT_header.remove(draw_pause)
for panel in get_panels():
panel.COMPAT_ENGINES.remove('CYCLES')
-
# Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
#
+# <pep8 compliant>
+
# XML exporter for generating test files, not intended for end users
import os
import xml.etree.ElementTree as etree
import xml.dom.minidom as dom
+
def strip(root):
root.text = None
root.tail = None
for elem in root:
strip(elem)
+
def write(node, fname):
strip(node)
f = open(fname, "w")
f.write(s)
+
class ExportCyclesXML(bpy.types.Operator, ExportHelper):
''''''
bl_idname = "export_mesh.cycles_xml"
verts += " "
node = etree.Element('mesh', attrib={'nverts': nverts, 'verts': verts, 'P': P})
-
+
# write to file
write(node, filepath)
return {'FINISHED'}
+
def register():
pass
+
def unregister():
pass
if __name__ == "__main__":
register()
-