Cleanup: pep8, cycles
This commit is contained in:
@@ -47,7 +47,7 @@ import bpy
|
||||
from . import (
|
||||
engine,
|
||||
version_update,
|
||||
)
|
||||
)
|
||||
|
||||
|
||||
class CyclesRender(bpy.types.RenderEngine):
|
||||
|
@@ -83,14 +83,16 @@ def _parse_command_line():
|
||||
import _cycles
|
||||
_cycles.set_resumable_chunk(
|
||||
int(args.cycles_resumable_num_chunks),
|
||||
int(args.cycles_resumable_current_chunk))
|
||||
int(args.cycles_resumable_current_chunk),
|
||||
)
|
||||
elif args.cycles_resumable_start_chunk is not None and \
|
||||
args.cycles_resumable_end_chunk:
|
||||
import _cycles
|
||||
_cycles.set_resumable_chunk_range(
|
||||
int(args.cycles_resumable_num_chunks),
|
||||
int(args.cycles_resumable_start_chunk),
|
||||
int(args.cycles_resumable_end_chunk))
|
||||
int(args.cycles_resumable_end_chunk),
|
||||
)
|
||||
|
||||
|
||||
def init():
|
||||
@@ -206,6 +208,7 @@ def system_info():
|
||||
import _cycles
|
||||
return _cycles.system_info()
|
||||
|
||||
|
||||
def register_passes(engine, scene, srl):
|
||||
engine.register_pass(scene, srl, "Combined", 4, "RGBA", 'COLOR')
|
||||
|
||||
|
@@ -31,7 +31,7 @@ import _cycles
|
||||
enum_devices = (
|
||||
('CPU', "CPU", "Use CPU for rendering"),
|
||||
('GPU', "GPU Compute", "Use GPU compute device for rendering, configured in the system tab in the user preferences"),
|
||||
)
|
||||
)
|
||||
|
||||
if _cycles.with_network:
|
||||
enum_devices += (('NETWORK', "Networked Device", "Use networked device for rendering"),)
|
||||
@@ -39,34 +39,34 @@ if _cycles.with_network:
|
||||
enum_feature_set = (
|
||||
('SUPPORTED', "Supported", "Only use finished and supported features"),
|
||||
('EXPERIMENTAL', "Experimental", "Use experimental and incomplete features that might be broken or change in the future", 'ERROR', 1),
|
||||
)
|
||||
)
|
||||
|
||||
enum_displacement_methods = (
|
||||
('BUMP', "Bump Only", "Bump mapping to simulate the appearance of displacement"),
|
||||
('DISPLACEMENT', "Displacement Only", "Use true displacement of surface only, requires fine subdivision"),
|
||||
('BOTH', "Displacement and Bump", "Combination of true displacement and bump mapping for finer detail"),
|
||||
)
|
||||
)
|
||||
|
||||
enum_bvh_layouts = (
|
||||
('BVH2', "BVH2", "", 1),
|
||||
('BVH4', "BVH4", "", 2),
|
||||
)
|
||||
)
|
||||
|
||||
enum_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"),
|
||||
)
|
||||
)
|
||||
|
||||
enum_filter_types = (
|
||||
('BOX', "Box", "Box filter"),
|
||||
('GAUSSIAN', "Gaussian", "Gaussian filter"),
|
||||
('BLACKMAN_HARRIS', "Blackman-Harris", "Blackman-Harris filter"),
|
||||
)
|
||||
)
|
||||
|
||||
enum_aperture_types = (
|
||||
('RADIUS', "Radius", "Directly change the size of the aperture"),
|
||||
('FSTOP', "F-stop", "Change the size of the aperture by f-stop"),
|
||||
)
|
||||
)
|
||||
|
||||
enum_panorama_types = (
|
||||
('EQUIRECTANGULAR', "Equirectangular", "Render the scene with a spherical camera, also known as Lat Long panorama"),
|
||||
@@ -74,23 +74,23 @@ enum_panorama_types = (
|
||||
('FISHEYE_EQUISOLID', "Fisheye Equisolid",
|
||||
"Similar to most fisheye modern lens, takes sensor dimensions into consideration"),
|
||||
('MIRRORBALL', "Mirror Ball", "Uses the mirror ball mapping"),
|
||||
)
|
||||
)
|
||||
|
||||
enum_curve_primitives = (
|
||||
('TRIANGLES', "Triangles", "Create triangle geometry around strands"),
|
||||
('LINE_SEGMENTS', "Line Segments", "Use line segment primitives"),
|
||||
('CURVE_SEGMENTS', "Curve Segments", "Use segmented cardinal curve primitives"),
|
||||
)
|
||||
)
|
||||
|
||||
enum_triangle_curves = (
|
||||
('CAMERA_TRIANGLES', "Planes", "Create individual triangles forming planes that face camera"),
|
||||
('TESSELLATED_TRIANGLES', "Tessellated", "Create mesh surrounding each strand"),
|
||||
)
|
||||
)
|
||||
|
||||
enum_curve_shape = (
|
||||
('RIBBONS', "Ribbons", "Ignore thickness of each strand"),
|
||||
('THICK', "Thick", "Use thickness of strand when rendering"),
|
||||
)
|
||||
)
|
||||
|
||||
enum_tile_order = (
|
||||
('CENTER', "Center", "Render from center to the edges"),
|
||||
@@ -99,46 +99,46 @@ enum_tile_order = (
|
||||
('TOP_TO_BOTTOM', "Top to Bottom", "Render from top to bottom"),
|
||||
('BOTTOM_TO_TOP', "Bottom to Top", "Render from bottom to top"),
|
||||
('HILBERT_SPIRAL', "Hilbert Spiral", "Render in a Hilbert Spiral"),
|
||||
)
|
||||
)
|
||||
|
||||
enum_use_layer_samples = (
|
||||
('USE', "Use", "Per render layer number of samples override scene samples"),
|
||||
('BOUNDED', "Bounded", "Bound per render layer number of samples by global samples"),
|
||||
('IGNORE', "Ignore", "Ignore per render layer number of samples"),
|
||||
)
|
||||
)
|
||||
|
||||
enum_sampling_pattern = (
|
||||
('SOBOL', "Sobol", "Use Sobol random sampling pattern"),
|
||||
('CORRELATED_MUTI_JITTER', "Correlated Multi-Jitter", "Use Correlated Multi-Jitter random sampling pattern"),
|
||||
)
|
||||
)
|
||||
|
||||
enum_integrator = (
|
||||
('BRANCHED_PATH', "Branched Path Tracing", "Path tracing integrator that branches on the first bounce, giving more control over the number of light and material samples"),
|
||||
('PATH', "Path Tracing", "Pure path tracing integrator"),
|
||||
)
|
||||
)
|
||||
|
||||
enum_volume_sampling = (
|
||||
('DISTANCE', "Distance", "Use distance sampling, best for dense volumes with lights far away"),
|
||||
('EQUIANGULAR', "Equiangular", "Use equiangular sampling, best for volumes with low density with light inside or near the volume"),
|
||||
('MULTIPLE_IMPORTANCE', "Multiple Importance", "Combine distance and equi-angular sampling for volumes where neither method is ideal"),
|
||||
)
|
||||
)
|
||||
|
||||
enum_volume_interpolation = (
|
||||
('LINEAR', "Linear", "Good smoothness and speed"),
|
||||
('CUBIC', "Cubic", "Smoothed high quality interpolation, but slower")
|
||||
)
|
||||
)
|
||||
|
||||
enum_world_mis = (
|
||||
('NONE', "None", "Don't sample the background, faster but might cause noise for non-solid backgrounds"),
|
||||
('AUTOMATIC', "Auto", "Automatically try to determine the best setting"),
|
||||
('MANUAL', "Manual", "Manually set the resolution of the sampling map, higher values are slower and require more memory but reduce noise")
|
||||
)
|
||||
)
|
||||
|
||||
enum_device_type = (
|
||||
('CPU', "CPU", "CPU", 0),
|
||||
('CUDA', "CUDA", "CUDA", 1),
|
||||
('OPENCL', "OpenCL", "OpenCL", 2)
|
||||
)
|
||||
)
|
||||
|
||||
enum_texture_limit = (
|
||||
('OFF', "No Limit", "No texture size limit", 0),
|
||||
@@ -149,7 +149,8 @@ enum_texture_limit = (
|
||||
('2048', "2048", "Limit texture size to 2048 pixels", 5),
|
||||
('4096', "4096", "Limit texture size to 4096 pixels", 6),
|
||||
('8192', "8192", "Limit texture size to 8192 pixels", 7),
|
||||
)
|
||||
)
|
||||
|
||||
|
||||
class CyclesRenderSettings(bpy.types.PropertyGroup):
|
||||
@classmethod
|
||||
@@ -1139,7 +1140,6 @@ class CyclesObjectSettings(bpy.types.PropertyGroup):
|
||||
default=False,
|
||||
)
|
||||
|
||||
|
||||
@classmethod
|
||||
def unregister(cls):
|
||||
del bpy.types.Object.cycles
|
||||
@@ -1204,12 +1204,14 @@ class CyclesCurveRenderSettings(bpy.types.PropertyGroup):
|
||||
def unregister(cls):
|
||||
del bpy.types.Scene.cycles_curves
|
||||
|
||||
|
||||
def update_render_passes(self, context):
|
||||
scene = context.scene
|
||||
rd = scene.render
|
||||
rl = rd.layers.active
|
||||
rl.update_render_passes()
|
||||
|
||||
|
||||
class CyclesRenderLayerSettings(bpy.types.PropertyGroup):
|
||||
@classmethod
|
||||
def register(cls):
|
||||
@@ -1421,7 +1423,6 @@ class CyclesPreferences(bpy.types.AddonPreferences):
|
||||
return device_entry
|
||||
return None
|
||||
|
||||
|
||||
def update_device_entries(self, device_list):
|
||||
for device in device_list:
|
||||
if not device[1] in {'CUDA', 'OPENCL', 'CPU'}:
|
||||
@@ -1439,7 +1440,6 @@ class CyclesPreferences(bpy.types.AddonPreferences):
|
||||
# Update name in case it changed
|
||||
entry.name = device[0]
|
||||
|
||||
|
||||
def get_devices(self):
|
||||
import _cycles
|
||||
# Layout of the device tuples: (Name, Type, Persistent ID)
|
||||
@@ -1465,7 +1465,6 @@ class CyclesPreferences(bpy.types.AddonPreferences):
|
||||
opencl_devices.extend(cpu_devices)
|
||||
return cuda_devices, opencl_devices
|
||||
|
||||
|
||||
def get_num_gpu_devices(self):
|
||||
import _cycles
|
||||
device_list = _cycles.available_devices()
|
||||
@@ -1478,11 +1477,9 @@ class CyclesPreferences(bpy.types.AddonPreferences):
|
||||
num += 1
|
||||
return num
|
||||
|
||||
|
||||
def has_active_device(self):
|
||||
return self.get_num_gpu_devices() > 0
|
||||
|
||||
|
||||
def draw_impl(self, layout, context):
|
||||
layout.label(text="Cycles Compute Device:")
|
||||
layout.row().prop(self, "compute_device_type", expand=True)
|
||||
@@ -1500,7 +1497,6 @@ class CyclesPreferences(bpy.types.AddonPreferences):
|
||||
for device in opencl_devices:
|
||||
box.prop(device, "use", text=device.name)
|
||||
|
||||
|
||||
def draw(self, context):
|
||||
self.draw_impl(self.layout, context)
|
||||
|
||||
|
@@ -22,7 +22,7 @@ from bpy.types import (
|
||||
Panel,
|
||||
Menu,
|
||||
Operator,
|
||||
)
|
||||
)
|
||||
|
||||
|
||||
class CYCLES_MT_sampling_presets(Menu):
|
||||
@@ -86,6 +86,7 @@ def use_sample_all_lights(context):
|
||||
|
||||
return cscene.sample_all_lights_direct or cscene.sample_all_lights_indirect
|
||||
|
||||
|
||||
def show_device_active(context):
|
||||
cscene = context.scene.cycles
|
||||
if cscene.device != 'GPU':
|
||||
@@ -1741,6 +1742,7 @@ class CYCLES_SCENE_PT_simplify(CyclesButtonsPanel, Panel):
|
||||
col = split.column()
|
||||
col.prop(cscene, "ao_bounces_render")
|
||||
|
||||
|
||||
def draw_device(self, context):
|
||||
scene = context.scene
|
||||
layout = self.layout
|
||||
|
@@ -75,19 +75,25 @@ def foreach_cycles_node(callback):
|
||||
traversed = set()
|
||||
for material in bpy.data.materials:
|
||||
if check_is_new_shading_material(material):
|
||||
foreach_notree_node(material.node_tree,
|
||||
foreach_notree_node(
|
||||
material.node_tree,
|
||||
callback,
|
||||
traversed)
|
||||
traversed,
|
||||
)
|
||||
for world in bpy.data.worlds:
|
||||
if check_is_new_shading_world(world):
|
||||
foreach_notree_node(world.node_tree,
|
||||
foreach_notree_node(
|
||||
world.node_tree,
|
||||
callback,
|
||||
traversed)
|
||||
traversed,
|
||||
)
|
||||
for lamp in bpy.data.lamps:
|
||||
if check_is_new_shading_world(lamp):
|
||||
foreach_notree_node(lamp.node_tree,
|
||||
foreach_notree_node(
|
||||
lamp.node_tree,
|
||||
callback,
|
||||
traversed)
|
||||
traversed,
|
||||
)
|
||||
|
||||
|
||||
def displacement_node_insert(material, nodetree, traversed):
|
||||
@@ -102,9 +108,11 @@ def displacement_node_insert(material, nodetree, traversed):
|
||||
# Gather links to replace
|
||||
displacement_links = []
|
||||
for link in nodetree.links:
|
||||
if link.to_node.bl_idname == 'ShaderNodeOutputMaterial' and \
|
||||
link.from_node.bl_idname != 'ShaderNodeDisplacement' and \
|
||||
link.to_socket.identifier == 'Displacement':
|
||||
if (
|
||||
link.to_node.bl_idname == 'ShaderNodeOutputMaterial' and
|
||||
link.from_node.bl_idname != 'ShaderNodeDisplacement' and
|
||||
link.to_socket.identifier == 'Displacement'
|
||||
):
|
||||
displacement_links.append(link)
|
||||
|
||||
# Replace links with displacement node
|
||||
@@ -117,20 +125,22 @@ def displacement_node_insert(material, nodetree, traversed):
|
||||
nodetree.links.remove(link)
|
||||
|
||||
node = nodetree.nodes.new(type='ShaderNodeDisplacement')
|
||||
node.location[0] = 0.5 * (from_node.location[0] + to_node.location[0]);
|
||||
node.location[1] = 0.5 * (from_node.location[1] + to_node.location[1]);
|
||||
node.location[0] = 0.5 * (from_node.location[0] + to_node.location[0])
|
||||
node.location[1] = 0.5 * (from_node.location[1] + to_node.location[1])
|
||||
node.inputs['Scale'].default_value = 0.1
|
||||
node.inputs['Midlevel'].default_value = 0.0
|
||||
|
||||
nodetree.links.new(from_socket, node.inputs['Height'])
|
||||
nodetree.links.new(node.outputs['Displacement'], to_socket)
|
||||
|
||||
|
||||
def displacement_nodes_insert():
|
||||
traversed = set()
|
||||
for material in bpy.data.materials:
|
||||
if check_is_new_shading_material(material):
|
||||
displacement_node_insert(material, material.node_tree, traversed)
|
||||
|
||||
|
||||
def displacement_principled_nodes(node):
|
||||
if node.bl_idname == 'ShaderNodeDisplacement':
|
||||
if node.space != 'WORLD':
|
||||
@@ -139,6 +149,7 @@ def displacement_principled_nodes(node):
|
||||
if node.subsurface_method != 'RANDOM_WALK':
|
||||
node.subsurface_method = 'BURLEY'
|
||||
|
||||
|
||||
def square_roughness_node_insert(material, nodetree, traversed):
|
||||
if nodetree in traversed:
|
||||
return
|
||||
@@ -176,13 +187,14 @@ def square_roughness_node_insert(material, nodetree, traversed):
|
||||
|
||||
node = nodetree.nodes.new(type='ShaderNodeMath')
|
||||
node.operation = 'POWER'
|
||||
node.location[0] = 0.5 * (from_node.location[0] + to_node.location[0]);
|
||||
node.location[1] = 0.5 * (from_node.location[1] + to_node.location[1]);
|
||||
node.location[0] = 0.5 * (from_node.location[0] + to_node.location[0])
|
||||
node.location[1] = 0.5 * (from_node.location[1] + to_node.location[1])
|
||||
|
||||
nodetree.links.new(from_socket, node.inputs[0])
|
||||
node.inputs[1].default_value = 0.5
|
||||
nodetree.links.new(node.outputs['Value'], to_socket)
|
||||
|
||||
|
||||
def square_roughness_nodes_insert():
|
||||
traversed = set()
|
||||
for material in bpy.data.materials:
|
||||
@@ -298,6 +310,7 @@ def ambient_occlusion_node_relink(material, nodetree, traversed):
|
||||
nodetree.links.remove(link)
|
||||
nodetree.links.new(from_node.outputs['Color'], to_socket)
|
||||
|
||||
|
||||
def ambient_occlusion_nodes_relink():
|
||||
traversed = set()
|
||||
for material in bpy.data.materials:
|
||||
@@ -335,9 +348,11 @@ def do_versions(self):
|
||||
for scene in bpy.data.scenes:
|
||||
cscene = scene.cycles
|
||||
sample_clamp = cscene.get("sample_clamp", False)
|
||||
if (sample_clamp and
|
||||
if (
|
||||
sample_clamp and
|
||||
not cscene.is_property_set("sample_clamp_direct") and
|
||||
not cscene.is_property_set("sample_clamp_indirect")):
|
||||
not cscene.is_property_set("sample_clamp_indirect")
|
||||
):
|
||||
|
||||
cscene.sample_clamp_direct = sample_clamp
|
||||
cscene.sample_clamp_indirect = sample_clamp
|
||||
@@ -353,10 +368,11 @@ def do_versions(self):
|
||||
if bpy.data.version <= (2, 72, 0):
|
||||
for scene in bpy.data.scenes:
|
||||
cscene = scene.cycles
|
||||
if (cscene.get("no_caustics", False) and
|
||||
if (
|
||||
cscene.get("no_caustics", False) and
|
||||
not cscene.is_property_set("caustics_reflective") and
|
||||
not cscene.is_property_set("caustics_refractive")):
|
||||
|
||||
not cscene.is_property_set("caustics_refractive")
|
||||
):
|
||||
cscene.caustics_reflective = False
|
||||
cscene.caustics_refractive = False
|
||||
|
||||
|
Reference in New Issue
Block a user