How to animate abstract 2d top down water texture?

The name of the pictureThe name of the pictureThe name of the pictureClash Royale CLAN TAG#URR8PPP





.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty margin-bottom:0;







up vote
2
down vote

favorite












I currently implement a game with a top down view of the ocean. I use the following, a little abstract texture: enter image description here



The actual texture is transparent, I added the green-like color for clarity.



The problem I now have is, that I don't know how to animate this texture so the water looks nice. I tried to move the texture with a sin wave: texture.y += sin(angle). Of course now the whole texture is moving which looks kind of unrealistic. The next thing I tried is to add another layer and implement a parallax effect. So that reflections under the water surface would also move, but much slower. It looks a little better but still not... nice enough.



I think the best looking animation would be, if the individual cells would expand and contract, kind of like a web or piece of cloth. Imagine if someone would slightly pull at one vertex of these cells and the neighbored cell would expand and the cell I pull towards to (or push to) would contract. Kind of like a web of springs(?). But I have no clue how to implement something like this:



  • Whats the math-model for this? Something with springs, where forces push/ pull?

  • And if so, how do I map this model to the given texture? Keeping all the curves and what not...

(I'm also open to different ideas/answers on how to animate the given texture.
Realism is not the point here, just some nice looking water like movements...)










share|improve this question



























    up vote
    2
    down vote

    favorite












    I currently implement a game with a top down view of the ocean. I use the following, a little abstract texture: enter image description here



    The actual texture is transparent, I added the green-like color for clarity.



    The problem I now have is, that I don't know how to animate this texture so the water looks nice. I tried to move the texture with a sin wave: texture.y += sin(angle). Of course now the whole texture is moving which looks kind of unrealistic. The next thing I tried is to add another layer and implement a parallax effect. So that reflections under the water surface would also move, but much slower. It looks a little better but still not... nice enough.



    I think the best looking animation would be, if the individual cells would expand and contract, kind of like a web or piece of cloth. Imagine if someone would slightly pull at one vertex of these cells and the neighbored cell would expand and the cell I pull towards to (or push to) would contract. Kind of like a web of springs(?). But I have no clue how to implement something like this:



    • Whats the math-model for this? Something with springs, where forces push/ pull?

    • And if so, how do I map this model to the given texture? Keeping all the curves and what not...

    (I'm also open to different ideas/answers on how to animate the given texture.
    Realism is not the point here, just some nice looking water like movements...)










    share|improve this question























      up vote
      2
      down vote

      favorite









      up vote
      2
      down vote

      favorite











      I currently implement a game with a top down view of the ocean. I use the following, a little abstract texture: enter image description here



      The actual texture is transparent, I added the green-like color for clarity.



      The problem I now have is, that I don't know how to animate this texture so the water looks nice. I tried to move the texture with a sin wave: texture.y += sin(angle). Of course now the whole texture is moving which looks kind of unrealistic. The next thing I tried is to add another layer and implement a parallax effect. So that reflections under the water surface would also move, but much slower. It looks a little better but still not... nice enough.



      I think the best looking animation would be, if the individual cells would expand and contract, kind of like a web or piece of cloth. Imagine if someone would slightly pull at one vertex of these cells and the neighbored cell would expand and the cell I pull towards to (or push to) would contract. Kind of like a web of springs(?). But I have no clue how to implement something like this:



      • Whats the math-model for this? Something with springs, where forces push/ pull?

      • And if so, how do I map this model to the given texture? Keeping all the curves and what not...

      (I'm also open to different ideas/answers on how to animate the given texture.
      Realism is not the point here, just some nice looking water like movements...)










      share|improve this question













      I currently implement a game with a top down view of the ocean. I use the following, a little abstract texture: enter image description here



      The actual texture is transparent, I added the green-like color for clarity.



      The problem I now have is, that I don't know how to animate this texture so the water looks nice. I tried to move the texture with a sin wave: texture.y += sin(angle). Of course now the whole texture is moving which looks kind of unrealistic. The next thing I tried is to add another layer and implement a parallax effect. So that reflections under the water surface would also move, but much slower. It looks a little better but still not... nice enough.



      I think the best looking animation would be, if the individual cells would expand and contract, kind of like a web or piece of cloth. Imagine if someone would slightly pull at one vertex of these cells and the neighbored cell would expand and the cell I pull towards to (or push to) would contract. Kind of like a web of springs(?). But I have no clue how to implement something like this:



      • Whats the math-model for this? Something with springs, where forces push/ pull?

      • And if so, how do I map this model to the given texture? Keeping all the curves and what not...

      (I'm also open to different ideas/answers on how to animate the given texture.
      Realism is not the point here, just some nice looking water like movements...)







      2d libgdx animation water






      share|improve this question













      share|improve this question











      share|improve this question




      share|improve this question










      asked 2 hours ago









      morpheus05

      1113




      1113




















          2 Answers
          2






          active

          oldest

          votes

















          up vote
          2
          down vote













          This is called a caustic effect, and generating these effects at runtime is fairly time consuming, so this is traditionally done with pre-rendered frame-by-frame animation. There are tools that will generate caustic animation frames for you, such as Caustics Generator, which has a free version for non-commercial use. There are also some pre-made ones that you can buy for significantly cheaper than the pro version of the tool I mentioned.



          Note that caustic effects are also usually an effect applied as a light cookie on an underwater terrain, or on the underwater surface. That is, putting it on the surface of the water while looking down into it is not normally what water looks like.






          share|improve this answer





























            up vote
            2
            down vote













            A common way this is done is using an indirect texture lookup in the shader to distort the display texture:



            Animated gif showing water animation



            Here I'm using a texture with some low-frequency colour noise (tiling smooth blobs of random colours), and scrolling it across the display geometry over time.



            enter image description here



            Instead of drawing the colours from this texture, I instead take the red & green channels and subtract 0.5f to turn them into a pseudorandom 2D vector that changes smoothly over time & space.



            I can then add a small multiple of this vector to my UV coordinates, before sampling from the main water texture. This shifts the part of the texture we're reading & displaying, warping it around.



            By averaging two samples from this noise, scrolling in opposite directions, we can hide the direction of movement so it just looks like aimless sloshing.



            In Unity the shader would look like this - it should be simple enough to translate to the shader language of your choice:



            fixed4 frag (v2f i) : SV_Target

            float2 waveUV = i.uv * _NoiseScale;
            float2 travel = _NoiseScrollVelocity * _Time.x;

            float2 uv = i.uv;
            uv += _Distortion * (tex2D(_Noise, waveUV + travel).rg - 0.5f);
            waveUV += 0.2f; // Force an offset between the two samples.
            uv += _Distortion * (tex2D(_Noise, waveUV - travel).rg - 0.5f);

            // Sample the main texture from the distorted UV coordinates.
            fixed4 col = tex2D(_MainTex, uv);

            return col;






            share|improve this answer




















            • This looks really nice. I'm not sure I understand all the attributes: _NoseScale = scalar for scaling the "noise map". _NoiseScrollVelocity = Vector2 at which speed we move across the noise map. _Noise = ?. _Distortion = Scalar I choose as a distortion factor? v2f = Vertex we determine the color. i = ?
              – morpheus05
              9 secs ago










            Your Answer




            StackExchange.ifUsing("editor", function ()
            return StackExchange.using("mathjaxEditing", function ()
            StackExchange.MarkdownEditor.creationCallbacks.add(function (editor, postfix)
            StackExchange.mathjaxEditing.prepareWmdForMathJax(editor, postfix, [["\$", "\$"]]);
            );
            );
            , "mathjax-editing");

            StackExchange.ifUsing("editor", function ()
            StackExchange.using("externalEditor", function ()
            StackExchange.using("snippets", function ()
            StackExchange.snippets.init();
            );
            );
            , "code-snippets");

            StackExchange.ready(function()
            var channelOptions =
            tags: "".split(" "),
            id: "53"
            ;
            initTagRenderer("".split(" "), "".split(" "), channelOptions);

            StackExchange.using("externalEditor", function()
            // Have to fire editor after snippets, if snippets enabled
            if (StackExchange.settings.snippets.snippetsEnabled)
            StackExchange.using("snippets", function()
            createEditor();
            );

            else
            createEditor();

            );

            function createEditor()
            StackExchange.prepareEditor(
            heartbeatType: 'answer',
            convertImagesToLinks: false,
            noModals: false,
            showLowRepImageUploadWarning: true,
            reputationToPostImages: null,
            bindNavPrevention: true,
            postfix: "",
            onDemand: true,
            discardSelector: ".discard-answer"
            ,immediatelyShowMarkdownHelp:true
            );



            );













             

            draft saved


            draft discarded


















            StackExchange.ready(
            function ()
            StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fgamedev.stackexchange.com%2fquestions%2f163689%2fhow-to-animate-abstract-2d-top-down-water-texture%23new-answer', 'question_page');

            );

            Post as a guest






























            2 Answers
            2






            active

            oldest

            votes








            2 Answers
            2






            active

            oldest

            votes









            active

            oldest

            votes






            active

            oldest

            votes








            up vote
            2
            down vote













            This is called a caustic effect, and generating these effects at runtime is fairly time consuming, so this is traditionally done with pre-rendered frame-by-frame animation. There are tools that will generate caustic animation frames for you, such as Caustics Generator, which has a free version for non-commercial use. There are also some pre-made ones that you can buy for significantly cheaper than the pro version of the tool I mentioned.



            Note that caustic effects are also usually an effect applied as a light cookie on an underwater terrain, or on the underwater surface. That is, putting it on the surface of the water while looking down into it is not normally what water looks like.






            share|improve this answer


























              up vote
              2
              down vote













              This is called a caustic effect, and generating these effects at runtime is fairly time consuming, so this is traditionally done with pre-rendered frame-by-frame animation. There are tools that will generate caustic animation frames for you, such as Caustics Generator, which has a free version for non-commercial use. There are also some pre-made ones that you can buy for significantly cheaper than the pro version of the tool I mentioned.



              Note that caustic effects are also usually an effect applied as a light cookie on an underwater terrain, or on the underwater surface. That is, putting it on the surface of the water while looking down into it is not normally what water looks like.






              share|improve this answer
























                up vote
                2
                down vote










                up vote
                2
                down vote









                This is called a caustic effect, and generating these effects at runtime is fairly time consuming, so this is traditionally done with pre-rendered frame-by-frame animation. There are tools that will generate caustic animation frames for you, such as Caustics Generator, which has a free version for non-commercial use. There are also some pre-made ones that you can buy for significantly cheaper than the pro version of the tool I mentioned.



                Note that caustic effects are also usually an effect applied as a light cookie on an underwater terrain, or on the underwater surface. That is, putting it on the surface of the water while looking down into it is not normally what water looks like.






                share|improve this answer














                This is called a caustic effect, and generating these effects at runtime is fairly time consuming, so this is traditionally done with pre-rendered frame-by-frame animation. There are tools that will generate caustic animation frames for you, such as Caustics Generator, which has a free version for non-commercial use. There are also some pre-made ones that you can buy for significantly cheaper than the pro version of the tool I mentioned.



                Note that caustic effects are also usually an effect applied as a light cookie on an underwater terrain, or on the underwater surface. That is, putting it on the surface of the water while looking down into it is not normally what water looks like.







                share|improve this answer














                share|improve this answer



                share|improve this answer








                edited 18 mins ago

























                answered 25 mins ago









                Ed Marty

                2,6301411




                2,6301411






















                    up vote
                    2
                    down vote













                    A common way this is done is using an indirect texture lookup in the shader to distort the display texture:



                    Animated gif showing water animation



                    Here I'm using a texture with some low-frequency colour noise (tiling smooth blobs of random colours), and scrolling it across the display geometry over time.



                    enter image description here



                    Instead of drawing the colours from this texture, I instead take the red & green channels and subtract 0.5f to turn them into a pseudorandom 2D vector that changes smoothly over time & space.



                    I can then add a small multiple of this vector to my UV coordinates, before sampling from the main water texture. This shifts the part of the texture we're reading & displaying, warping it around.



                    By averaging two samples from this noise, scrolling in opposite directions, we can hide the direction of movement so it just looks like aimless sloshing.



                    In Unity the shader would look like this - it should be simple enough to translate to the shader language of your choice:



                    fixed4 frag (v2f i) : SV_Target

                    float2 waveUV = i.uv * _NoiseScale;
                    float2 travel = _NoiseScrollVelocity * _Time.x;

                    float2 uv = i.uv;
                    uv += _Distortion * (tex2D(_Noise, waveUV + travel).rg - 0.5f);
                    waveUV += 0.2f; // Force an offset between the two samples.
                    uv += _Distortion * (tex2D(_Noise, waveUV - travel).rg - 0.5f);

                    // Sample the main texture from the distorted UV coordinates.
                    fixed4 col = tex2D(_MainTex, uv);

                    return col;






                    share|improve this answer




















                    • This looks really nice. I'm not sure I understand all the attributes: _NoseScale = scalar for scaling the "noise map". _NoiseScrollVelocity = Vector2 at which speed we move across the noise map. _Noise = ?. _Distortion = Scalar I choose as a distortion factor? v2f = Vertex we determine the color. i = ?
                      – morpheus05
                      9 secs ago














                    up vote
                    2
                    down vote













                    A common way this is done is using an indirect texture lookup in the shader to distort the display texture:



                    Animated gif showing water animation



                    Here I'm using a texture with some low-frequency colour noise (tiling smooth blobs of random colours), and scrolling it across the display geometry over time.



                    enter image description here



                    Instead of drawing the colours from this texture, I instead take the red & green channels and subtract 0.5f to turn them into a pseudorandom 2D vector that changes smoothly over time & space.



                    I can then add a small multiple of this vector to my UV coordinates, before sampling from the main water texture. This shifts the part of the texture we're reading & displaying, warping it around.



                    By averaging two samples from this noise, scrolling in opposite directions, we can hide the direction of movement so it just looks like aimless sloshing.



                    In Unity the shader would look like this - it should be simple enough to translate to the shader language of your choice:



                    fixed4 frag (v2f i) : SV_Target

                    float2 waveUV = i.uv * _NoiseScale;
                    float2 travel = _NoiseScrollVelocity * _Time.x;

                    float2 uv = i.uv;
                    uv += _Distortion * (tex2D(_Noise, waveUV + travel).rg - 0.5f);
                    waveUV += 0.2f; // Force an offset between the two samples.
                    uv += _Distortion * (tex2D(_Noise, waveUV - travel).rg - 0.5f);

                    // Sample the main texture from the distorted UV coordinates.
                    fixed4 col = tex2D(_MainTex, uv);

                    return col;






                    share|improve this answer




















                    • This looks really nice. I'm not sure I understand all the attributes: _NoseScale = scalar for scaling the "noise map". _NoiseScrollVelocity = Vector2 at which speed we move across the noise map. _Noise = ?. _Distortion = Scalar I choose as a distortion factor? v2f = Vertex we determine the color. i = ?
                      – morpheus05
                      9 secs ago












                    up vote
                    2
                    down vote










                    up vote
                    2
                    down vote









                    A common way this is done is using an indirect texture lookup in the shader to distort the display texture:



                    Animated gif showing water animation



                    Here I'm using a texture with some low-frequency colour noise (tiling smooth blobs of random colours), and scrolling it across the display geometry over time.



                    enter image description here



                    Instead of drawing the colours from this texture, I instead take the red & green channels and subtract 0.5f to turn them into a pseudorandom 2D vector that changes smoothly over time & space.



                    I can then add a small multiple of this vector to my UV coordinates, before sampling from the main water texture. This shifts the part of the texture we're reading & displaying, warping it around.



                    By averaging two samples from this noise, scrolling in opposite directions, we can hide the direction of movement so it just looks like aimless sloshing.



                    In Unity the shader would look like this - it should be simple enough to translate to the shader language of your choice:



                    fixed4 frag (v2f i) : SV_Target

                    float2 waveUV = i.uv * _NoiseScale;
                    float2 travel = _NoiseScrollVelocity * _Time.x;

                    float2 uv = i.uv;
                    uv += _Distortion * (tex2D(_Noise, waveUV + travel).rg - 0.5f);
                    waveUV += 0.2f; // Force an offset between the two samples.
                    uv += _Distortion * (tex2D(_Noise, waveUV - travel).rg - 0.5f);

                    // Sample the main texture from the distorted UV coordinates.
                    fixed4 col = tex2D(_MainTex, uv);

                    return col;






                    share|improve this answer












                    A common way this is done is using an indirect texture lookup in the shader to distort the display texture:



                    Animated gif showing water animation



                    Here I'm using a texture with some low-frequency colour noise (tiling smooth blobs of random colours), and scrolling it across the display geometry over time.



                    enter image description here



                    Instead of drawing the colours from this texture, I instead take the red & green channels and subtract 0.5f to turn them into a pseudorandom 2D vector that changes smoothly over time & space.



                    I can then add a small multiple of this vector to my UV coordinates, before sampling from the main water texture. This shifts the part of the texture we're reading & displaying, warping it around.



                    By averaging two samples from this noise, scrolling in opposite directions, we can hide the direction of movement so it just looks like aimless sloshing.



                    In Unity the shader would look like this - it should be simple enough to translate to the shader language of your choice:



                    fixed4 frag (v2f i) : SV_Target

                    float2 waveUV = i.uv * _NoiseScale;
                    float2 travel = _NoiseScrollVelocity * _Time.x;

                    float2 uv = i.uv;
                    uv += _Distortion * (tex2D(_Noise, waveUV + travel).rg - 0.5f);
                    waveUV += 0.2f; // Force an offset between the two samples.
                    uv += _Distortion * (tex2D(_Noise, waveUV - travel).rg - 0.5f);

                    // Sample the main texture from the distorted UV coordinates.
                    fixed4 col = tex2D(_MainTex, uv);

                    return col;







                    share|improve this answer












                    share|improve this answer



                    share|improve this answer










                    answered 18 mins ago









                    DMGregory♦

                    52k1195146




                    52k1195146











                    • This looks really nice. I'm not sure I understand all the attributes: _NoseScale = scalar for scaling the "noise map". _NoiseScrollVelocity = Vector2 at which speed we move across the noise map. _Noise = ?. _Distortion = Scalar I choose as a distortion factor? v2f = Vertex we determine the color. i = ?
                      – morpheus05
                      9 secs ago
















                    • This looks really nice. I'm not sure I understand all the attributes: _NoseScale = scalar for scaling the "noise map". _NoiseScrollVelocity = Vector2 at which speed we move across the noise map. _Noise = ?. _Distortion = Scalar I choose as a distortion factor? v2f = Vertex we determine the color. i = ?
                      – morpheus05
                      9 secs ago















                    This looks really nice. I'm not sure I understand all the attributes: _NoseScale = scalar for scaling the "noise map". _NoiseScrollVelocity = Vector2 at which speed we move across the noise map. _Noise = ?. _Distortion = Scalar I choose as a distortion factor? v2f = Vertex we determine the color. i = ?
                    – morpheus05
                    9 secs ago




                    This looks really nice. I'm not sure I understand all the attributes: _NoseScale = scalar for scaling the "noise map". _NoiseScrollVelocity = Vector2 at which speed we move across the noise map. _Noise = ?. _Distortion = Scalar I choose as a distortion factor? v2f = Vertex we determine the color. i = ?
                    – morpheus05
                    9 secs ago

















                     

                    draft saved


                    draft discarded















































                     


                    draft saved


                    draft discarded














                    StackExchange.ready(
                    function ()
                    StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fgamedev.stackexchange.com%2fquestions%2f163689%2fhow-to-animate-abstract-2d-top-down-water-texture%23new-answer', 'question_page');

                    );

                    Post as a guest













































































                    Comments

                    Popular posts from this blog

                    Long meetings (6-7 hours a day): Being “babysat” by supervisor

                    Is the Concept of Multiple Fantasy Races Scientifically Flawed? [closed]

                    Confectionery