December 22, 2024, 09:24:43

Author Topic: Adding custom animations  (Read 35659 times)

Offline Mularac

  • Lieutenant
  • ***
  • Posts: 531
  • Karma: 11
    • View Profile
Adding custom animations
« on: February 28, 2010, 06:46:10 »
Hey Arparso, may I enquire how did you manage to include your own fx animations? I tried something of my own, with little success, and I wish to know if I failed in the coding or in the painting of the fx.

Offline Arparso

  • Administrator
  • Lieutenant
  • *****
  • Posts: 558
  • Karma: 14
  • I can see you...
    • View Profile
    • http://arparso.de/nexus
(No subject)
« Reply #1 on: February 28, 2010, 13:08:10 »
You mean animated textures as EFX? That's not too complicated.

First you need to create your animation. You can hand-draw each frame, if you're talented enough, or "simply" create your animated explosion/warphole/whatever effect in a 3d application like 3D Studio Max and export the individual frames as individual images. I got the frames for my animated subspace effect directly from the FS2 upgrade project, so I can't really help you with that step. Just make sure, your frame's width and height are both a power of two like 32, 128, 256 or 512 pixel, as that'll make things easier down the road. I'll also suggest black as backgrond color, since that'll allow us to not worry about the alpha channel for transparency (because we'll be using additive blending).

The frames for an explosion effect might look like this, for example:


Now you need to pack all these individual frames into a single texture. Nexus' texture converter is supposedly able to do that, if you select "***** sequence (BMP)" in the conversion options, but I was never able to get that to work. If you know how to do that, please let me know - otherwise just pack them yourself. Nexus supports a maximum texture resolution of 2048x2048, which also limits the size and amount of frames you'll be able to put into a single texture. In my example I've got 47 frames each 256x256 pixels wide. In a 2048x2048 texture, I can fit 8 frames in a row (2048 / 256 = 8) and need 6 rows to store all 47 frames (6 * 8 = 48). Smaller texture sizes like 2048x1024 or 1024x1024 aren't big enough to store all my frames, so that'll have to do for my example.

You can use all kinds of software to pack all frames into a single big texture. Personally I'm using XnView for that, which has a nice feature to automate most of the work (Create -> Strip of Images, or Shift+A). The resulting texture might look like this:


Save this texture as 24-bit or 32-bit tga, depening on if you need an alpha channel or not, and convert it to Nexus' format using Nexus' texture converter. For maximum memory efficiency choose "compressed [DXT1/DXT3]". You can also go with 16- or 32-bit options, but that'll also cost more graphics memory.

Now open up "universeenginemod_ani.ini" and insert this:
Code: [Select]
ANI ""
For my explosion example I'd use this:
Code: [Select]
ANI 40 "fxmy_explosion" #BL_ADD #APM_ONCE 47 8 6
needs to be in the range of 40 - 59
is the path and name of the .tex file
is the blending mode, #BL_ADD means additive blending in this case
lets you specify looping animations, if you need that - the explosion shouldn't loop, so I used #APM_ONCE
is the number of animation frames, here 47
is the number of animation frames per row, here 8
is the maximum number of rows fitting into the texture, even if you didn't fill them all up, here 8

You can see the list of blending modes and playmodes in the modding manual at "5.2 Animated Sequences".

Now you can add your animated sequence to any EFX block you'd like with using the ANI keyword:
Code: [Select]
ANI
Index 40 0
Size 200
ANI

... or in a particle effect using the SEQUENCE keyword. My warp effect looks like this, for example:
Code: [Select]
PARTICLE "Warp"

    duration 4
   
    SEQUENCE
        type 40
        fps 25
        startframe 0
        size 0 {dur 1 lerpto 50} {dur 2.5 lerpto 50} {dur .5 lerpto 0}
    END
   
END

Offline Mularac

  • Lieutenant
  • ***
  • Posts: 531
  • Karma: 11
    • View Profile
(No subject)
« Reply #2 on: February 28, 2010, 15:49:46 »
This is really excellent Arparso! should help and plenty of others. Why don't you add it to the wiki?

Offline Arparso

  • Administrator
  • Lieutenant
  • *****
  • Posts: 558
  • Karma: 14
  • I can see you...
    • View Profile
    • http://arparso.de/nexus
(No subject)
« Reply #3 on: February 28, 2010, 16:03:48 »
Will do, right after finishing the Vasudan ships I'm currently working on ;)

Offline Mularac

  • Lieutenant
  • ***
  • Posts: 531
  • Karma: 11
    • View Profile
(No subject)
« Reply #4 on: February 28, 2010, 16:06:53 »
oh.... that's so awesome... please post pictures later, please! :P

Offline Mularac

  • Lieutenant
  • ***
  • Posts: 531
  • Karma: 11
    • View Profile
(No subject)
« Reply #5 on: February 28, 2010, 19:10:40 »
uhm.. are you sure that the tga file has to be done withouth the alpha channel? in test run the game would run the whole picture, not each frame. Here's my coding:

the effect

Code: [Select]
ANI 40 "panorama" #BL_ADD #APM_ONCE 25 5 5

and the particle

Code: [Select]
PARTICLE "Hyper"

    duration 8
   
    SEQUENCE
        type 40
        fps 25
        startframe 0
        size 0 {dur 0.5 lerpto 5} {dur 3.5 lerpto 17} {dur 4 lerpto 25}
    END
   
END

Offline Arparso

  • Administrator
  • Lieutenant
  • *****
  • Posts: 558
  • Karma: 14
  • I can see you...
    • View Profile
    • http://arparso.de/nexus
(No subject)
« Reply #6 on: February 28, 2010, 19:50:27 »
Quote
uhm.. are you sure that the tga file has to be done withouth the alpha channel?
You can also save it with an alpha channel, if you're going to use one of the alpha blending modes (such as #BL_ALPHA, #BL_ALPHAINVERT and #BL_ALPHAADD) - otherwise you don't need that channel and can free some memory this way. DXT1-compressed 24-bit textures without an alpha channel take up only half the memory a DXT3-compressed 32-bit texture needs. ;)

Quote
in test run the game would run the whole picture, not each frame.
What are the dimensions of your texture? Width and height of the packed image should be a power of two, such as 128, 256, 512, 1024 or 2048. Width and height don't need to be the same, though, so you can safely use a 2048x128 texture, if that fits your needs.

Offline Mularac

  • Lieutenant
  • ***
  • Posts: 531
  • Karma: 11
    • View Profile
(No subject)
« Reply #7 on: February 28, 2010, 20:03:48 »
Quote
What are the dimensions of your texture? Width and height of the packed image should be a power of two, such as 128, 256, 512, 1024 or 2048. Width and height don't need to be the same, though, so you can safely use a 2048x128 texture, if that fits your needs.

uhm... that could be an issue, I'm currently using an image of 640x640 (25 blocks of 128x128 frames, 5 colums and 5 rows)
I'll give it a shot

Offline Arparso

  • Administrator
  • Lieutenant
  • *****
  • Posts: 558
  • Karma: 14
  • I can see you...
    • View Profile
    • http://arparso.de/nexus
(No subject)
« Reply #8 on: February 28, 2010, 21:34:54 »
Then make it a 1024x512 image: 4 rows with 8 frames each. You don't have to fill the last row, just leave the remaining frames empty. This is why you have to set the total number of frames in mod_ani.ini ;)

Offline jstubbles

  • Petty Officer
  • **
  • Posts: 169
  • Karma: 2
    • View Profile
    • http://www.ivassago.com
(No subject)
« Reply #9 on: March 01, 2010, 19:51:58 »
Bear in mind too, that if you're going to be using the BL_ALPHA blend mode, your alphas need to be premultiplied. By that I mean you have to compensate for the funky way gfx cards handle pixel blending. If you just create the particle on a black BG w/alpha, your sprite will have a black halo around it, for example (if using bl_alpha). Here's an example of a non-premultiplied alpha on a white BG and the "halo" effect:




Now this is an example of the premultiplied particle I created for our BSG mod:



and this is the texture sheet:



As you can see, it's on a black BG and there's no halo effects. The premultiplied alpha makes the texture look pretty funky, since the pixels are being spread around like that. But the alpha channel is what culls it out to perfection :)

Here's the alpha chan, which looks how you'd expect it to look:




@Arparso - thanks for the tip on using XnView to create the sheets! My god, I was doing it all by hand in Photoshop - what a nightmare! I've been using XnView for years and didn't know about that feature :)

Offline Mularac

  • Lieutenant
  • ***
  • Posts: 531
  • Karma: 11
    • View Profile
(No subject)
« Reply #10 on: March 05, 2010, 02:14:22 »
Guys, I'm loosing my mind here. I don't know what the hell I'm doing wrong but the effect will just not play right! I know it's not the coding, and since my photoshop skills are pretty much non-existent (I even used gimp instead of ps). So, would it be too much to ask for a hand with it? If anyone is willing to help I can upload the big tga file withouth the alpha channel...

Offline jstubbles

  • Petty Officer
  • **
  • Posts: 169
  • Karma: 2
    • View Profile
    • http://www.ivassago.com
(No subject)
« Reply #11 on: March 05, 2010, 08:02:23 »
Sure thing man, I can take a peek at it.

Offline Mularac

  • Lieutenant
  • ***
  • Posts: 531
  • Karma: 11
    • View Profile
(No subject)
« Reply #12 on: March 05, 2010, 10:02:01 »

Offline jstubbles

  • Petty Officer
  • **
  • Posts: 169
  • Karma: 2
    • View Profile
    • http://www.ivassago.com
(No subject)
« Reply #13 on: March 05, 2010, 10:58:16 »
This is a warp effect? Hmm. I haven't messed around with those myself, but the animation itself plays fine. I just replaced my flak explosion with your warp texture, to get this:




All of the frames of animation play just fine, though the texture itself is a bit fudgy (haloed).  My mod_ani looks like this:

Code: [Select]
Ani 42 "fxwarp" #BL_ADD #APM_ONCE  64 8 8

Offline Arparso

  • Administrator
  • Lieutenant
  • *****
  • Posts: 558
  • Karma: 14
  • I can see you...
    • View Profile
    • http://arparso.de/nexus
(No subject)
« Reply #14 on: March 05, 2010, 11:48:02 »
Seems I made a stupid mistake in my "tutorial": , the last number you enter in your animation's line in the mod_ani.efx, isn't the number of rows with animation frames, but the total number of rows fitting into the texture. In this example it should be 8, because 8 rows of 256x256 frames fit into a single 2048x2048 texture, although you're only filling 6 rows with actual animation frames.

I've tried the version without alpha using additive blending and while it looked better than on jstubbles screenshot the effect doesn't really look great at the edges yet:

Code: [Select]
ANI 47 "fxwarp2" #BL_ADD #APM_ONCE 45 8 8
Code: [Select]
PARTICLE "Warp2"

    // 45 frames / 25 fps = 1.8 seconds playtime  
    duration 1.8
   
    SEQUENCE
        type 47
        fps 25
        startframe 0
        size 50 // no need for size adjustments, opening/closing of the wormhole/subspace/whatever is done in the texture
    END
   
END



Another (future) issue could be the fixed nature of the effect itself, depending on what you're going to do with it. It'll be hard to adjust the playing time of the warp effect without recreating the texture each time you need more frames. For the Freespace mod I had the luxury to create a looping warp effect, which allows me to keep the wormhole open for as long as I wish to. The opening and closing animation is done completely by a simple size adjustment in the particle effect definition (see first post). The texture in question would look like this:



Code: [Select]
ANI 40 "fxwarp" #BL_ADD #APM_LOOP 15 4 4
This gives you the advantage of just having to edit the particle effect to change the duration of the open wormhole or you could also create multiple different particle effects with different lengths all using the same texture. You're also not limited by texture size as much as before: a 2048x2048 texture can hold a maximum of 64 textures the size of 256x256... with the default playback speed of 25fps, this limits you to a maximum of 2.56 seconds of playback time. You can slow down the effect and gain some playback time by altering the fps-setting in the particle effect, but the lower you go, the less fluid the animation will look... and that's a very bad idea for big animations such as wormholes or warp effects. If you make it into a looping effect you won't have these issues, since the animation constantly repeats itself and you don't have to worry about opening/closing animation frames taking up valuable space. For example, the warp effect texture for the Freespace mod uses 512x512-sized animation frames, which give them just enough detail to look good even when being very close to the camera.

Only real disadvantage of a looping animation is, if you're going to need to have a visually complex startup or ending effect, which can't be done using size, rotation, color or speed adjustments in the particle definition in Nexus.

Offline Mularac

  • Lieutenant
  • ***
  • Posts: 531
  • Karma: 11
    • View Profile
(No subject)
« Reply #15 on: March 06, 2010, 15:22:41 »
-ok, it works like a charm now. Thanks guys!
A qustion: is it possible to set one range of the effect in a loop mode? from x to y frame, for instance.

Offline Arparso

  • Administrator
  • Lieutenant
  • *****
  • Posts: 558
  • Karma: 14
  • I can see you...
    • View Profile
    • http://arparso.de/nexus
(No subject)
« Reply #16 on: March 07, 2010, 21:35:09 »
I don't think so. :(

Offline jstubbles

  • Petty Officer
  • **
  • Posts: 169
  • Karma: 2
    • View Profile
    • http://www.ivassago.com
(No subject)
« Reply #17 on: March 17, 2010, 21:06:27 »
hey Arparso, have you ever gotten strange results from the xnview packing? For some reason, it's adding TONS of black space when I generate the texture mosaic sheet. It didn't do this before when I tried it, so I'm wondering if something is going on.

Offline Arparso

  • Administrator
  • Lieutenant
  • *****
  • Posts: 558
  • Karma: 14
  • I can see you...
    • View Profile
    • http://arparso.de/nexus
(No subject)
« Reply #18 on: March 18, 2010, 00:05:16 »
Yeah, I noticed that too. Seems to have something to do with the picture size. Try to make the resulting mosaic picture quadratic rather than rectangular. Alternatively you can choose to assemble the rows of frames for the resulting texture seperately by selecting "horizontal alignment" instead of "mosaic" in XnView. For example, if you've got an animation with 16 frames, which you intend to store in a texture in a 4x4 pattern (4 frames per row with 4 rows), then create 4 different horizontal rows with each set of 4 frames using this "horizontal alignment" option. Afterwards, create a new "strip of images" out of the 4 files you created, but this time using "vertical alignment"... now you've got your mosaic as well.

Offline The Old Dragon

  • Ensign
  • ***
  • Posts: 362
  • Karma: 6
    • View Profile
    • http://
(No subject)
« Reply #19 on: March 21, 2010, 20:17:19 »
Hi Guys,

Although it's not an animation, I was wondering if I could ask for some help  with an aspect of modelling?
Despite my best efforts, I've yet to figure out how to get some of the engine effects to work. Most notably, the way which engine surfaces glow and pulse.
Many thanks.
Better to look the fool by asking, then prove them right with ignorance.

Offline jstubbles

  • Petty Officer
  • **
  • Posts: 169
  • Karma: 2
    • View Profile
    • http://www.ivassago.com
(No subject)
« Reply #20 on: March 21, 2010, 20:25:58 »
I think it requires the object in question (the inside of the engine nozzle) to have it's own texture and material. That way you have the base texture of the engine and it's own luminosity map. So when the engines turn on, it fades the luminosity map on/off based on the engines functions. I'll try to do a test to confirm, but I think that's it.

Offline jstubbles

  • Petty Officer
  • **
  • Posts: 169
  • Karma: 2
    • View Profile
    • http://www.ivassago.com
(No subject)
« Reply #21 on: March 21, 2010, 20:52:15 »
I had another particle Q of my own.

How the heck do you edit the particle used for ship "combustion" ??? it's a simple glow sprite that spawns like pulsing wannabe fire, after a ship gets hit by a weapon. I tried modifying the only "ship combustion" particle in the PRT config, but that doesn't change a damned thing. It's a horrendously ugly effect and I want to get rid of it or change it somehow. For now I've just been disabling ship combustion in the main menu settings, but that's not a real solution.
Any help would be great, thanks!

Offline Arparso

  • Administrator
  • Lieutenant
  • *****
  • Posts: 558
  • Karma: 14
  • I can see you...
    • View Profile
    • http://arparso.de/nexus
(No subject)
« Reply #22 on: March 21, 2010, 21:12:52 »
Quote
How the heck do you edit the particle used for ship "combustion" ??? it's a simple glow sprite that spawns like pulsing wannabe fire, after a ship gets hit by a weapon.
If a ship gets hit by a weapon, there'll be two effects active: the "End" effect of the weapon and the "ImpactEfx" of the shipclass being hit. You should be able to find your offending glow in one of these two effects.

As for glowing engine exhausts: put the corresponding faces in their own material in Lightwave and append "@boosters" to the material's name. Then mask the glowing engine parts in a luminosity texture just as you'd do for any other glowing part of the ship. The game will figure out which faces to light up on its own (based on the faces' normals), so for example you can savely put all maneuver thrusters in the same "@boosters"-material, no matter the direction they're facing.

Offline Mularac

  • Lieutenant
  • ***
  • Posts: 531
  • Karma: 11
    • View Profile
(No subject)
« Reply #23 on: March 21, 2010, 21:29:11 »
The fire you see after a weapon is hit, although as ugly as it may seem is a pretty accurate display of how fire burns in zero-gravity: http://en.wikipedia.org/wiki/Microgravity

Offline jstubbles

  • Petty Officer
  • **
  • Posts: 169
  • Karma: 2
    • View Profile
    • http://www.ivassago.com
(No subject)
« Reply #24 on: March 21, 2010, 22:40:23 »
@Arparso - neither of those effects are what controls the "combustion" effect - I tried editing them with no success. :(

@Mularac - yeah....but it still looks like crap :P   I'm trying to get the effects to match the BSG show as close as possible.


**** EDIT ****
I edited the wrong mod's INI file, haha. That worked great Arparso - thanks! :D :D