2
$\begingroup$

I want to make custom node that can be used in compositing nodes. I stuck in part when I need to pass color value (and do some operation on that) from input to output socket.

def init(self, context):
    inp = self.inputs.new('NodeSocketColor', "Input 1")
    inp2 = self.inputs.new('NodeSocketColor', "Input 2")

    out = self.outputs.new('NodeSocketColor', "Out")
    out2 = self.outputs.new('NodeSocketColor', "Out 2")
  1. I don't know how to set up links (inp -> out, inp2 -> out2). Outputs are always connected to the first input socket.
  2. How to change value before outputting.
$\endgroup$
1
$\begingroup$

From the code above I'm not exactly sure how to give a contextually direct solution, but in an attempt to help move along the issue...

  1. Set up a node tree reference:

    tree = bpy.context.scene.node_tree

  2. Set up a link reference:

    your_links = tree.links

  3. Make your links:

    your_link = your_links.new(your_node.outputs[0],another_node.inputs[0])

To change the values you could do something like:

your_node.inputs[0].default_value = 0.3
$\endgroup$
  • $\begingroup$ As I understand your answer, you are talking about linking few nodes to solve a problem. I was thinking about making a singular custom node performing complex algorithm. $\endgroup$ – theres1 Aug 4 '15 at 13:47

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.