How to access ParticleSystemVertexStream.StableRandomX in a fragment shader

I need unique number per particle accesible in my shader. The description for ParticleSystemVertexStream.StableRandomX in the documentation sounds like exactly what I need: Unity - Scripting API: ParticleSystemVertexStream.StableRandomX

But the documenation is sparse. I have no idea how to use this.

Googling for ParticleSystemVertexStream.StableRandomX returns almost literally nothing except that page.

Ideally, I’d like to be able to access a random unique number per particle inside the shader used on the particle system without even needing a C# script on the particle system gameobject.

Wow, neat! That was a lot easier than I expected. Thank you for pointing me in the right direction! :slight_smile:

What range are those random values in?, i want to try and get a random range of numbers between -1,1.

Using the custom vertex stream exposes the random system used in the particle system, so i was hoping the stable random value would produce a better random value, but as i need to control the range, i could do with knowing what possible values are returned…

The range is a float between 0.0 to 1.0

1 Like