Game Development Community

Animated Textures in T3D

by JesseL · in Torque 3D Professional · 05/29/2009 (12:20 pm) · 22 replies

I think I am a little confused on how Animated Textures work. I would assume that if I created a texture that was 320 units long and 32 units high. Every 32 units I placed a texture like a number increasing from 0 1 2 3 4 5 6 7 8 9.

baseTex[0] = "demo/data/shapes/particles/alphasoup0_9";
   animFlags[0] = $sequence;
   sequenceFramePerSec[0] = "10";
   sequenceSegmentSize[0] = "0.1";

instead it just looks like it placed the whole texture on the shape and is scrolling it around. What do I do? This was not the intended effect!

About the author

I just realized that if I wanted to create a cat that caught on fire and ran up a telephone pole and then burst into a blue waterfall. That wouldn't be to hard!

Page «Previous 1 2
#1
05/29/2009 (1:01 pm)
I can't say i've used it myself... but i really do want to understand. Anyone used it before in TGEA?
#2
05/29/2009 (2:56 pm)
Looking at the source, I believe something is missing:

// handle sequence
      if( mMaterial->mAnimFlags[i] & Material::Sequence )
      {
         U32 frameNum = (U32)(MATMGR->getTotalTime() * mMaterial->mSeqFramePerSec[i]);
         F32 offset = frameNum * mMaterial->mSeqSegSize[i];

         Point3F texOffset = texMat.getPosition();
         texOffset.x += offset;
         texMat.setPosition( texOffset );
      }

It's applying an offset based on the current frame, but shouldn't it scale the texture as well, to account the number of frames?

Anyway, even if it scales the matrix it wouldn't work for tiling textures. Something would need to go in the shader itself to clamp the sampling to the current frame only.
#3
05/29/2009 (4:14 pm)
apart from the GUI torque gets pretty uppity if you give it images that dont conform to the power of 2 rule anyway so your 320x32 image would probably trip up some thing.

as for animation, i believe torque supports image file lists, which is possibly a better approach than framed images?
#4
05/29/2009 (8:15 pm)
new Material(TestIFL)
{
mapTo = "explosion.ifl";
baseTex[0] = "~/data/shapes/explosion/glauncher_exp0010";
translucent = true;
emissive = true;
};

thats how you do an IFL each file is seperate. But the animated (sequence) texture is suppose to all be together.


Sequence
Sequences are a series of images that reside in a single texture. They are arranged in the horizontal of a texture and offset at regular intervals. The sequence texture doesn't need to be square, but it does need to be a power of two to work.



The sequenceFramePerSec parameter indicates how many sequence segments are displayed in a second. The parameter sequenceSegmentSize indicates the size of each segment in a sequence in texture space.



For example for a sequence of 4 32x32 images, create a 128x32 size texture. Then create the images side by side in the image. To show all four images in one second as a looping animation, set sequenceFramePerSec to be 4.0. The sequenceSegmentSize parameter should be set to 0.25 because there are 4 segments (1/4 equals 0.25).



An example of it's use is:


new Material(AnimatedMat)
{
baseTex[0] = "demo/data/shapes/spaceOrc/orc_ID1_skin";
animFlags[0] = $sequence;
sequenceFramePerSec[0] = 4;
sequenceSegmentSize[0] = 0.25;
};

Take a look at this place::

http://tdn.garagegames.com/wiki/TSE/Materials/Overview
#6
05/31/2009 (11:23 pm)
You know we could probably fix that... you would texture your model in the 0 to 1 UV space like its one frame of the animated texture. In the vertex shader we can then rescale that to fit one frame of your animation.

That seems like it would that be better than having to UV something for a specific frame size.

Thoughts?
#7
06/01/2009 (4:46 am)
[Edit]
I like the Idea, We can always use the material scroll to scroll the whole texture around so I feel that this would be a better fix for material animation.
#8
06/30/2009 (9:07 am)
Did this get looked into? Will it make it in or?
#9
08/09/2009 (11:24 pm)
bump.
#10
08/15/2009 (11:18 am)
This has yet to be implemented! Is this something everyone wants or am I just barking up the wrong tree here?
#11
08/15/2009 (12:47 pm)
No one has had time to look into it yet... but i still think its a good idea. If it doesn't make it into 1.0 it will into 1.1.

THREED-651
#12
10/21/2009 (8:12 pm)
I'm just trying to get a simple IFL of 512x512 png's to animate on a decal.... Apparently my material definition is incorrect

singleton Material(DECAL_pingDecal)
{
   mapTo = "greenPing.ifl";
   baseTex[0] = "art/decals/mapArt/greenPing0000";
   baseTex[1] = "art/decals/mapArt/greenPing0001";
   baseTex[2] = "art/decals/mapArt/greenPing0002";
   baseTex[3] = "art/decals/mapArt/greenPing0003";
   baseTex[4] = "art/decals/mapArt/greenPing0004";
   baseTex[5] = "art/decals/mapArt/greenPing0005";
   baseTex[6] = "art/decals/mapArt/greenPing0006";
   baseTex[7] = "art/decals/mapArt/greenPing0007";
   baseTex[8] = "art/decals/mapArt/greenPing0008";
   baseTex[9] = "art/decals/mapArt/greenPing0009";
   baseTex[10] = "art/decals/mapArt/greenPing0010";
   baseTex[11] = "art/decals/mapArt/greenPing0011";
   baseTex[12] = "art/decals/mapArt/greenPing0012";
   baseTex[13] = "art/decals/mapArt/greenPing0013";
   baseTex[14] = "art/decals/mapArt/greenPing0014";
   baseTex[15] = "art/decals/mapArt/greenPing0015";
   translucent = "1";
   alphaTest = "1";
   animFlags[0] = "0x00000010";
   sequenceFramePerSec[0] = "16";
   sequenceSegmentSize[0] = "1";
};

This material was primarily created through the material editor, I have been tweaking and twisting to no avail.
#13
10/22/2009 (12:46 pm)
wait wait wait. Do you want to do an IFL or a GIF type image? My example was for a GIF type image. When the Item loads it becomes a animated GIF automatically. If you want to do a Sequence IFL for a ShapeBased object then ya don't use the way to do a GIF. When you use this way its like taking a long reel of Image-frames and putting them together horizontal like in one file. Then telling it to play that file on a surface that meets the exact UV map of one Image-frame. If you want examples of how IFL's get played and loaded take a look at how the cloud (sky) content works. That loads an IFL.
#14
10/22/2009 (7:09 pm)
Ok, I was looking at the post you made back on May 30....

I'll look at the cloud materials and see if I can figure it out. If I can't, I'll be begging here again shortly.
#16
06/03/2010 (3:01 pm)
I'm holding for the 1.1 complete release to see if it made it. If not, hopefully it'll make one of the fast-tracks they were talking about a little bit ago in the blogs.

I'm also looking forward to the stuff from the new docs guys - I think this will go farther for me than even a large feature/functionality update because I don't have much time for digging through code. It's easier for me to sit and read manuals in bits as I have time than it is for me to read code - basically, if I can't devote at least two straight hours to reading code I can't seem to retain any of it.

Anyway, this feature could use a bit of refinement and I'm looking forward to seeing what the guys bring us.
#17
06/25/2010 (11:30 am)
Any Chance of a GG comment on if this made it into 1.1 Beta 2 that we've been hearing so much about. :p
#18
06/25/2010 (12:43 pm)
The changes haven't made it into Torque 3D yet and there is a good chance it won't be in Beta 2.
#19
06/25/2010 (12:44 pm)
I have used this, and I end up with the same effect of the "scrolling" type texture instead of it using all my texture "slides", as I like to call them. perhaps is this meant to be done like bullet holes and such, putting all the frames on the same bitmap? Looks like you guys have tried everything else, but this is just a guess of course:O)


Edit: ...guess I should have read Richards post more clearly...oops
#20
06/25/2010 (12:52 pm)
My understanding is that to make it work you have to make sure that the UV coordinates of your model match the size of your "frames" on the texture.

For example if you have a 4 frame texture (say 1024x256) that you want to map to a single quad in your model then you will need to make sure that the U coordinates for that quad go from 0.0 to 0.25 and not from 0.0 to 1.0 as you probably have it now.

It should then only show one frame at a time as it progresses through the texture. The annoying thing is that you would have to remap your UV's every time you change the number of frames.

Ideally, you should be able to map your UV's as 0.0 to 1.0 and then the ShaderGen feature would automatically scale the UV's down to match the number of frames. Sadly, we just haven't had the time to go and write that code since there have been higher priority bugs that need fixing.
Page «Previous 1 2