User Tools

Site Tools


frame-by-frame_texture_animation

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

frame-by-frame_texture_animation [2014/08/19 03:03] (current)
phanjam created
Line 1: Line 1:
 +======Frame-by-frame Texture Animation======
 +
 +By: Arkham
 +<style right>​Tags:</​style>​
 +{{tag>​[textures animated_textures]}}
 +
 +This is a tutorial for making animated textures. The files I provide are for a weapon, but this same method can be used for props and characters/​creatures as well.
 +
 +This tutorial is fairly specific in scope and is intended for people who already have at least some expertise in Torchlight mod making, so I will be glossing over certain details that might not be familiar to newer modders.
 +
 +
 +====Tutorial files====
 +
 +Download the tutorial files (in RAR format) at RGF:
 +
 +http://​www.runicgamesfansite.com/​vbdownloads.php?​do=download&​downloadid=576
 +
 +Everything has been provided but one thing -- the tut_scythe.material file is incomplete. If used in its current state it will simply display the scythe'​s regular diffuse texture; this tutorial will cover what needs to be added and why (covering how the texture animation works in the process).
 +
 +{{http://​i.imgur.com/​KPaMJWj.jpg}}
 +
 +Fig. 1: Scythe without animation
 +
 +
 +====Editing the material file====
 +
 +Open the **tut_scythe.material** file in a text editor. (Notepad, Wordpad, and Notepad++ are all perfectly acceptable.)
 +
 +Note that there is only one texture declaration currently in the file, which reads "​texture scythe.dds"​ -- this is the part assigning the diffuse (color) texture. What we're going to add is a second declaration,​ which will tell the material to use a series of frames as an emissive (glow) texture, that will "​pulsate"​ on and off.
 +
 +Add another texture_unit section as follows:
 +
 +<​code>​
 + texture_unit
 + {
 + anim_texture scythe_glow.dds 24 2
 + colour_op add
 + }
 +</​code>​
 +
 +There'​s a few differences here: first is, the regular texture declaration is replaced with **anim_texture** to tell the engine that this texture will play through multiple textures instead of just displaying one texture statically.
 +
 +The filename is slightly deceptive here: there is no texture file we have made named "​scythe_glow.dds"​. Rather, this tells the engine to look for a sequence of files named **scythe_glow_0.dds**,​ **scythe_glow_1.dds**,​ **scythe_glow_2.dds**,​ and to keep looking until it gets to the last one in the sequence (more on that part below). Naming the files this way (meaning, ending with "​underscore+number"​) has to be done exactly, specifically this way, starting with **_0** and moving upwards, in order for it to work. The final frame'​s number should be one less than the actual total number of frames there are, since you are counting from zero.
 +
 +For the two numbers at the end of this line -- the first number says the total number of frames to cycle through before looping back to the first one; the second number tells you the number of seconds it takes to play through the animation once.
 +
 +In the case of my own texture, there are **24 frames** total that I want to play over the course of **2 seconds**. If you made your own texture animation of 12 frames that needed to play over the course of a half-second,​ you would want the line to read **anim_texture scythe_glow.dds 12 0.5**.
 +
 +You can set this second number to anything in order to alter the speed at which the animation plays. A lower number will speed up the animation and a higher number will slow it down; however, when slowing down an animation made up of a limited number of frames, the rate the frames are played back will inherently slow down as well, which can start to look bad and stagger-y if your animation is supposed to look like a smooth transition from frame to frame. Keep this in mind when determining what your framerate should be like -- it's worth it to do the math and calculate out an animation length and rate that translates to something more or less **between 20 to 30 frames per second** to keep the texture animation looking nice and smooth. Shorter animations are almost always easier to deal with -- a 10-frame long animation that plays for half a second will still be the equivalent of a full 20 frames per second.
 +
 +This is, of course, the issue one has to think about and deal with before they even begin a project like this, since you have to decide how many frames you want the total animation to be.
 +
 +Lastly **colour_op add** is simply what tells it to treat the textures as a glow texture (by "​adding"​ the color onto the existing diffuse texture independently of the in-game lighting).
 +
 +
 +====Testing/​Wrapping up====
 +
 +In any case, we now have everything we need. You can now add the files to a new GUTS mod's folder structure, and set up an item referencing the **tut_scythe.mesh** file (I recommend the polearm weapon type for this example) if you want to see it in action yourself. Make sure that the mesh, material, and texture files all remain in the same folder.
 +
 +{{http://​i.imgur.com/​bTE8stT.gif}}
 +
 +Fig. 2: Scythe with animated glow
 +
 +
 +====Tips on making your own animated textures====
 +
 +  * Your weapon (or prop, or whatever else) should be modeled and UV unwrapped.
 +  * In most cases, the animated elements are only going to be a portion of the texture changing. Hence, it would be wise to finish up a "​base"​ texture of all the parts that are not going to change during the animation.
 +  * You certainly do not have to do an animation that is 24 frames long. 12 to 16 frames can be sufficient for many simple animations.
  
frame-by-frame_texture_animation.txt · Last modified: 2014/08/19 03:03 by phanjam