Dynamic Maths Expression - baldingwizard/Blender-Addons GitHub Wiki

(aka "Node Expressions")

See also BaldingWizard blog for examples and additional information.

Download

Node Expressions (Lite) for Blender 2.7x (1.11)

Node Expressions (Lite) for Blender 2.8 (1.11)

Node Expressions (Full) (BlenderMarket)

Node Expressions (Full) for Blender 2.7x (1.33)

Node Expressions (Full) for Blender 2.8+ (1.33)

Experimental : Node Expressions (Full) for Blender 2.8+ (1.34) (includes changes for supporting optional iterations and other minor syntax support for additional Mandelbulb presets)

Node Expressions (Full) for Blender 3.1+ (2.02)

!!! Note !!!

This add-on has been used as the basis of a 'production-ready' add-on available on Blender Market at https://blendermarket.com/products/node-expressions. The full version is now also available free to download (see above) The 'Lite' version is available here as well as being available on Blender Market at the above link. Alternatively, please support me by sending a donation to https://www.paypal.me/BaldingWizard or [email protected]

The 'full' version includes additional functionality such as sub-expressions, optimisations, text block editing of expressions as well as a 'preset' expression library and more.

Details

The Dynamic Maths Expression add-on provides a means to enter a mathematical expression which is then parsed to generate a node group built up of standard maths nodes to implement that expression. It is available within the Node Editor 'Add' menu as 'Maths Expression'. On selecting the menu option you'll be presented with a popup window prompting for you to enter your expression.

Add Expression

For example, entering the expression a+b will result in a node with two inputs ('a' and 'b'), outputting a single value that is the mathematical sum of 'a' and 'b'.

Enter Expression Dialog

This will result in the automatic creation of the following node group :

Expression 'a+b'

The following standard mathematical operations are implemented :

  • Addition a+b
  • Subtraction a-b
  • Multiplication a*b
  • Division a/b
  • Power a**b

The following standard functions are implemented :

  • Sine sin(x)
  • Cosine cos(x)
  • Tangent tan(x)
  • Arcsine asin(x)
  • Arccosine acos(x)
  • Arctangent atan(x)
  • Absolute abs(x)
  • Round round(x,y)
  • Maximum max(x,y)
  • Minimum min(x,y)
  • Modulo mod(x,y)
  • Log log(x,y)

The following 'comparators' are also permitted. These return False (0) or True (1) based on the input values :

  • Greater Than x>y
  • Less Than x<y
  • Greater Than or Equals x>=y
  • Less Than or Equals x<=y
  • Equals x==y
  • Maximum max(x,y)
  • Minimum min(x,y)

In addition, the following extended function is provided. This is implemented by automatically expanding to implement the function by combining the above functions and operations :

  • atan2 atan2(x,y)

Any of the above functions, operators and comparators can be combined into a single expression and standard operator precedence rules should be followed - ie, power takes precedence over multiplication and division, which take precedence over addition and subtraction. Comparators (ie, >, <, >=, <=, ==) take least precedence. The expression can also include brackets to indicate overriding the operator precedence.

The expression can be edited using the Edit button of the custom node created with the node group. The node group is compatible with GPU rendering (since it only uses 'standard' Maths nodes) and can be exported to use in a Blend file independently of the add-on.

The expression can be arbitrarily complicated and the groups inputs and outputs will be automatically updated with the relevant inputs and outputs to the expression.

Edit expression

Note also that multiple expressions can be entered, separated by commas, so as to provide a group with multiple outputs - for example, sum=a+b+c,distance=(a*a+b*b+c*c)**0.5,minimum=min(min(a,b),c),maximum=max(max(a,b),c) to create a group with inputs of a,b,c and outputs of sum,distance,minimum,maximum.