In Realtime VFX, randomizing values is usually helping alot to breaking repetetive patterns in textures. You achieve that through setting random values, for example for size, rotation, speed and all kinds of parameters for your effects.

One thing i recently stumbled upon in the new Unity3d VFX Graph is randomly flipping UV coordinates on billboards that play a flipbook. I wanted a particle billboard to get a random UV flip on creation but then stick to it till the end of lifetime of each billboard. There is probably many ways to solve this. Here is one simple approach.

Okay, so here is the deal, this is our debug atlas texture.

I want to playback this texture on a billboard and have each particle a random U and V flip assigned on generation and then stay like this in this until end of lifetime.

The trick is to just set either a positive or a negative scale on the billboard (should also work for other shapes though).

First, in the Output block, at the end, add a “Multiply Scale” node set to the channels XY:

Then make sure there is no scaling after this node happening, as it may mess things up.

Then hook up the following node chain to the scale. I just hooked it up to scale so it will actually affect both axis, but you can split them or just choose one axis to control if it should only flip on X or Y.

The Random Number generates a floating value between 0 and 1 per particle. The Step, with a threshold of 0.5 either spits out 1 or 0, depending if the random number is below or above 0.5.

The Compare is then checking for whether we have a 0 or a 1 (if Left ist equal to Right => true) and gives a boolean.

This is then feeded into the Branch, which results in a value of -1 if true or 1 if false.

And voilà, there you have it. A random flip for each particle that works well with the flipbook:

Thanks for reading!

Leave a comment