Tutorial: Animated GIFs

Recently, I have been having a lot of fun creating these little animations to show off our progress for Sprout and I thought it would be nice to share how I do it. After all, games are best viewed when in action!

This will be a full tutorial showing the steps I took to create this animation of our Beast character from Sprout and it involves the use of Maya and Photoshop.

Step 1: Create A Scene

For this animation, I cobbled some assets together from the Title Animation I made a little while ago and imported the animated character I wanted to use. Using File > Import to import the Maya file into the scene will insure that all elements from the animated scene will show up in here in case you end up needing them.

I had my camera set up during this creation process so I could always see what the scene looked like as I added elements and moved things around.

The Beast was already animated, so in this scene I moved the track to the proper time so when I scrub through the timeline, I can see a preview of what I will be rendering. His peeking animations were from frame 292 to 435 so that's where my time track is.

Step 2: Render Setup

This section is specific to 3D programs and even more specifically to Maya so you could skip it and move on to Step 3 if you want.

If you are using Maya as well, consider the new "Viewport 2.0" which offers fantastic real time hardware rendering. This makes it easy to see what you are going to record immediately in the viewport and it also makes rendering time go really fast.

Even though the materials I am using are simple, you can have some pretty advanced materials and effects show in real time using this viewport.

The settings I used for this scene were the "Anti-Aliasing" to remove jagged edges and the "Screen-space Ambient Occlusion" to give the scene some depth.

The lighting could be it's own step but because I'm leaving you to play around with all these settings, I will show the basic lighting setup that I used for this scene. I recommend making your own as every scene is different and would benefit from a unique setup.

- Ambient Light: I have an ambient Light to remove the ugly black shadows from the scene. This light brightens everything up and makes the normals look much less muddy.

- Directional Light: I'll want to add shadows in eventually so I need a Directional Light in the scene as well. To get nice looking shadows, I used these settings. By default, the "Depth Map Shadows" are harsh and jagged so making the "Filter Size" higher, will smooth the edges out. They aren't fantastic but they will look fine for these purposes.

- Point Light: I'm also using a point light behind the camera to softly brighten everything up a bit more.

Now to get the shadows to show up, switch on the shadows in the viewport toolbar by clicking the "Shadows" icon.

That's as far as I went in setting up the scene but there is a ton you may want to add to give your scene the look it needs so don't stop here!

Step 3: Render The Scene

This can be done in any number of ways depending on the software you are using to display your scene. In some cases, your program won't support its own rendering like most 3D programs so doing a screen capture would do as well. There are a ton of screen capture programs out there so just find the one that suits you best. A simple and free solution you might choose could be something like Open Broadcaster which also supports video streaming and stuff.

Now more Maya specific stuff! After I render out my image sequence, I go right into Photoshop so skip on to Step 4 if you aren't using Maya.

Because I used Viewport 2.0 to set the scene up, I want Maya to use that same process while batch rendering my animation frames. So in the render settings, I select "Maya Hardware 2.0". Maya will use all the viewport settings I already set up and my render will match everything I see in my scene. All the same settings can be adjusted in the Render Settings window as well.

The important settings for doing a batch render are in the "Common" tab:

- First of all, I need to tell Maya what "Image format" I want each frame to be saved as. For this project I used PNG for good quality, high comparability and 32 bits (alpha channel).

- Second I need to set the naming conventions or "Frame/Animation ext". By making it "name.#.ext" I will get a file something like this: "BeastScene.292.png". When I do a batch render, all my frames will be named that way with the proper frame number at the end. This is important because it will keep the frames all in order for the most part...

- That brings me to the third setting. This is important! The "Frame Padding" adds a "0" at the start of the frame number in the file name. If this is set to a digit lower than the digits of frames in the animation, the files will be in order until an extra digit is added to the name, then they will start ordering wrong depending on what software you are using to compile the frames later on. I always set it one digit above the total digits of my highest frame. in this case my last frame will be named "BeastScene.0435" and I know most any program will read that as the last frame.

You can always see a preview of what your file names will look like right at the top under the "Common" tab.

- The fourth setting is the "Frame Range". This is where I designate the frames the batch render will start and end on while it renders. For mine, its starting on 292 and ending on 435 and rendering every frame one-by-one.

- The last settings are to designate the camera that will be capturing the scene (generally goes with the one you have selected as well) and the resolution of the final image of each frame. Because I'm making a GIF, I'm using a relatively small size but because I can edit this in Photoshop later, the size doesn't matter too much as long as its not too small.

A quick optional setting if you are dealing with transparency in your scene is to set the camera environment to white instead of its default black by selecting the render camera and changing the "Background Color" environment attribute. This will make edges on semitransparent pixels harder to see on light backgrounds. You may want to keep it darker depending on the background you add in later. If your scene has a background in Maya, you likely won't need to worry about this.

When those settings are all set, all that's left to do now is the batch render. To do so, have the "Rendering" toolbar open and select Render > Batch Render. Maya will start rendering all the files to the progect folder. If you don't have a project folder set, it will send the images to "C:/Users/UserName/AppData/Local/Temp".

Step 4: Composite Frames

Now that I have these frames saved as images, I can open them right up in Photoshop as an "Image Sequence". Photoshop can recognize a sequence of images based on their file name so by clicking the first image in the sequence and checking that box, you can open all the files at once and it will play like a video in Photoshop!

In order to edit the video, you need to open up the "Timeline" window. From here, you can make all kinds of edits to the sequence. Because the animation is inside Photoshop now, you can do just about anything you would want to do with the rest of Photoshop's tools, like add layers and adjust colors.

Step 5: Save GIF

Once you are happy with your animation, you're ready to save this guy out as a GIF to share with the world! To save as a GIF, Go to File > Save for Web to open the "Save for Web" window. From here, you have all kinds of options that let you adjust quality, size, colors, and how the GIF will play (Looping Options). It also has a live preview so you can see exactly what the GIF will look like once it is saved with those options.

You can see the settings for my example in this image. I use a "Pattern" dither to give it a nice effect even though I'm using so few colors.


That's all there is to it! Once you get passed all the technical stuff, it gets easier and faster to make animations like these. I think its a nice and quick way to show off little examples of animations or just make some fun things to share with your friends.

I hope this was useful for some of you and as always, please leave comments if you have any questions!