Today I was making a shader to make an element swaying in the wind using Shader Graph (12.1).
The shader I want to create is a shader that rotates and moves vertices around a specific position.
The goal is to represent plants moving by the wind.
After completing the Shader Graph, I placed several to test the overall visual, and a problem happend.
It was as if the Position node’s vertex input was being processed at the origin of the world.
Even weirder, when I switched to the Shaded Wireframe view to check the state of the vertices, I found that the graphics and meshes were displayed separately.
So I did some more research and found few points of this issue.
If this is a situation where batching is possible at once, a problem happened.
There was no issues when I connected the Position node directly to the vertex output.
Below is the Shader Graph where the problem occurs.
The object position node is making use of the per mesh local to world transform matrix used for rendering. Batched meshes are combined into a single mesh pretransformed into world space, and that matrix is an identity matrix (it has no rotation or transform and a uniform scale of 1). Sprites are batched by default unless you use a shader that supports sprite instancing, and AFAIK Shader Graph shaders don’t support Sprite instancing!
Unable to benefit from optimization of sprite atlas ( I found a relate forum post’s reply by @bgolus )
But I’ve decided to accept it as it is, but if you have any information that for me or anyone visiting with the same problem should know or take note of, please leave a post here.
I’m encountering the same problem here. I’m trying to color sprites using their scale and position but it doesn’t work if I use GPU instancing. But if I use GPU instancing I then can’t use the vertex color (but for some reason I can still use the alpha of the vertex color, I’m confused)
Has anyone figured out a solution to get the best of both worlds?