Skip to content

Commit

Permalink
fix color ramp regression, fix node positioning
Browse files Browse the repository at this point in the history
  • Loading branch information
meta-androcto committed Sep 3, 2016
1 parent 7ad5abd commit d5d095f
Showing 1 changed file with 16 additions and 13 deletions.
29 changes: 16 additions & 13 deletions materials_utils/materials_cycles_converter.py
Original file line number Diff line number Diff line change
Expand Up @@ -271,11 +271,14 @@ def AutoNode(active=False, operator=None):
# Starting point is diffuse BSDF and output material
# and a Color Ramp node
shader = TreeNodes.nodes.new('ShaderNodeBsdfDiffuse')
shader.location = 0, 470
shader.location = 10, 10
shader_val = TreeNodes.nodes.new('ShaderNodeValToRGB')
shader_val.location = 0, -200
shout = TreeNodes.nodes.new('ShaderNodeOutputMaterial')
shout.location = 200, 400
shout.location = 200, 10
try:
links.new(shader.outputs[0], shout.inputs[0])
links.new(shader.inputs[0], shader_val.outputs[0])
except:
link_fail = True

Expand All @@ -290,7 +293,7 @@ def AutoNode(active=False, operator=None):
collect_report("INFO: Make DIFFUSE shader node for: " + cmat.name)
TreeNodes.nodes.remove(shader)
shader = TreeNodes.nodes.new('ShaderNodeBsdfDiffuse')
shader.location = 0, 470
shader.location = 10, 10
try:
links.new(shader.outputs[0], shout.inputs[0])
except:
Expand All @@ -301,7 +304,7 @@ def AutoNode(active=False, operator=None):
collect_report("INFO: Make GLASS shader node for: " + cmat.name)
TreeNodes.nodes.remove(shader)
shader = TreeNodes.nodes.new('ShaderNodeBsdfGlass')
shader.location = 0, 470
shader.location = 0, 100
try:
links.new(shader.outputs[0], shout.inputs[0])
except:
Expand All @@ -312,7 +315,7 @@ def AutoNode(active=False, operator=None):
collect_report("INFO: Make MIRROR shader node for: " + cmat.name)
TreeNodes.nodes.remove(shader)
shader = TreeNodes.nodes.new('ShaderNodeBsdfGlossy')
shader.location = 0, 520
shader.location = 0, 10
try:
links.new(shader.outputs[0], shout.inputs[0])
except:
Expand All @@ -325,20 +328,20 @@ def AutoNode(active=False, operator=None):
collect_report("INFO: Mix EMISSION shader node for: " + cmat.name)
TreeNodes.nodes.remove(shader)
shader = TreeNodes.nodes.new('ShaderNodeEmission')
shader.location = 0, 450
shader.location = 0, 200
try:
links.new(shader.outputs[0], shout.inputs[0])
except:
link_fail = True
else:
if not Add_Emission:
collect_report("INFO: Add EMISSION shader node for: " + cmat.name)
shout.location = 550, 330
shout.location = 600, 100
Add_Emission = TreeNodes.nodes.new('ShaderNodeAddShader')
Add_Emission.location = 370, 490
Add_Emission.location = 370, 100

shem = TreeNodes.nodes.new('ShaderNodeEmission')
shem.location = 180, 380
shem.location = 0, 200
try:
links.new(Add_Emission.outputs[0], shout.inputs[0])
links.new(shem.outputs[0], Add_Emission.inputs[1])
Expand Down Expand Up @@ -384,7 +387,7 @@ def AutoNode(active=False, operator=None):

# remove Color Ramp and links from the default shader and reroute
try:
shout.location = 400, 460
shout.location = 400, 0
for link in links:
links.remove(link)

Expand All @@ -393,12 +396,12 @@ def AutoNode(active=False, operator=None):
clay_frame.label = 'Clay Material'

sh_glossy = TreeNodes.nodes.new('ShaderNodeBsdfGlossy')
sh_glossy.location = 0, 350
sh_glossy.location = 0, 200
sh_glossy.inputs['Color'].default_value = CLAY_GLOSSY
sh_mix = TreeNodes.nodes.new('ShaderNodeMixShader')
sh_mix.location = 200, 460
sh_mix.location = 200, 0
sh_weight = TreeNodes.nodes.new('ShaderNodeLayerWeight')
sh_weight.location = 0, 590
sh_weight.location = 0, 350
links.new(sh_mix.outputs[0], shout.inputs[0])
links.new(sh_weight.outputs[1], sh_mix.inputs[0])
links.new(shader.outputs[0], sh_mix.inputs[1])
Expand Down

0 comments on commit d5d095f

Please sign in to comment.