Cleanup: pep8, cycles
This commit is contained in:
parent
b328a59373
commit
0108ce1fe5
|
@ -45,9 +45,9 @@ if "bpy" in locals():
|
|||
import bpy
|
||||
|
||||
from . import (
|
||||
engine,
|
||||
version_update,
|
||||
)
|
||||
engine,
|
||||
version_update,
|
||||
)
|
||||
|
||||
|
||||
class CyclesRender(bpy.types.RenderEngine):
|
||||
|
|
|
@ -82,15 +82,17 @@ def _parse_command_line():
|
|||
if args.cycles_resumable_current_chunk is not None:
|
||||
import _cycles
|
||||
_cycles.set_resumable_chunk(
|
||||
int(args.cycles_resumable_num_chunks),
|
||||
int(args.cycles_resumable_current_chunk))
|
||||
int(args.cycles_resumable_num_chunks),
|
||||
int(args.cycles_resumable_current_chunk),
|
||||
)
|
||||
elif args.cycles_resumable_start_chunk is not None and \
|
||||
args.cycles_resumable_end_chunk:
|
||||
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_num_chunks),
|
||||
int(args.cycles_resumable_start_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')
|
||||
|
||||
|
|
File diff suppressed because it is too large
Load Diff
|
@ -19,10 +19,10 @@
|
|||
import bpy
|
||||
|
||||
from bpy.types import (
|
||||
Panel,
|
||||
Menu,
|
||||
Operator,
|
||||
)
|
||||
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':
|
||||
|
@ -965,9 +966,9 @@ class CYCLES_LAMP_PT_preview(CyclesButtonsPanel, Panel):
|
|||
@classmethod
|
||||
def poll(cls, context):
|
||||
return context.lamp and \
|
||||
not (context.lamp.type == 'AREA' and
|
||||
context.lamp.cycles.is_portal) \
|
||||
and CyclesButtonsPanel.poll(context)
|
||||
not (context.lamp.type == 'AREA' and
|
||||
context.lamp.cycles.is_portal) \
|
||||
and CyclesButtonsPanel.poll(context)
|
||||
|
||||
def draw(self, context):
|
||||
self.layout.template_preview(context.lamp)
|
||||
|
@ -1035,7 +1036,7 @@ class CYCLES_LAMP_PT_nodes(CyclesButtonsPanel, Panel):
|
|||
def poll(cls, context):
|
||||
return context.lamp and not (context.lamp.type == 'AREA' and
|
||||
context.lamp.cycles.is_portal) and \
|
||||
CyclesButtonsPanel.poll(context)
|
||||
CyclesButtonsPanel.poll(context)
|
||||
|
||||
def draw(self, context):
|
||||
layout = self.layout
|
||||
|
@ -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
|
||||
|
@ -1823,7 +1825,7 @@ def get_panels():
|
|||
'WORLD_PT_mist',
|
||||
'WORLD_PT_preview',
|
||||
'WORLD_PT_world'
|
||||
}
|
||||
}
|
||||
|
||||
panels = []
|
||||
for panel in bpy.types.Panel.__subclasses__():
|
||||
|
|
|
@ -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,
|
||||
callback,
|
||||
traversed)
|
||||
foreach_notree_node(
|
||||
material.node_tree,
|
||||
callback,
|
||||
traversed,
|
||||
)
|
||||
for world in bpy.data.worlds:
|
||||
if check_is_new_shading_world(world):
|
||||
foreach_notree_node(world.node_tree,
|
||||
callback,
|
||||
traversed)
|
||||
foreach_notree_node(
|
||||
world.node_tree,
|
||||
callback,
|
||||
traversed,
|
||||
)
|
||||
for lamp in bpy.data.lamps:
|
||||
if check_is_new_shading_world(lamp):
|
||||
foreach_notree_node(lamp.node_tree,
|
||||
callback,
|
||||
traversed)
|
||||
foreach_notree_node(
|
||||
lamp.node_tree,
|
||||
callback,
|
||||
traversed,
|
||||
)
|
||||
|
||||
|
||||
def displacement_node_insert(material, nodetree, traversed):
|
||||
|
@ -102,10 +108,12 @@ 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':
|
||||
displacement_links.append(link)
|
||||
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
|
||||
for link in displacement_links:
|
||||
|
@ -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
|
||||
|
@ -163,7 +174,7 @@ def square_roughness_node_insert(material, nodetree, traversed):
|
|||
for link in nodetree.links:
|
||||
if link.to_node.bl_idname in roughness_node_types and \
|
||||
link.to_socket.identifier == 'Roughness':
|
||||
roughness_links.append(link)
|
||||
roughness_links.append(link)
|
||||
|
||||
# Replace links with sqrt node
|
||||
for link in roughness_links:
|
||||
|
@ -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:
|
||||
|
@ -288,7 +300,7 @@ def ambient_occlusion_node_relink(material, nodetree, traversed):
|
|||
ao_links = []
|
||||
for link in nodetree.links:
|
||||
if link.from_node.bl_idname == 'ShaderNodeAmbientOcclusion':
|
||||
ao_links.append(link)
|
||||
ao_links.append(link)
|
||||
|
||||
# Replace links
|
||||
for link in ao_links:
|
||||
|
@ -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
|
||||
|
||||
|
|
Loading…
Reference in New Issue