#Wind Effect Shader for Sprite Atlas - UV problems

1 messages · Page 1 of 1 (latest)

red horizon
#

I was following the tutorial in https://www.youtube.com/watch?v=VcUiksxYT88 to create foliage shader and it's almost working. I'm just stuck at the "Masking" part where the bottom y area of the texture would remain static but the higher it goes, the more the wind effect shader would be applied. I have a sprite atlas and it seems to be not working well but if I use it on a non-atlas sprite it works fine.

✅ Get the Project files and Utilities at https://unitycodemonkey.com/video.php?v=VcUiksxYT88
Let's learn how to make a simple Wind Shader effect in Unity! 👇
🌍 Get the Complete Builder-Defender Course! ✅ https://unitycodemonkey.com/coursebuilderdefender.php
👍 Learn to make an awesome game step-by-step from start to finish.

Make Awe...

▶ Play video
teal orbit
#

As the current shader is using UV.Y to mask the wind effect, it assumes that your sprite takes the full UV of the texture (so, non atlased textures).
But sprites in atlases are using only a portion of the UVs to display, and this need to be taken into account when masking.
You can get this information in c# using Sprite.textureRect and pass it to the shader to remap the UV and have the proper Y gradient.

Or maybe you can use the bounds information from the Object node to remap the vertices coordinates and also get the gradient.

red horizon
#

ok. thanks. i'll give it a try

pallid epoch