Layer Layouts give you the power to playback or create real-time content in an intuitive, visual and 100% flexible way. The same visual node-based approach is used in all layer types, be it regular layers, 2D or 3D scenes.
Nodes
The main building block in any Layout is a node. In most cases it represents a function, for example, an Add node takes 2 numbers and outputs the sum. With various nodes, you can build complex behavior and even conditional action flows.
There are 2 types of nodes: actions and basic. Action nodes have at least one lifeline (lime color) square pin input or output and basic nodes have none. You’ll find out more about the importance of these lime square pins soon.
Special nodes
There are 3 special nodes in every layer. They are inserted by default and cannot be deleted.
- Run node executes every frame as long as the transport (the green vertical line in the Sequencer indicating where in the sequence you are) is on the layer.
- On layer begin executes only once at the beginning of the layer.
- On layer end is similar to on layer begin, except that it executes at the end of the layer.
Node connections
You’ll notice that connections between nodes have different colors. Each color represents what is sent along that connection. For example, red represents a float which stands for a ‘real number’ whereas purple represents a texture. You can only connect pins with the same color and only an output to an input. Additionally, one output pin can usually be connected to many inputs, but an input can only have one connection.
There is one connection type that is special. It is called Lifeline. It is shown with a lime color and it determines the action flow of the layout. Contrary to most other connection types, an input pin can have many connections whereas an output pin can have only one.
Action flow
Action flow determines which nodes will be called in each frame. You determine the action flow with Lifeline connections and every Lifeline starts with a Run node or one of other Lifeline generator nodes, such as On layer begin, On layer end, Keypress and so on. If we continue with the assumption that you are using Run node, you’ll see that it has only one Lifeline output which is executed every frame. Therefore, in every frame Lightact starts from the Run node and calls the next node in Lifeline chain and then the next and so on until Lifeline chain ends. The whole Lifeline chain is executed in every frame, but if the chain is not connected to the Run node, it is not going to be executed.
You can also split Lifeline node by using conditional nodes or delay its execution and so on. There are many ways you can play with how a particular layout is executed. For example, the layout below renders a blue 320 x 320 px square on a canvas at different positions depending on the value of the Bool input in the If node.
Variables
We’ve explained how values are transferred from one node to the next with the help of node connections. There is one other way to do it, which also allows you to transfer them between layers as well. This is done with the help of Variables. In any layer, you can create a variable and it instantly becomes available in any other layer. Variables come in different types. For example float, integer, texture and so on. Almost every connection type has a corresponding variable type.
You can set the value of a variable with a Setter node and you can retrieve its value with a Getter node. The layout below, for example, multiplies the current value of ‘testVar’ variable by 2 in every frame. So, if testVar is 1 in frame 1, it is going to be 2 in frame 2, then 4,8,16 and so on.
Real-time content
Content layers can be used for a variety of different things: from reading a movie file and rendering it to a canvas, to sending out UDP messages. One thing that they cannot do though is rendering content in real-time. That’s where 2D and 3D scenes come in.
2D scenes
A 2D scene is a special type of layer with a specific set of available nodes. In a 2D scene, you can create simple shapes like a rectangle or a circle and make adjustments to them in real-time. The usefulness of 2D scenes will grow over time, but at the moment it is primarily used to create texture variables in real-time.
The output of a 2D scene can be visible in the preview area of the window. It is also saved in a texture variable of your choosing. So if you want to use the output of a 2D scene in a layer (to render it to a canvas for example) you first have to create a texture variable, then set it as the parent variable of your 2D scene and then grab this variable with a Getter node.
Please note, Lightact will draw elements in the same order as they are connected in the lifeline chain. So in the image below we are drawing first a white rectangle and then a purple circle.
3D scenes
3D scenes are similar to 2D scenes in that their output is usually written to a Texture variable, which is then read from within other content layers.
In 3D scenes, however, space is not 2 dimensional but 3 dimensional and in order to view it, you have to create a camera first. To do that you have to create a camera node and connect it an active lifeline. Before the camera view can be grabbed from other layers, you have to set a parent texture variable of the camera. This is the Texture variable the Camera node will render its view to.
The layout below, for example, creates a purple sphere and a camera, which is rendering its view to CameraFrom3DScene Texture Variable. This variable can then be easily read from other layouts with a Getter node.
While in 3D scenes you can draw spheres, the main usefulness of 3D scenes lies in their ability to create real-time particle systems.