They Call Me Loopy:Creating Seamless Loops

By Lance Evans • Category: Tutorials

articlethumb_1.jpg

From the Digital Basics Dept.: Topic suggested by Patrick St.Onge, Boston

Looping, or cycling techniques have always been part of the image business. In graphics we have always had a “step and repeat”, and as far back as the early days of films they had something called “film loops” that would play all day long at nickelodeons.

All of our digital tools offer multiple ways to make loops, cycles and other seamless transitions. Why is this capability so popular? Because it helps us make the best use of our most prized possession, our intellectual and creative property. Such content takes a long time to create, so tools that can help us extend our media’s usefulness are tools we want to take advantage of.

However, based on the many requests I get to explain some of these capabilities, I realize few know how to make good use of them. So what we will do here is to take a short trip along a few toolsets and look at some of the options they can offer. We will cover a bit of the basics (creating seamless textures in Photoshop and in Maya), creating seamless animated clips in an animation program (a very generic approach for all 3D applications), and how to make any non-looping clip into a seamless loop in post. We will then take a look at how loops can be used to give us a quantum leap in production speed using our favorite multi-pass rendering tricks.

Just X and Y
Our first stop on this tutorial is an area most of you should be very familiar with, but we will cover it “just in case”.

Most graphics programs have a “step and repeat” function. These tools can be found in the more common layout programs such as QuarkXpress, as well as the texture mapping sections of 3D applications. These duplicate a selected image and copy it a specified number of times along the vertical or horizontal axis, or both at the same time. If a step and repeat is applied to an arbitrary image then the result will usually be an obvious repeating pattern. This is fine for some projects, but for most of what we do in 3D and animation the harsh edges created are a problem. Instead we usually need to work with imagery which is called “seamless”.

Step and Repeat, Plain and Mirrored
Step and Repeat, Plain and Mirrored

A seamless image is simply one that when duplicated and placed beside itself shows no OBVIOUS repeating patterns. The word obvious is important here as there are absolutely repeating patterns, but if the edges of the image match up exactly-from top and bottom, or from left side and right side-then the seam will be invisible. An invisible seam does not in itself prevent a viewer’s eyes from seeing a repeat, but is the first step in that direction. While we can force most images to become seamless, that does not in itself make for great seamless art. Choosing the right images to work with is always an important first step.

Keep in mind that an image need not be seamless in both vertical and horizontal directions. For example, if all you need is a wrap-around horizon scenic, then a horizontally seamless image will likely suite your needs. No vertical seems will need to be touched. There is a way to make semi-seamless images by using a step & repeat with a mirroring option. This can be a quick solution for some needs, but its results are often crude. Here are two better ways to create it.

Creating seamless images is easy:
In Photoshop, open the base artwork to be made seamless. When designing, painting or choosing the image to work with, try to make sure opposing edges have similar content. This will make the next step much easier.

The next step: Go to FILTERS > Other > Offset

(Note that the Offset filter only works on one layer at a time. So if you want to apply it to a multi-layers file you must first Duplicate. and flatten the file.)

Use the sliders found in this filter to reposition all the pixels in the image. It will offset them in either axis. Set the option toggles to “Wrap Around” and you will see the imagery from one side brought to the other, and the edge will be moved towards the center. Make sure the edge seam is placed a comfortable distance from any canvas boundary to allow for easy working, then click OKAY. Now with the Brush, Clone and other tools we can paint away the hard-edged seam. The vertical and horizontal axis can be done separately or at the same time.

Offset Filter
Offset Filter

If you are using Maya, its Paint Effects toolset adds something even more effective. There are two toggles called Wrap Canvas, one for horizontal and the other for vertical. When clicked on these will let you paint right across one edge and have it wrap the paint stroke to the opposing side. Very nice!

Paint Effects
Paint Effects

One last bit I want to make clear. No matter how talented you are at this, not all images will work as a repeating texture. The less obvious the pattern, the more naturally the edges match up, and the larger the image is used (hence less repetition), then the more successful the project will be.

There are also a variety of lesser known applications for creating tile art, and there is even an automated filter in Photoshop called Patternmaker, most of which I personally find useless. I simply prefer to control I have using the more manual approach discussed above.

Animated Loops-From Scratch
Now let’s look at the animated corollary to seamless 2D tiles, animations that loop in time. These are rather popular for use in gaming, but they have been used for years in multimedia, web work and other purposes. They can also be hugely beneficial in high end animation work, as we will see later.

We will start off with the most obvious way to make an animated loop-create it in the animation package! These need to be generated with a stationary camera, unless of course the camera finishes in the same position it started. Some applications give you fancy ways to accomplish this. But here is a little trick that is so simple many hit their heads after hearing it. And, it is applicable to any 3D or even 2D animation package that uses keyframes.

Got to the first frame of the animation and set the attributes (position, color, size, etc.) of all the items to be animated. Then set a keyframe for this frame. Go through the rest of the timeline setting keyframes as needed. When you get to the very last frame, COPY the first keyframe and paste it into the last frame. This will force the objects to animate themselves back into their starting state. Obviously the second and third keyframes before the last one should also be set appropriately to avoid any overly jarring effects.

Keyframe Loop
Keyframe Loop

While we have created a loop, we have also created a duplicate frame which may result in an ever-so-slight pause or stutter upon playback. There is an easy fix for this. Simply chop off the very last frame of the animation, so that the second to last frame becomes the last one used before cycling back to frame number 1.

Depending on the application, there are a few ways to chop the last frame. You can simply set the rendering controls to less than the full project, or you can manually reduce the number of frames in the file. Doing this may simply shift the last keyframes to one earlier frame. To avoid this you can place your time thumb in that previous frame and force the creation of new keyframes, then delete the ones in the very last frame.

Animated Loops-In Post
We do not always have the luxury of creating those perfect looping animations inside our animation package. Sometimes there are technical limitations that may prevent us doing it, or perhaps the clip was already rendered and we don’t have time to redo it. Or, as is the case of video source, we may be working from real life footage instead of CG. In any of these situations we will need to solve the problem in our post compositing application. Fortunately this is often a relatively easy thing to do, and with a bit of creativity, we can come away with some really convincing results.

Remember that the idea here is to simply make sure our final few frames-especially the last frame-mostly matches our first few frames in all its visual attributes. The more similar the starting frames are to the ending frames, the easier this will be to accomplish. Also, the more abstract the content, the easier it is to fool the viewer’s eye. For example, rolling clouds and fast moving fire footage taken from a stationary camera are often pretty easy to make into convincing loops.

Not to make it too easy on ourselves, our project will take a look at footage that is often not so easy, ocean waves. At first glance it would seem to be very repetitive and easy to loop, which it is depending on things like lighting and wave height. For example, if we have water that has only indistinct waves and is illuminated with mostly ambient light that creates no specularity, then our job is easy. Our example project is not going to be so easy, since it has distinct (if not really high) waves, and a harsh specular reflective light shining across its body.

Let’s start with the basic setup, which we will do in After Effects. We’ll use the file which you can download here: OceanScene.zip

  • Open After Effects and import the “Ocean.mov” QuickTime file.
  • Create a new Composition, setting its pixel size and duration to match the Ocean clip (Time: 3:10, Size: 640×480), and then drop it onto the stage/timeline.

Ocean Footage
Ocean Footage

Open the Time Controls window and click the play options toggle until it displays the “Loop” icon. This will make the previews loop continuously so that we can see the transition between the end and the new beginning frames. Press the RAM Preview button. The comp will first load into memory, this may take a few moments, after which After Effects will play the entire comp. Watch the comp loop a couple of times and see how jarring the jump from end to start is. Since we want to make the start of the clip blend with the end, we will create a “wrap-around” effect, and we will do it in a way that is reminiscent of how we made seamless images earlier-with a few variations of course.

  • Move the time thumb on the Timeline towards the end of the timeline, but not as far as the end itself. Ours was moved to 3:00. Select the clip in the Timeline and EDIT > Split Layer (Control-Shift-D on Windows, Command-Shift-D on Mac).
  • Select the newly created small clip at the end (which should be the upper layer) and drag it to the start of the comp. Make sure its first frame rests at the comp’s first frame.
  • Using the twist arrows, open the top layer’s attributes to expose the Opacity controls. (You could also just hit the “T” key to jump right to that attribute.) Set a keyframe for this first frame, but leave it set at 100%. Slide the time thumb to the end of the clip. (Holding the Shift key will force the time thumb to snap to endpoints and keyframes making placement easier.) Now set this last frame’s Opacity to 0%, and see that a keyframe is automatically created.
  • Press the RAM Preview button again. The comp will need to load into memory once again and then play the comp. This time you will notice that the jump from end to start is no long as jarring as it was before. In fact it’s almost passable. Well, almost. (You can see the results thus far in the After Effects file available with this tutorial “1-Ocean Project.aep”.)

Blend Clip
Ocean Footage

The quick-and-dirty job we just did is so close to being good, it hurts that it isn’t good enough. But that is the case for THIS footage. Had we used a more willing and congenial source as a sample, we would be done now.

How can we make this problem clip loop look better? There are a number things we can do. For now we will concentrate our efforts on the waves, and try to make them match up a little better. This is not very easy as their patterns are not as cyclic as they seem to be. To better match the start and ending attributes we can try changing the timing of the clip:

  • Try either lengthening or shortening the duration of the small blend clip we made. Not by stretching the clip, but by adding or subtracting frame from it (and in turn from the tail-end of the main clip if needed). Creating the blend clip from a slightly earlier point in time may offer a better match-up.
  • Why put our blend-clip all the way at the start? We may find a better match-up by shifting it forward a number of frames.
  • If you can get the first few frames of the blend clip to sync up, but then it falls out of sync, then you may wish to play with stretching or compressing the time of the blend clip using the tools found in LAYER > Timestretch.

Cheating frames from the front or rear of the source footage is fine, however since this particular “Ocean” clip is not long to begin with we need to not steal too much or our loop will cycle too quickly. We will solve one problem and create another. With longer playing source footage we can have the luxury of more to play with. In fact, if this were a commercial shot with real ocean footage, we would have many minutes or even hours of footage to scour for what we need.

Being that this is a tutorial with limited resources we found that cheating the blend clip in a few frames from the start offered a (for now) acceptable compromise. This allowed the waves to match up a bit better. However, if you spend more time on it that we did I am sure you can find an even better match than we have here.

To quickly test the loop, drag the Work Area start and endpoint markers to the start and end of the loop, press play and view the loop. When happy, select the layers and slide them so their start frames abut the left of the Timeline. Then change the comp’s length in the Composition Settings window to end the comp at the end of the clips.

You can see what we have done thus far by opening the After Effects file “2-Ocean Project-More Polished.aep”, and viewing “Comp 1″. You will see that it is smoother than our previous attempt, but something is still missing. While the waves are not perfect, they are not the bothersome part now. Instead, the problem is the way the specular highlights in the water go flat and blah during the blending segment.

This muting down of the specularity is caused by the blending of the two layers, so let’s see of we can put some of that back.

  • Create a new comp (Comp 2) that is the same size and duration as Comp 1. Then drop Comp 1 into it.
  • Dupe the Comp 1 layer so that two layers are in the new Comp.
  • With the top layer selected, scroll the time thumb to view the animation and mark four mileposts: The last frame BEFORE the specularity begins to diminish, the frame where it has diminished and is not diminishing any further, and the same two frames on the upswing of the blend process. Use the LAYER > Add Marker (or keypad-*) to mark these frames.
  • Since we only want to affect the bright specular areas of the water, double-click on the upper layer to open its editing window. With the Pen tool, create a vector mask around the specular zone. Then add 20-30 pixels of Mask Feather. Close the Edit window.
  • Position the time thumb between the inner markers. With the top layer selected add a Levels effect. We want to bring up the highlights, so drag the Input Whitepoint down until the specular highlights are looking similar to those seen at other points in time. What values you use here will depend upon how you set up the layer and what Blending Mode you choose for it. Many will work here, but each will require different ancillary settings.
  • Open the top layer’s Opacity and add a keyframe at each of the marker positions. The two inner markers should be set to 100% opacity, and the two outer markers should be set to fully transparent. Scrub the timeline to see how it looks, and then play a full preview.
  • Finally, we noticed that raising the highlights also increased the color saturation a bit. So we threw in a Hue/Saturation filter to tone the colors back down.

Blend Clip
Polished Version

When testing the quality of the loop it is helpful to play it both honestly, and also be cheating. What I mean by this is to play it both while peaking at the timeline so you can see the moment it jumps to the start, and also while not peaking. Each way of viewing the loop will tell you different things.

When happy with the results, render out your project.

Loopius Exoticus
If you think we have gone to extremes in making this work, well, we haven’t. While this may not have been the easiest loop to make, there are others that require much more work and ingenuity.

Some imagery requires that we push the envelope further in order the get disparate parts to gel. Sometimes this may mean making very exotic masks or blending using a series of filters and Channel Ops (Channel Operations). For example, we can use the Set Matte effect filter and choose to mask the top layer using any channel from either the top or bottom layer. Or by using the layer’s luminosity values as a mask. We can also use the Pen tool to create vector-based masks, which are easy to animate with softened edges.

More complex loops can require brute force techniques like deformations to make it all work. More often than not, if too much brute force is needed to make something technically work, it will not work on an aesthetic level. Let your artist’s eye be your guide.

Also keep in mind that even though such options can save the day, it often takes a while to come up with just the right mix of treatments to make it all work.

Loops and the Multi-Pass Render
While most people think of loop clips as the domain of the low end for games and multi-media, this is not always the case. While loops are often made of small pixel dimensions, they can also be made full broadcast quality resolution. They can also play for longer times instead of the brief loops we usually think of.

Why would we want a high definition loop, how would we use it?

One such use would be to save us lots of production and rendering time. Take the Ocean clip as an example. Since it was created in 3D, imagine if we have a film project at 2k resolution that required a CG generated water scene to be dropped behind either other CG elements or even live action shots.

Imagine that the shot lasted for 5 minutes, and that each frame took over 8 minutes to render. At a film rate of 24 fps that is 7200 frames at 8 minutes each, or 57,600 minutes, or 960 hours, or 40 days and 40 night of rendering on one computer (no, I didn’t plan that!). And this is just for ONE layer!

But what if you could create a loop, instead? What if you were to generate a 10-second loop that could play in the background of the composite? A 10-second loop should be plenty of time to prevent viewers from picking up any looping actions. Using the same specs as before, a 10 second loop would only take 32 hours on a single machine.

If a simple little film-loop could save you over one month of rendering, would you ever look down your nose at it again? I wouldn’t.

The Set-Up: If there is a way to automatically set a short clip to repeat ad infinitum in a compositing application channel, I am not familiar with it. However, even done manually, setting up a loop is a fast enough thing to do. Select, dupe, select and slide into place (hold that Shift key in After Effects to invoke snapping), and do it again. Get a dozen or more layers placed and then Pre-compify. Then each dupe and place cycle places a dozen or more at a pop, and you are done before you know it.

Comments are closed.