Best way to get a wavy object without moving it's bottom point?

Hi there! I’m pretty new to shaders but I was working on making some grass using shader graph following this tutorial:

I basically got everything working the same and it’s all good but I wanted to expand this grass shader to be a more general foliage shader and now I’m running into problems.

Here is what I’m getting:

7498063--923597--Grass Example.gif

All of these are using the shader I made following the tutorial above.

The grass on the left is using a material with a a single sprite in the spritesheet.

The bush in the middle and the grass on the right are using the same material as each other that has a sprite sheet with multiple sprites on it.

The bush sprite is at the bottom of the sheet, and the grass sprite is at the top of the sheet.

So the issue is that the grass on the right has it’s bottom swaying and I don’t want that. The bush doesn’t sway at the bottom but it also has a very subtle effect which I also don’t want.

I think this has to do with this part of the shader graph:

Where I’m using the position and the UV to (according to the tutorial) “root” the bottom of the sprite and only sway the top.

This works well if the sprite is in it’s own texture, but if I want to use a sprite sheet with many sprites it doesn’t seem to give the same result.

Is there any solution for this other than making each sprite have it’s own texture/material?

I was just working on this problem recently to make hanging flags wriggle a little in the wind, so a similar problem, but the top would be stationary instead. I didn’t watch the video you linked, but essentially, whatever function/node you’re using to create a wavy effect, you’ll want to multiply that against the position (object) node. And if you have the objects origin at the very bottom, it’ll be zero. So down at the bottom where position is zero, you’ll get no movement and you’ll get linearly more movement as you go up.

Or in my case, I didn’t want a linear drop-off, so I used a gradient and gradient sampler to have no movement on the top 1/4 of the flag.

That makes sense and it’s more or less what I’m doing with the grass on the left which uses a material with a a single sprite in the spritesheet. But have you figured out any way to have multiple textures on a single spritesheet and still get this effect?

My current solution is to have a spritesheet that is exactly the height of the object I want swaying and putting as many textures as I can horizontally on it.

I might be missing something but the sprite sheet is determined by the UV map on your plane geometry, not by the vertex positions that you’re moving in the shader. I watched the video and in Brackey’s tutorial he’s manipulating vertex positions, so switching out the texture with a sprite sheet and changing tiling and offset shouldn’t affect the wobbling.

Could something else have gone wrong in your shader during the time you changed the texture?

Hmm I’ll have to look more into it but I don’t see the issue, only the weird behavior of the sway that seems to depend on where the texture was positioned on the sprite sheet.

Not really sure what’s going but I think it must be related to the image texture/sprite sheet I’m using. In the video and in my first attempt (grass on the left) he and I use a texture/sprite that is alone on the sheet and the sheet’s size is the size of the texture.

It works fine like that, but again, using the sprite sheet I have which ahs a bunch of sprites/tiles the stuff at the top of the sheet swings wildly, and the stuff at the bottom barely moves. It has to be something with the UVs of the obj file I suspect.

I suspect the solution would be something like getting the top and bottom of the UV of the texture regardless of where it is on the image texture/sprite sheet, but I’m not sure how to do that or if it can even be done.