Unity 5.5 / 5.6 Align Mesh Particles with Velocity using Vertex Stream

Here is a shader based solution to get particle meshes orienting with velocity:

Particle Component:

Shader based on ShaderForge Custom Lit:

meshes are pointing in Y direction. options for Particle Rotation might work different than expected. Simulation has to be in world space.

15 Likes

it’s great to have it now in 5.5 and 5.6 just FYI to others,… beta allows render_alignment = velocity

(for those hoping; it will be coming afaik)

2 Likes

yeah, the changes for 2017 look promising

1 Like

Wow! that’s really helpful and awesome, great job!

1 Like

Thank you!
But i can’t get that UV Coord. node :frowning:
What version of SF are you using? :blush:

you are welcome!

the version is 1.36

you sure you tried and ticked all tose boxes on your UV Coord node?

you can switch from default UV to UVZW just on the node itself, if that helps

1 Like

Hey! Good day :slight_smile:
I don’t know how to change that settings, this is all i have… :frowning:

oh okay, I get the other one straight out of the box, maybe updating shaderforge to a newer version helps… didn’t have a look at the changelogs though

Just had a browse:

New in Shader Forge 1.34: (Unity 5.5 or later required)
• You can now read UV coordinates as 4-component vectors

…That update should do it!

2 Likes

Ohh i see! Thank you very much! :smiley:

Hey there.

The provided gif from you looks promising. But for some kind of reason i cant get it to work on shaderlab. I redid the entire shader as provided above.

As u can see the red arrow shows a difference to the above provided picture. it turns black for some reason. And i think this messes something up.

Can someone help me figure this out.

I can’t update Unity, cause i am bound to the version v5.6.3p1 (VRChat) and i want to make an animation where the mesh particle align to velocity.

I would appreciate a response.

With best regards

Mizuke

Hi Mizuke,

Didn’t get this behaviour at any point, also not able to reproduce in 5.6.0p3 (version I got installed).
Just to make sure, which version of Shader Forge are you on?

…I found this bug online, not the exact same preview issue, but in the same ballpark. Eventually a problem with the version of Unity you have there…

The only other idea I have right now might be with the whole network set up, but the effect not working, that your renderer is missing the vertex streams velocity and center…given those black previews are a “cosmetic” issue…

Thanks for the fast response. I tried again and it seems like it still works. My fail was, that i didnt simulate the particle into world space.

But i still have one minor issue. If the velocity of the object is 0 the vertex offset is going to shoot it into nothingness. Basicly its invisible for the eye, cause its gone somewhere far of. if the object has an velocity of 0.00001 or something into a direction than the object is visible again, but it seems on 0 its gone. Do you know how i could fix that?

bug
EDIT: u have to expand the picture to fully see it :frowning:
Here u can see that the Particel is still there cause the colliderbox is still visualized. But it disappears.

EDIT 2: Setting the startSpeed to 0 will let the particle be not visible. even if u apply gravity to them :frowning:

I can only attach one image in one post :frowning:

And here is the shaderlab. I changed it only on the color part. but the vertex offset is the same

Ah mate, sorry for not getting back to you!

I guess the 0 velocity issue stems from the use of the vertex stream VELOCITY, so sth strange is happening once that is at 0.

Not sure if it is still of use to you, but I’ll have a look later today!

Did have a look now and can’t come up with a good solution atm.

If you were able to store the current velocity of each particle in a custom stream as long as it doesn’t equal zero and then refer back to that stream as soon as a velocity is 0, that would be nice :smiley:

For now I’d stick to workarounds, for that sticking arrow for example you might get away with spawning another arrow on collision, inheriting just a tiny fraction of the velocity of the former arrow, which is now at zero and killed?