Unity Custom Stream and Shaderforge

I guess it is my lack of basic understanding of shaders, but does anyone know a way to get the info out of the Particle Custom Stream into the Shaderforge Shader by using the Code snippet/ function module?

I saw @Keith posting a vertex struct snippet over in the Unity 5.5 Beta post, I guess that is too low level to get into a function in Shaderforge…

Also there is a request already in the Support Forums… So my hopes are not too high that there is a workaround out there…

I’m not too familiar with ShaderForge, but i thought I’d seen that you could use additional UVs in the node graph. If I’ve got that right, you ought to be able to match these up with the TEXCOORDx labels in the Particle System Renderer custom stream UI.

2 Likes

ah cool thanks, found it. this one helped in particular. Now I can feed velocity into shader forge… just have to find out what zw|x means… zw stands for x and z velocity, no idea how to get the y velocity though :confused:

edit: I guess the y velocity is somehow incorporated into the x and z direction, that might be what that zw |x is hinting at. because in shaderforge I only get to access uvzw when using velocity in the stream. U and V behave static as they always do and are just plain UVs, zw are modulated by velocity and hopefully somehow incorporate the y direction…

edit2: a kk, zw seem to describe two angles, that could be why a third component is missing. I don’t get it :smiley:

aaaahhh, it seems they are kind of physical velocity vectors, again only two of them… but cool.

Because the streams are packed together, they may span 2 texcoord channels, to avoid leaving gaps.

Let’s say you have:
UV (Texcoord0.xy)
Velocity (Texcoord0.zw|x)

It’s saying that the first uv stream has 4 components. The xy holds the uv, and the zw holds the first 2 components of the Velocity.

However, we need 3 components for the velocity, so the 3rd component has spilled into the first part of the 2nd uv channel.

This might be a bit awkward for a shader forge node graph… might make it look a bit over complicated, but your Velocity will be made up from:

Velocity = float3(firstuv.zw, seconduv.x);

To make things simpler in shaderforge, perhaps set up your particle system streams like this instead:

UV (Texcoord0.xy)
UV2 (Texcoord0.zw)
Velocity (Texcoord1.xyz)

It’s a bit wasteful to have a stream present that isn’t used (UV2), but it will make your velocity stream fit nicely into the second TEXCOORD channel without any complications :slight_smile:

4 Likes

AhhhhH! awesome. Cheers mate!

1 Like