13
$\begingroup$

An object's Custom Properties panel looks like a great way to inject variable values in the Compositor:

Custom Properties

However, there does not seem to be an Input that defines a reference to the Object Data's Custom Properties.

In the above image, I wanted to reuse the same Material Node setup for two different objects. The difference being one has transparent checkers (to create a dashed line) and the other is solid.

Without using Python, Drivers, Empty objects, or Animation Nodes:

  • Is it possible to pass variables (such as numbers and colours) into the Compositor?
  • If not, how would you reuse a Material Node setup across multiple objects, but vary it depending on some value?

I thought about using the Object Index, but that seems like a lot of work just to toggle a multiplication factor.

This is a general-purpose question. I'm not asking specifically how to make a reusable dashed or non-dashed line (i.e., Transparent shader and Checkered Texture). I'm asking how to reference various types of variables within the Compositor so as to program Material Nodes with different capacities.

$\endgroup$

1 Answer 1

13
$\begingroup$

To do this, you need to use your custom property to drive a value node.

EDIT: Added compositor example in addition to the original cycles material example.

This is possible in either the material or compositor node trees. Below is an example demonstrating the process in the compositor, and at the end I'll also include an example from a cycles material node setup.

  1. Add a value node ( ShiftA --> Input --> Value ) to your node tree.
  2. Right click on the number in the input box and add driver. Step1
  3. Open the graph editor window, change the view mode from F-Curve to Drivers, then open the properties panel (N).
  4. Change the driver Type to Scripted Expression.
  5. Change the variable Type to Single Property.
  6. In the variable's Path box type the name of your custom property delimited by square brackets and double quotes. Example: ["myProp"]
  7. In the Expr (expression) input box, make sure the name of the driver variable (default "var") is present. enter image description here

That's it. You're value node is now connected to the value of your custom property, and any changes you make to the custom prop will be reflected there.

In the compositor, however, changing the custom property does not immediately trigger a scene update, which means the result will not be shown until you perform some other action that updates the view. In the example below, I simply Ctrl + LMB clicked on the Color node to reconnect the Viewer node, which updated the view.

Result

Cycles material example: enter image description here

$\endgroup$
5
  • $\begingroup$ Without drivers, as per the question, it's not possible? (Drivers seem overkill just to pass a value around.) $\endgroup$ Commented Oct 27, 2015 at 9:01
  • 1
    $\begingroup$ Not AFAIK. The Attribute input node, which is a natural candidate for this role, does not support custom properties from what I've read in the docs. $\endgroup$
    – TLousky
    Commented Oct 27, 2015 at 9:03
  • 4
    $\begingroup$ Silly comment. When specifying the data path to the custom property, make sure to use double-quotes, as in ["CustomPropertyname"]. Single quotes around the property name do not work, at least in Blender 2.8. $\endgroup$
    – Dazotaro
    Commented May 8, 2019 at 18:38
  • 6
    $\begingroup$ How can I pull a custom property from the current object, instead of a specific object? e.g. I want to have multiple objects with different colours but the same material for example. $\endgroup$ Commented Jan 28, 2021 at 22:49
  • $\begingroup$ Did you ever get an answer to how to get the custom prop from the current object? $\endgroup$
    – Jos
    Commented Jun 15, 2022 at 16:02

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .