Unity, particle system with velocity alignment + vertex offset

Hi everyone.
Has anyone tried to create school of fish? It’s simple task in Unity: standard particle system + mesh + velocity.
wings_line_8
And probably a lot of us used vertex offset by shader. The simplest node-tree is:


I have tried different parameters, different nodes combinations to create school of fish with vertex offset, but each time I had the same, or worse then earlier results…
wings_line_7

Shader works correctly on static mesh, but particle system change vertexes positions by the same axes (in example it is X). I found that particle pivots have the same XYZ orientation.

So technically shader works correct, it changed vertex position by particle pivot, which is not the same object pivot.
I tried to found school of fish in PC games… but each game showed me the same: floated log.

Is it possible to realize school of fish, each fish changes the direction by velocity, and vertex position changes by object pivot orientation?

2 Likes

Maybe there are easier ways but I would expect using the custom vertex stream velocity could help you. There’s a thread about this!

Since particles that use velocity alignment don’t orient itself using 3d rotations, you can instead use the velocity vector as your relative fish orientation pivot if that makes sense? :fish:
There is most likely a little bit sorcery involved in creating this type shader so please share your progress :slight_smile: I am curious!

thx for the link, but I have already read and rebuilt the shader… result the same (((

The workflow in the link would have to be adapted and applied to you shader’s vertex offsets differently than discussed in the thread. The exact implementation I can’t tell you without trying to figure it out by myself

Basically your vertex transform is in world space. So without a rotational offset, the animation won’t work. Typically the best approach for this is to back a vertex animation in local space for the mesh, and then play that animation in the shader as most of the nodes necessary usually start from the assumption that you are in local space.
I’ve never had much luck with procedural animation for the swimming of the fish, but flocking is great.
Another thing you’ll want to do is to build in an averaging system between frames so that they have a maximum angular velocity. This should help with the flip-popping.
Without looking at your graph I can only say this, “I hope you’re working in quaternions” because gimbal lock is gonna kick your ass every time.

1 Like

New result
wings_line_9

3 Likes

Ah cool, looks like you solved the vertex animation issue, still using the sine curve?
In the solution I am using at the current project, there is a RotateAboutAxis node, also found in Unreal. Quite handy fella:

3 Likes

Sorry for my long answer, but I have some problems with new Unity 2018.3 and ShaderForge. So I will show the node tree as soon as I made it on Amplify or ShaderGraph

Cool, Can you share your settings?? I got same issue

Hi, i’m also currently trying to do a very similar thing with butterflies flapping. Any help or node sharing would be greatly appreciated