Circle Image

Pixaflux

Tutorial Tunnel Scale

The tunnel effect scale node graph project

In this tutorial you will learn how to create a Node Graph project that scales an image in multiple steps, composing each step on top of the previous one to create a tunnel like effect.

Visual Scripting Tunnel Scale

Create the Node Graph project

  1. Create a new empty project. File > New > Empty Project

  2. Add an image Generate.png Arrow Image Reader icon. Drag drop the new image, or and drag and drop new reader icon.

  3. Add a transform node. Compose.pngArrow Image Transform icon.

  4. In Transform node expose as input the Scale attribute. Right click the Transform node and check the Scale attribute.

  5. Create a new Attributes node. Project icon Arrow Attributes icon. Rename it as Scale, set the type number between 0.0 and 1.0 with 2 decimals. Set the scale to 0.9. This will be the default value of the attribute when this project is loaded in by a Node Graph node.

    Scale Attribute Tunnel Scale

  6. Add a Math > Point node. Math icon Arrow Attributes icon. Expose attributes x and y.

  7. Connect Attributes> scale to x>Point and y > Point. Scale Attribute to Point Node

    • Project icon Arrow Attributes icon The Attributes node defines 3 attributes: The size of the borders and the colors of the two borders.

    • Generate.png Arrow Generate Gradient.png The Gradient node.

    • Project icon Arrow Image IO icon The Image IO inside the Inputs Node Frame defines the input of the reusable node.

    • Project icon Arrow Image IO icon The Image IO inside the Outputs Node Frame defines the output of the reusable node.

    • Layout iconArrow Border icon The nodes inside the Body of the Algorithm Node Frame define the body of the custom node: The Border nodes. Their exposed attributes are fed by the Attributes Node. Left Click on node to expose its attributes.

This project is saved in a file Double_Border.pxf.

Reusing the Double Border node graph

  1. Create a new empty project. File > New > Empty Project
  2. Create an Node Graph node Geometry icon Arrow Image Set Pivot icon.
  3. Click the Path button and load the Double_Border.pxf project. Double click the node to reactivate it and display all its attribute, inputs and outputs.
  4. Drag and drop an image into the project to create a Reader node.
  5. Connect [Reader › image] to [image › Double_Border].
  6. Set the size and color of the border.

Double Border

This Double_Border node applies the two borders to the image with the border size and colors defined in the attributes of the Node Graph node.

Adding More Borders

You will now modify the Double_Border.pxf project to add more borders to the image using multiple loops. Each border will be one size larger than the previous border.

  1. Load the Double_Border.pxf project.
  2. Create a new Loop Iterations node. This node has two number outputs, the current iteration and the number of iterations. The attributes of this node can be used to test the behavior of the node graph at different iterations.
  3. Create a new Number Multiply node.
  4. Connect [Loop Iterations › iteration] to [number_a › Number Multiply]. The Number Multiply node will multiply the size of the border by the current iteration.
  5. Connect [Number Multiply › number] to [size › Border].
  6. Connect [Number Multiply › number] to [size › Border].
  7. Resize the Node Frames and add a new Node Frame for the Loop Iterations node.
  8. Modify the Loop Iterations Iteration attribute to see how the border size changes on each iteration.
  9. Save this project as DoubleBorderLoop.pxf.

Double Border Loop

Testing the Double Border Loop Project

In a new project create a new Reader node with an image and a new Node Graph node. Load the DoubleBorderLoop.pxf project in this node.

Increase the number of iterations in the DoubleBorderLoop node.

Testing Double Border Loop

There is something wrong. The DoubleBorderLoop node is not applying multiple borders, instead it is creating a larger border.

This happens because by default the Node Graph node applies the same node graph to the same input image, and each iteration makes the border larger.

To fix the effect you need to tell the Node Graph node that the new border has to be applied to image generated in the previous loop.

Fixing the Double Border Loop Project

Load the DoubleBorderLoop.pxf project.

  1. Activate the input Image IO node and rename it image.
  2. Activate the output Image IO node and rename it image.

Testing the Double Border Loop Project

In a new project create a new Reader node with an image and a new Node Graph node. Load the DoubleBorderLoop.pxf project in this node.

Increase the number of iterations in the DoubleBorderLoop node.

Testing Double Border Loop Fixed

Creating a Custom Node from the Double Border project

Now that you have a node graph project that can be reused, you can create a new node type