You are here:
  • Home
  • Unity
  • Texture Sharing in LightAct for Unity

This article will explain the most important aspects of Extremely Simple Unity Integration sample project that is available in the Intro Window under the Unity tab. It works out-of-the-box with Unity Sample Project available free-of charge on our website.

Please note, we won’t be going into every detail of LightAct. If you are a complete LightAct beginner you might want to have a look at the following resources:

Texture Sharing

Every integration in LightAct starts in Devices window. So, without further ado, let’s open it by pressing F7 or by going to Window and then clicking on Devices.

Once the window opens, you’ll see 5 nodes. We can ignore the one describing your computer, which leaves 2 Spout nodes and 2 JSON memory writer nodes. Let’s focus on Spout first.

Sending Spout from LightAct to Unity

For the purpose of this article, let’s say Spout is a place in computer’s memory where applications can write textures to and from where other applications can read them at the same time in a very fast and efficient way. Each Spout stream has to have a ‘name’ so that the application that’s trying to read the texture, knows which Spout name it should look for.

If you select Spout Writer node, you’ll see both of these properties are on the right. However, as you’ll notice, they are not editable. In order to make them editable, uncheck the Streaming checkbox on the node itself.

Now that we’ve made them editable, let’s walk through them:

  • Spout name is the name of Spout stream LightAct is writing to. You will have to type in the exact same name on Unity side.
  • Texture width and height determine the resolution of the texture. This will affect the Texture connections that you can connect to the Spout Sender node in Layer Layouts.

Let’s leave the entries exactly as they are, at the moment, and just hit Apply or deselect node, if you don’t see Apply button.

Make sure you check the Streaming checkbox back again.

Now all that we have to do is determine which texture we want to send to Unity. We do that in LA2Unity layer in the Sequencer.

Setting up Spout Sender in Layer Layouts

Open LA2Unity layer in the Sequencer by double-clicking on it.

In this Layout, you’ll see a Spout Sender node.

If you select it, you will see, in its properties on the right hand side, that it has our Spout Writer node selected as its parent. This means that it is going to send whichever texture (purple connection) is connected to the Texture pin on the node, to that Spout Writer.

Receiving Spout in LightAct

To receive Spout in LightAct the process is quite similar to sending it. Again, it all starts in the Devices window, so let’s open it again.

However, if you select Spout Reader node, you’ll see that it only has Spout name property. Again, in order to be able to receive the texture from Spout this name has to match exactly the name of Spout stream in the application that is sending it. In our case that is Unity, of course.

Make sure that you check Listening checkbox and then close the Devices window. Next, open the Unity2LA layer.

In this Layout, you will see a Spout Listener node. 

If you select it, you will see it has our Spout Reader node selected as the parent device. This means that this Listener node will output from its Output purple texture pin whichever texture our Spout Reader node in the Devices window is receiving.

To explain the rest of this purple Texture chain originating in our Spout Listener node: first, we connect the texture to Set Texture Channel node, which overwrites the alpha channel of the texture in order to make the sky opaque too. Then we bring the resulting texture to Render to Canvas node, which renders it to a LightAct canvas and from there it goes to the Video screen

For more information about how content flows in LightAct please refer to LightAct Resources in Beginners links above.

In the next article, we will explain how to set up data sharing in LightAct for Unity.