#How to get an "underwater" effect on Texture2D?

1 messages · Page 1 of 1 (latest)

fallow hazel
#

I'm trying to make things underwater have a wave motion applied to the sprite, so it seems like the the movement of water is distorting them. See the images for a dirty example of the result I want. However, I can't get it to work.

I tried applying a Sine wave to the X-axis of a Vector2 and using that as the Offset for the Texture2D, but it makes the entire texture move instead of only part of it. I've no idea how to move part of the texture and not the entire thing, Does anyone know with which Nodes I can achieve an effect like this?

I looked into 3d waves as well, but they all manipulate the vertexes, which I don't think I should be doing. I tried it regardless, but to no avail.

wary totem
#

That's because the output of sine time is constant over the whole object.
But if you take the time output, add UV.x (for example) and then use the sine node on this value, the deformation will vary on the X axis.
In math language its :
UVOffset.x = sin(Time.time + UV.x)

fallow hazel
#

I see, hadn't thought of that! I'll read up a bit on Time.sine vs Sine and then try it out, didn't know they were different

fossil sun
fallow hazel
wary totem
# fallow hazel I have to say I don't really understand the theory, but it seems to work! Still ...

Theory :
sin(Time.time) will return a value going back and forth between -1 and 1 for all pixels that are rendered.
But if you add UV.x to the sine input, you are adding variation per pixel, as each pixel UV.x is different (or at least, horiontally over the sprite).
So sin(Time.time + UV.x) still varies between -1 an 1, but the result is "offset" for each pixel on the horizontal axis.
If you wanted to have a wavy pattern on the sprite, you'd plug this to the Y offset value, so it would look like it's deforming vertically.

You can then alter the frequency of the waves, their speed and amplitude by multiplying some value :
Offset.y = sin( Time.time * speed + UV.x * frequency ) * amplitude