How to loop a water surface animation?

As you can see from the scene below , I have a plane setup to simulate a lake : 


The plane is using a displacement mod to simulate water ripples. The displacement texture is animated by means of an empty that is parented to a bone in an armature. I have set the bone to rotate on its Y axis 360 degrees so that as it rotates full circle , it creates a looping seamless animation of the water rippling gently. 

This is all good , however, I have to make the whole rotation 3500 frames long to get the water ripples to go slow enough to look the way I want. However , as this animation is to be used in game , I really need it to be 48 - 96 frames max. The issue I have though is that I can't find a single section of the 3500 frame animation where I can cut such a segment from that gives a believable loop that does not jump. 

Can anybody offer any advice? @waylow  this is probably something you know all about? 

Thanks in advance guys :) 

  • spikeyxxx replied

    If I remember correctly, Greg Zaal showed a technique which could be used for something like this here:

    https://cgcookie.com/tutorial/creating-a-looping-cloth-simulation

  • Wayne Dixon replied

    I can't recall how many frames the loop was in the Halloween animation but check out this video
    https://cgcookie.com/lesson/procedural-pond-surface-animation

    But this type of thing seems right in Kent's wheelhouse( @theluthier )

  • Kent Trammell replied

    Ahh I remember dealing with this exact same issue! At that time I took the easy route and simply dissolve transitioned the image sequence during video editing. If you look close you can see a subtle jump.

    However as I'm rethinking this problem, you could try a similar "dissolve transition" in the shader instead. For this to work you'll need to go with shader bump instead of geo displacement. I suppose you could bake the resulting procedural texture to an image sequence to then plug into a displacement modifier..but that's too convoluted and unnecessary since the pond surface displacement is so subtle anyway.


    Ok, here's my attempt to describe the approach clearly:

    1. Translate your wave displacement over to shader nodes.
    2. Once you have the speed of the waves established (and at linear interpolation of keyframes), duplicate that node (or group of nodes) so you have two identical wave texture chunks.
    3. Within the desired timeline length, align your first wave texture keyfame (0° rotation) to the start of the timeline.
    4. Align your second wave texture keyframe (0° rotation) to the end of your timeline. Easy by selecting both keyframes in the graph editor and hitting G + X + (number of timeline frames).
    5. Finally, add a simple RGB mix node to combine both wave textures.
    6. Then you can animate the mix value from 0 to 1 whenever you want in your timeline (between start and end). You can mix slowly over more frames or quickly over fewer frames. Whichever results in the least noticeable transition.

    The result should be a seamless loop of the textures at the beginning and end with the transition in the middle.

    Does that make sense frikkr?

    EDIT: I couldn't resit making an example .blend file: https://www.dropbox.com/s/2051gs1vrls2yq3/looping-pond.blend?dl=0

    The speed of the waves can be adjusted by extending / shrinking the second keyframe of both mapping nodes.

  • spikeyxxx replied

    Well, if you want to use a Shader for the displacement, you might be able to use this Node setup (the second, improved one):

    https://cgcookie.com/questions/11218-want-to-loop-a-noise-texture-here-s-a-way-to-do-that

    This works because we now have 4D Textures

  • Kent Trammell replied

    Ahhh I forgot about your thread. Great suggestion spikey 🎯

  • spikeyxxx replied

    The above mentioned node setup for looping  a noise texture was made with the procedural fire by @theluthier in mind and gives a choppy effect. So here is a smoother variant that is more suited for a water surface:

    By the way if you take a Value Node and type #frame in the number field, Blender automatically sets up a Driver for you....

  • Matthew Fricker(frikkr) replied

    Great stuff guys , thankyou all for your help. I have lots to try out now and I will keep you posted on the outcome  :)