---
title: "Flashy Neons"
canonical: "https://rmanwiki-27.pixar.com/space/RU/638877713/Flashy%20Neons"
format: markdown
---
![NeonSign_Banner.jpg](media://ec2e9edd-f89d-4379-b3c3-0e08b00268a6)


Leading on from the previous lesson, let’s now bring our neon sign to life with some cool VEX code in Solaris!

![DownloadButton2.png](media://995f31c5-f337-49f0-a079-d87895da9dfb)

In this lesson, we’re going to amend the four Glow shaders from the [Neons ](https://renderman.atlassian.net/wiki/spaces/RU/pages/392953857)lesson to be able to control the PxrSurface Glow Intensity with a Primvar.  Once done, we’ll be able to control the neons' animation using some clever VEX code.


> ℹ️ <span style="color: #ffffff">**USD Asset Setup**</span>

What we’re after is to dynamically control the ‘chasing’ animation of the neon tubes.  


The first thing we need to do is edit the Glow shaders.  In Solaris, this can be done by creating a *editmaterialproperties* node.  We can add the glow shader to this node and further edit it.  

Inside the first Glow Shader, let’s create a PrimVar node, leave the Variable type to Float, but make sure you set the Float value to 0.1. This gives us an initial intensity value.  

In this example, or PrimVar is called Outer_INT

The resultR from the Primvar is then connected to the glowgain of the PxrSurface.


We need to repeat these steps for each of the other Glow shaders, ensuring each PrimVar has a unique name. 

I used 

Outer_INT  
Mid_INT

Inner_INT

White_INT

![Solaris_Animate_Solaris_AddPrimvar.jpg](media://ac946a5f-a09e-4840-81d3-84614072b416)

Once done, we need to re-publish the USD asset and then reload it into our main network.


> ℹ️ <span style="color: #ffffff">**Time to Animate!**</span>

Hand-animating these neons would take a while, but why do it by hand when we have the power of VEX in Solaris?

Start by creating an AttributeWrangle node and paste the following code into the VEXpression box.

```
int off = chi("off");
int on = chi("on");
int transition = chi("transition");
int A = off;
int B = off + transition;
int C = off + transition + on;
int D = off + 2 * transition + on;

float val = 0;
int frame = int(@Frame - $FSTART + chi("frameOffset") * @elemnum) % (D + 1);

if(frame < A)
    val = 0;
else if (frame >= A && frame < B)
    val = 1 - (B - frame) / float(B - A);
else if(frame >= B && frame < C)
    val = 1;
else if (frame >= C && frame < D)
    val = (D - frame) / float(D - C);
val *= ch("intensity");

@inputs:defaultFloat = val;
//@inputs:intensity = val;
```


Once compiled, you’ll see the following interface!

![Solaris_Animate_Solaris_VEX.jpg](media://867aa90a-5e60-4bca-9ece-32eb298fe16c)

![Solaris_Animate_Solaris_1.jpg](media://b10a26ab-2b0f-45fd-9891-aa10b28acf20)

The last thing we need to do is to specify which Primitives we want to run the code over.


Using a handy wildcard as 

```
/NeonR/materials/**/**_INT
```

will look through all the materials and find the nodes that have _INT in the same.  We can easily and quickly pick up all the primvars we have in our Glow Shaders.


Here is a quick rundown of the parameters 

**OFF**

How many frames does each neon stay OFF for

**ON**

How many frames does the neons stay ON for

**Transition**

The number of frames to ramp up and down

**FrameOffset**

Change this value to alter the offset time between all the neons

**Intensity**

What is the maximum intensity the neons should reach


And that’s it… Feel free to play with the parameters to create your own chasing times, and you can use this code on all your neons, too.  

Just make sure you have a PrimVar attached to the *glowgain in *your surfaces, and you’ll be good to go.


> 📝 Thanks to Damien Maupu at Pixar for the cool VFX code!