Unity - Custom Vertex Stream and Shadergraph/Amplify Shader

Hey everyone !

Since few weeks, I saw many questions about ’ Custom Vertex Stream ’ (called CVS here) on Shuriken with Shadergraph/Amplify Shader

First, here a really good post about CVS by Mirza Beig where a lot of things are explains : Intro to Custom Particle Vertex Streams – Mirza’s Realm

I will only tacle how to link CVS and Shadergraph/Amplify Shader!

Here the shader we will use for Shadergraph:

And here the shader we will use for Amplify Shader:

1: UV channel selector, the first important part in the shader
2: RGBA split component, the second important part!
The only difference between the two shadernode editors is the uv channel:
Shadergraph starts at 0
Amplify starts at 1

Let’s go to Shuriken now ! We add a new material with the shader we created in Shuriken renderer.
The setup is the simpliest as possible, only one particle and only the one ’ Custom Data ’ in CVS (we can’t delete the Position!)
Shuriken
1: Enable CVS and add a Custom1.xyzw data
Shuriken_1

2: Enable ’ Custom Data ’ module, set the Custom1 to Vector and 4 component

Custom1 is setup like that:
X : Start at 1 and decrease to 0 at midlife
Y : Start at 0 and at midlife go to 1
Z : Const 0
W : Const 0

And here the result you should have:
Result_1

Let’s describe a bit what happens!

CVS and Custom Data :

  • It’s simple, the Custom1 in CVS is the Custom1 in Custom data. You can animate here the XYZW component with const, curve or color.

CVS and Shadergraph/Amplify :

  • Near Custom1 in CVS, we can see Unity give us a tip on how to link that in Shadergraph/Amplify with (TEXCOORD0.xyzw). TEXCOORD is our UV channel and the 0 say it’s our first UV channel.
    We can resume with this array
    Array

But what if we have more data to send ? Our best friend become the number near TEXCOORD
Here a case :

In resume we have:

  • TEXCOORDX = UV channel X for Shadergraph and UV channel X+1 for Amplify.
  • XYZW = RGBA for Shadergraph and UVWT for Amplify
    One particular thing we see with StableRandom.xyzw is the TEXCOORD2.yzw**|**x
    Unity wants to say us ’ StableRandom.xyzw starts in TEXCOORD2.yzw and finishes in the next one,TEXCOORD3.x

And here we go! We can now make crazy SHEBAM ! POW ! BLOP ! WIIIZZ !
I hope this can help, forgive me my language mistakes, don’t hesitate to correct me to make this a bit clearer or add/remove/correct any informations! :grin:

49 Likes

My example
image
image

4 Likes

Using this feature you can make texture panning from curve x if you have UV output Z(W in amplify). It will be one curve for your Z value and panning. I don’t know where you can use it, but anyway…
image
or you can make random texture coordinates using StableRandom
image
Tangent need when you use normal map in the shader.
Put like on this comment if you found out about it for the first time :smile:

9 Likes

And here I thought vertex stream wasn’t working on shaderGraph. Thanks a lot !

I was wondering what kind of effect this could achieve, any ideas ?

1 Like

I would like to answer : whatever you want to animate in your shader :smiley:

Before that i personnaly used a lot ’ color over lifetime ’ to animate things, but i lost the real utility of this module. Now, you can pan a texture in a specific way, animate vertex, animate dissolve, knowing the lifetime of a particule etc. without to use tricks to get values in the shader!

They are some examples in Mirza Beig article too!

I’d like to manipulate color through this system (because the default color over time doesn’t allow HDR colors, which is “meh”). Do you know I can achieve this ?

One simple way is setting your colors as HDR in shadergraph
image

and use AgePercent to Lerp between the color
image

The only counterpart is if you want 4 different colors over the particule life, you will have to declare 4 colors :

Here the result :
test

In few words, each smoothstep provide a [0-1] value to lerp between the different colors.
The smoothstep range is define by [1 / 3 (numberOfSmoothstep)]

  • for the first one you have [0 => 0.33]
  • the seconde one : [0.33 => 0.33 * 2]
  • the last one : [0.33 * 2 => 0.33 * 3]

I hope it’s what you’re looking for in a way!
And here the shader for example (you can see the setup for shuriken in the gif). Sorry, i don’t know how to add commentary in shadergraph… and it’s look like it’s impossible for the moment!
https://drive.google.com/file/d/19oafzIyZIg3qzvszjFwKc0z7ZHYOiPUZ/view?usp=sharing

If someone have a simplier solution to have HDR color over lifetime, you must speak! now! :smiley:

1 Like

Hey, thanks for the answer !

I’ve been trying to mess around with CVS but I can’t manage to have any result outside of your exemple. I can’t seem to link the base (Uv/Split/Combine) with any texture or noise I could make.

To be precise: CVS only works when I remove the UV (TEXCOOR0.xy).Thus making it impossible to blend with anything else I could want to work with.

Is there something I missed ? I’m kinda clueless when it’s about CVS but it feels like this is something very important to have a grasp on.

Yep i think it’s a great add to shuriken. Now, you don’t have to c# script to get some values in your shader !
Can you show your shader (with uv channel for each uv) and your vertex stream please ? It’s a bit hard to say like that :thinking:

1 Like

Ok, so here is what I have:

Pretty basic, i just want to influence the alpha.

Now I want to join a noise with it, a multiply should be enough:

Here is the result:

BOwDvsa5tm

And here is the setting for the particle system

image

It completely ignores any values put on the custom data. But if I remove UV (TXCOORD0.xy)

nLpGMfOYRQ

Well, it works ! Buuuut now it loses its ability to read the texture.

If it isn’t clear enough please tell me ! And thank you for dedicating time for newbies like me <3

2 Likes

Haha no problem, we all scratched our head many times !
So, in your setup, your sending UV in TEXCOORD0.xy so your uv for noise will be uv channel 0.xy in shadergraph. Your custom data is send threw TEXCOORD0.zw|xy which means TEXCOORD0.zw and in TEXCOORD1.xy. So it will be uv channel 0.zw and uv channel 1.xy in shadergraph for your.
For your first pictures you can plug directly the split.r in your alpha output. Alpha is a float so it takes only thé first value of your vector.
I hope it helps, let me know !

Daaaayum, it worked !

I think I kindaaaaaa get how it function, although it will take time before I get to understand the full extents of it. if I ever need to deep diver, you might hear me again on this topic. Thank you very much ! :stuck_out_tongue:

1 Like

don’t know if this is necessary anymore but does this help?
split Blue out of vec4 passed as X (red) that is the custom1.x

also you could assign Alpha as Y (green) and use (custom1.xy) for your two particle graphs

Hi,

I have the same problem than [Asminae]

I’m only trying to make a dissolve from the texture i have in the graph. But animated in the Custom Data.
Like the Dynamic Parametre in Unreal.



Can someone help me because i’m new to Unity Hdrp and Custom data.

Thank you in advance.

0

Click this button and add Custom1.xyzw and Custom2.xyzw.

This way, you’ll be able to transfer data from the “Custom Data” node on your particle system to the shader!

1 Like

Hey Lush,

Much appreciated for your quick respond but I’ve put the Custom1.xyzw and Custom2.xyzw. and it’s not working.

image

As you can see there, TEX0.xy are being used to define the UVs, and TEX0.zw are the first two available channels for you to use!

Try using the other component slots. Copy and paste those curves from the X and Y components to the Z and W components on the Custom Data node.

By the way, I’d suggest you to create a shader with a color lerp from 0 to 1 controlled by one channel of the Vertex TexCoord node, and then switch through them until you find the right one if that doesn’t do the trick. Easy debuging tip!

2 Likes

Hi there!
I’m playing with vertex streams too, because i would like something very specific :

I’m in HDRP with Shader Graph.
I would like to create /use/ the HDR Color Gradient the same way the “color over time” works.
Can i pass the data of custom color HDR gradient to the shader?

Ok, i finally found the right settings!


image

Here is the first use of this ^^ nothing fancy, but i’m happy lol

Smoke_HDR_Gradient