Hi
I'm working on a small shader effect for a tiled sprite where I wobble the v coordinate to simulate rippling water.
I just added this to wobble the v-coordinate:
i.texcoord.y += sin(i.worldpos.y + _Time.z) * 0.009f;
(worldpos is the world position of the pixel we're rendering)
the problem is that when I push the v coordinate beyond the edge of the sprite in the sprite collection it reads whatever happens to be next to it.
the desired behaviour here would be to tile the v coordinate so if it goes off the top edge of the sprite in the sprite collection it'll warp back to the bottom instead of reading outside the sprite.
note that this is a tiled sprite with a sprite animator.
I've attached a wobblyWater.GIF where you can see what it actually looks like. at the bottom the v coordinate goes outside the sprite in the sprite collection so I get empty space and some garbage. if the v coordinate would loop back at the top it'd look perfect.
noWobble.GIF is the same thing without wobbling.
what would be the best way to tile the v coordinate so it always stays within the currently visible frame of the sprite?
my suspicion is, if I get the current frame's bounds within the spritesheet I can probably do the tiling in the shader.
but I don't know how to get the current frame's bounds.
thanks!