Guest User

Untitled

a guest
May 24th, 2018
78
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.49 KB | None | 0 0
  1. def append_shaped_absorb(data=bpy.data, use_fake_user=False):
  2. in_sockets = [
  3. {'name': 'Color',
  4. 'data_type': 'NodeSocketColor',
  5. 'default_value': (0.0, 0.0, 0.0, 1.0)},
  6. {'name': 'Density',
  7. 'default_value': 1.0,
  8. 'min_value': 0.0},
  9. {'name': 'Fac',
  10. 'default_value': 0.5,
  11. 'min_value': 0.0,
  12. 'max_value': 1.0},
  13. {'name': 'Lower',
  14. 'default_value': 0.0},
  15. {'name': 'Upper',
  16. 'default_value': 1.0}
  17. ]
  18.  
  19. out_sockets = [
  20. {'name': 'Volume',
  21. 'data_type': 'NodeSocketShader'},
  22. {'name': 'Color',
  23. 'data_type': 'NodeSocketColor'},
  24. {'name': 'Fac',
  25. 'min_value': 0.0,
  26. 'max_value': 1.0}
  27. ]
  28.  
  29. absorb_group = append_group_node(name='Absorb', data=data, use_fake_user=use_fake_user, in_sockets=in_sockets, out_sockets=out_sockets)
  30.  
  31. # Create nodes.
  32. nodes = absorb_group.nodes
  33. thresh = append_group_inst(nodes=nodes, group_name='Threshold', data=data, group_creation_func=append_threshold, data=data, use_fake_user=use_fake_user)
  34. holdout = nodes.new('ShaderNodeHoldout')
  35. mixsh = nodes.new('ShaderNodeMixShader')
  36. vol_abs = nodes.new('ShaderNodeVolumeAbsorption')
  37. mxrgb = nodes.new('ShaderNodeMixRGB')
  38.  
  39. # Set default values.
  40. mxrgb.inputs[1].default_value = (0.0, 0.0, 0.0, 0.0)
  41.  
  42. # Link nodes.
  43. links = absorb_group.links
  44. links.new(mixsh.inputs[0], thresh.outputs[0]) # Link threshold to mix factor.
  45. links.new(mixsh.inputs[1], holdout.outputs[0]) # Link holdout to mix slot 1.
  46. links.new(mixsh.inputs[2], vol_abs.outputs[0]) # Link absorb to mix slot 2.
  47. links.new(mxrgb.inputs[0], thresh.outputs[0]) # Link threshold to color mix.
  48.  
  49. # Link to group inputs.
  50. absorb_input = absorb_group.nodes['Group Input']
  51. links.new(vol_abs.inputs[0], absorb_input.outputs[0]) # Color.
  52. links.new(mxrgb.inputs[2], absorb_input.outputs[0]) # Color.
  53. links.new(vol_abs.inputs[1], absorb_input.outputs[1]) # Density.
  54. links.new(thresh.inputs[0], absorb_input.outputs[2]) # Fac.
  55. links.new(thresh.inputs[1], absorb_input.outputs[3]) # Lower.
  56. links.new(thresh.inputs[2], absorb_input.outputs[4]) # Upper.
  57.  
  58. # Link to group outputs.
  59. absorb_output = absorb_group.nodes['Group Output']
  60. links.new(absorb_output.inputs[0], mixsh.outputs[0]) # Volume.
  61. links.new(absorb_output.inputs[1], mxrgb.outputs[0]) # Color.
  62. links.new(absorb_output.inputs[2], thresh.outputs[0]) # Fac.
  63.  
  64. return absorb_group
Add Comment
Please, Sign In to add comment