Jump to content

New Asset Tools: Animations, Textures, Sounds And Layouts!


Ipsquiggle
 Share

Recommended Posts

  • Developer

ALPHA WARNING
 
All these pipeline tools are still in development and may undergo serious changes before they are ready. So don't be surprised if things break or don't work at all, and be prepared for changes with the next release.
 
We'd also love your feedback about how they could be made better and reports for any bugs you find!
 
Also note that for the time being, this process is Windows-only. Your mods will work on all platforms but the pieces can only be compiled on Windows.
 
The alpha tools are only on the preview release of the mod tools. Switching to this version of the tools is the same process as switching to the preview version of the game:

  • In Steam go to Library > Tools.
  • Right-click on "Don't Starve Mod Tools" and choose Properties.
  • Go to the Betas tab and select 'publicpreview'.

Demonstrations of each of these features can be found by downloading the "preview" versions of the sample mods.
 
Animation Pipeline


Download Mod tools and run Spriter. (You can also get the free or pro version from the Spriter website, but we include Spriter with the game as a convenience.)
 
Put all your PNGs in a folder inside mods/<yourmod>/anim/, and maybe subfolders if you want to easily “swap” them in spriter (i.e. different hand poses)
 
Make some sexy animations
  • Name things the right things!
    • The Spriter filename is the “build”
    • The “Entity” (top level in Animations panel) is the “bank”
    • The sub-entries in the Animations panel are the “animations”
  • One frame in Spriter is 1ms, so 1000 frames is one second of animation.
  • The big crosshairs in the main window points to the root of the animation. This is where your anim “touches the ground”, where the shadow will appear, etc.
  • More detailed tutorials on actually using spriter and creating cool animations coming soon! Plus there’s lots of stuff on the internet.

Once your animation is made, run the game! If: You have Don’t Starve Mod Tools installed, and, you have an .scml file in your mod with its .pngs beneath it, then it will automatically be converted into a correct asset when the game starts up.
 
If there are any errors they will pop up in a Notepad window, and appear in a .txt file next to your .scml file.

-- Example prefab filelocal assets={    -- always have to declare what assets you're loading and using    Asset("ANIM", "anim/anim_test.zip"),  -- same name as the .scml}local function fn(Sim)    local inst = CreateEntity()    local trans = inst.entity:AddTransform()    local anim = inst.entity:AddAnimState()    anim:SetBank("anim_test_bank") -- name of the animation root    anim:SetBuild("anim_test")  -- name of the file    anim:PlayAnimation("anim0", true) -- name of the animation    return instendreturn Prefab( "common/anim_test", fn, assets)

If you want to add new animations or make changes, just edit the Spriter project and run the game again. Your changes will be detected and compiled.


 
Texture Pipeline

Put your .png files anywhere in mods/<yourmod>/images/ or mods/<yourmod>/bigportrait/.
 
Run the game. Your .png will automatically be compiled into a .tex file and .xml atlas ready for use in-game.
 
-- Example prefab filelocal assets={    -- always have to declare what assets you're loading and using    Asset("ATLAS", "images/image_test.xml"),  -- same name as the .png    Asset("IMAGE", "images/image_test.tex"),  -- same name as the .png}local function fn(Sim)    local inst = CreateEntity()    local trans = inst.entity:AddTransform()    -- inventory images are one thing that uses custom textures    inst:AddComponent("inventoryitem")    inst.components.inventoryitem.atlasname = "images/image_test.xml"    -- in this case the texture name is automatically guessed from the prefab name    -- but in some cases you would have to specify the texture name as well.    return instendreturn Prefab( "common/image_test", fn, assets) 

Once it’s all hooked up, if you ever update your .png, just re-run the game and the changes will be detected, automatically recompiling the atlas!


 
Sound Pipeline

Get/Install/Run FMOD Designer. Note that this is a very complex and powerful program, but we only need to use a small portion of it to get sound going in the game. Also bear in mind that almost everything of use is in right-click menus, or in the properties panel that appears along the right side, so be sure to check those places if you’re hunting for a command.
 
Across the top are 4 “sections”, Events, Sound Defs, Music, Banks. You only need to use the Events section.
 
In the Groups tab, right-click in the blank space and choose “Add Event Group”, then right-click on that and choose “Add Simple Event”.
 
Right click in the playlist and choose “Add Sound” and choose your favourite sound file!
 
While we’re here, right-click on the Simple Event you created (in the Groups tab) and choose “copy path”. This copies the full name of the sound event, you’ll need this later.
 
In the top menu, choose Project > Build and hit Build. A couple new files will be created in a ‘sound’ folder in your mod, a .fev and a .fsb. And that’s what we need! Now the sounds are ready to load in the game.
-- Include the new sounds in either your mod assets or prefab assetsAssets = {    Asset("SOUNDPACKAGE", "sound/soundproject.fev"),    Asset("SOUND", "sound/soundbank.fsb"),}-- You can directly overwrite any sound event we are using. Put this in modmain.RemapSoundEvent("dontstarve/creatures/bat/flap", "soundexample/creatures/bat/pop")-- Alternatively, you can use your custom events directly in a prefab or stategraph:inst.SoundEmitter:PlaySound("soundexample/creatures/bat/pop")

FMOD Designer can be intimidating but just stick to the basics and you'll be okay.


 
Static Layouts

Install and run Tiled.
 
Copy and rename the sample static layout. Getting Spriter configured for each project can be a pain and it's easiest to just copy an existing layout to a new name/location and then modify it to suit your needs.
 
Open and edit your layout in Tiled.
  • You can adjust the width and height of the layout, but you should always make them square (i.e. the same width and height) and even (2, 4, 6, 8…)
  • If you place a water tile it will definitely be water. If you erase a tile so it's "blank" then when the layout is placed in-game it will be whatever tile was there previously. This is useful for giving softer or uneven edges to your layout.
  • When you place an object, the size of the box doesn't matter, only the midpoint of the box.
  • The name of an object is the name of the prefab you want to spawn there.
  • The tile layer must be called BG_TILES and the object layer must be called FG_OBJECT.

When your layout is ready, save it, and then choose File > Export As. For the filetype choose "Lua files (*.lua)". (Note that there are two .lua options, choose the Lua files option.)
 
Export the file to the scripts/map/static_layouts folder in your mod.
 
In modworldgenmain.lua (not modmain.lua!) add these lines:

local Layouts = GLOBAL.require("map/layouts").Layoutslocal StaticLayout = GLOBAL.require("map/static_layout")-- Give your layout an in-code name and point it to the exported fileLayouts["MyCustomLayout"] = StaticLayout.Get("map/static_layouts/mycustomlayout")-- Add this layout to some rooms or levels.-- In this example it's added to every "forest" room in the gameAddRoomPreInit("Forest", function(room)    if not room.contents.countstaticlayouts then        room.contents.countstaticlayouts = {}    end    room.contents.countstaticlayouts["MyCustomLayout"] = 1end)

The next time you generate a world, there should be new layouts in the woods!

  • Like 14
Link to comment
Share on other sites

Does the texture pipeline essentially eliminate the need for TEXTool? Or am I getting something wrong here?

 

EDIT: Also, are we ever going to see this compatible with Mac? I got all excited when I saw this, thinking I could get into doing things other than tweaks, before I saw the "Only for Windows" part.

Edited by Delta/V
Link to comment
Share on other sites

Useful tools, even if Windows-specific and proprietary. I'm glad Up and Away is a team effort.

 

At least Tiled is open source, though. It's even in the official repositories of my Linux distro, typing one line in the terminal was enough to install it.

 

So there's no way to edit (decompile) an existing anim?

 

And what are the parameters for this automatic TEX generation? Which resizing filter is used, Lanczos? And what will be the target pixel format, DXT5?

Edited by simplex
Link to comment
Share on other sites

  • Developer

Does the texture pipeline essentially eliminate the need for TEXTool? Or am I getting something wrong here?

 

EDIT: Also, are we ever going to see this compatible with Mac? I got all excited when I saw this, thinking I could get into doing things other than tweaks, before I saw the "Only for Windows" part.

 

Yes, TEXTool should hopefully be obsolete now. :)

 

And as far as cross-platform: This is basically a duplication of our own asset pipeline, which in the studio here is windows-only. It's kind of hairy and we don't even know at this point what would be involved in porting it, let alone whether it's feasible. I would of course love for everyone to have these tools, but it's just not a promise I can make right now.

 

But as Simplex mentioned, Tiled is cross-platform, and its output is directly used by the game so you can do that on any platform. In addition, Spriter has Mac and Linux versions for you to play in, I'm sure if you made some sweet animations someone would be able to export them for you.

 

 

Useful tools, even if Windows-specific and proprietary. I'm glad Up and Away is a team effort.

 

At least Tiled is open source, though. It's even in the official repositories of my Linux distro, typing one line in the terminal was enough to install it.

 

So there's no way to edit (decompile) an existing anim?

 

And what are the parameters for this automatic TEX generation? Which resizing filter is used, Lanczos? And what will be the target pixel format, DXT5?

 

It uses our own asset pipeline, so it uses whichever settings our own assets would use. There was a lot of concern and confusion over the various parameters and options which TextureConverter and TEXTool provided, when in fact there's usually only one right option for any given asset. BC3 or ARGB will be used as appropriate, and I'm not sure which filter method we use, though it's the one we use so at the very least you'll be consistent. ;)

Oh also the sample mods have been uploaded. :)

http://forums.kleientertainment.com/index.php?/files/file/202-sample-mods/

Link to comment
Share on other sites

And as far as cross-platform: This is basically a duplication of our own asset pipeline, which in the studio here is windows-only. It's kind of hairy and we don't even know at this point what would be involved in porting it, let alone whether it's feasible. I would of course love for everyone to have these tools, but it's just not a promise I can make right now.

Wouldn't you consider releasing them under an open source license, so we can port them ourselves? (by the way, I did write a TEX converter for Linux/Mac) Edited by simplex
  • Like 1
Link to comment
Share on other sites

Sad to hear that a Mac version of all this neat stuff seems unlikely... but at least I can try out spriter, even if I can't convert the things to an in-game state.

 

 

So, if I'm reading this right, we need to have each animation symbol as a separate image file... and those are imported into spriter... is there no way to use existing character assets? For example, to add a new item, and give the player an animation for that?

 

(I'm really hoping there's a way to switch the animation to a more manageable framerate, too. 1000fps is ridiculously unnecessary. I prefer working at 24, but I suppose 60 will be necessary. Still, 1000 is quite a large deal greater than 60! x.x; )

Link to comment
Share on other sites

(I'm really hoping there's a way to switch the animation to a more manageable framerate, too. 1000fps is ridiculously unnecessary. I prefer working at 24, but I suppose 60 will be necessary. Still, 1000 is quite a large deal greater than 60! x.x; )

The game runs (ideally) in 30 fps. 24 fps is too cinematographic for a game, c'mon! ;] Edited by simplex
Link to comment
Share on other sites

The game runs (ideally) in 30 fps. 24 fps is too cinematographic for a game, c'mon! ;]

I was a film student - of course I prefer working at a film framerate! xP

30 isn't too bad - most games run at 60, to my knowledge, but if it's 30, I'll stick to that.

 

As long as it's not 25fps. Bloody PAL TV-standard... such a nightmare...

Link to comment
Share on other sites

Sorry for the newb question, but i just created a Steam account (even though i hate steam) and installed my third (!!!) version of DS on one pc (don't ask), just to find out you need to have a beta key to have access to the publicpreview modtools! Where can i get one, if i can get one?

 

Nevermind... I think it's downloading without a beta code(?!?)...

Posted Image

Edited by lifemare
Link to comment
Share on other sites

Sorry for the newb question, but i just created a Steam account (even though i hate steam) and installed my third (!!!) version of DS on one pc (don't ask), just to find out you need to have a beta key to have access to the publicpreview modtools! Where can i get one, if i can get one?

There isn't one. Just hit enter.

 

Or did I misunderstand? o.o

 

Useful tools, even if Windows-specific and proprietary. I'm glad Up and Away is a team effort.

 

At least Tiled is open source, though. It's even in the official repositories of my Linux distro, typing one line in the terminal was enough to install it.

 

So there's no way to edit (decompile) an existing anim?

 

And what are the parameters for this automatic TEX generation? Which resizing filter is used, Lanczos? And what will be the target pixel format, DXT5?

I've got Windows. So if any collaborators need things converted, etcetera, I can give it a shot. Unless of course they become open source and cross-platform! (Even then, still, of course.)

Edited by debugman18
  • Like 3
Link to comment
Share on other sites

Useful tools, even if Windows-specific and proprietary. I'm glad Up and Away is a team effort.

 

At least Tiled is open source, though. It's even in the official repositories of my Linux distro, typing one line in the terminal was enough to install it.

 

So there's no way to edit (decompile) an existing anim?

 

And what are the parameters for this automatic TEX generation? Which resizing filter is used, Lanczos? And what will be the target pixel format, DXT5?

I've got Windows. So if any collaborators need things converted, etcetera, I can give it a shot. Unless of course they become open source and cross-platform! (Even then, still, of course.)

Link to comment
Share on other sites

I've got Windows. So if any collaborators need things converted, etcetera, I can give it a shot. Unless of course they become open source and cross-platform! (Even then, still, of course.)

We should stop stealing this thread. Most of what's been said here was about Up and Away. xD
Link to comment
Share on other sites

@Ipsquiggle

Let's see if I got this correctly, regarding builds and anims (based on this and that).

The base (final, "atlased") image is UV space, and the build defines how to map rectangular regions of UV space into XY space. Put precisely, it defines a set of affine transformations from UV space to XY space*, one for each frame of each symbol, of the form

Posted Image

where (x0, y0) is a constant vector, D is a diagonal matrix (i.e., scaling, possibly anisotropic) and (u0, v0) is the center of the current rectangular region in UV space being mapped.

Then the animations define general affine transformations from XY space to itself** (an affine endormorphism, if you will), each having the range of one of the "build maps" above as their domain (which is done first, the translation or the linear transformation, as they are specified in build.bin?). Finally, the result is translated by the entity's position.

* I'm ignoring frame durations here. A more accurate statement (if I got this correctly) is that subsets of UV space are being mapped onto prisms of XYT space, T being time.

** Again, I'm ignoring depth, to stick to the basics.

Edited by simplex
Link to comment
Share on other sites

  • Developer

Sad to hear that a Mac version of all this neat stuff seems unlikely... but at least I can try out spriter, even if I can't convert the things to an in-game state.

 

 

So, if I'm reading this right, we need to have each animation symbol as a separate image file... and those are imported into spriter... is there no way to use existing character assets? For example, to add a new item, and give the player an animation for that?

 

(I'm really hoping there's a way to switch the animation to a more manageable framerate, too. 1000fps is ridiculously unnecessary. I prefer working at 24, but I suppose 60 will be necessary. Still, 1000 is quite a large deal greater than 60! x.x; )

 

As far as assets: For now this pipeline works best for original animation. We're looking at ways to allow easy altering or extending of existing animation sets, but that won't be happening for this week's alpha release. There are also some features concerning build swaps and things of that sort that aren't fully supported yet, but if there's anything you'd really like to see let us know so we can prioritize it! :)

 

 

The terminology in Spriter is unclear: Those are milliseconds. Technically, it allows you to specify a keyframe on any given millisecond. This means 1000 positions per second, which in a weird way can be called "1000fps". But in fact, the game plays animations at 30fps so you don't need to be more aggressive than that.

 

I know that using 30's or 24's can be more natural for animators, but Spriter has chosen keying on milliseconds, for better or worse. If it helps, here's a cheat-sheet between 24fps and 1000fps:

1: 42

2: 83

3: 125

4: 167

5: 208

6: 250

7: 292

8: 333

9: 375

10: 417

11: 458

12: 500

13: 542

14: 583

15: 625

16: 667

17: 708

18: 750

19: 792

20: 833

21: 875

22: 917

23: 958

24: 1000

 

25: 1042

26: 1083

27: 1125

28: 1167

29: 1208

30: 1250

31: 1292

32: 1333

33: 1375

34: 1417

35: 1458

36: 1500

37: 1542

38: 1583

39: 1625

40: 1667

41: 1708

42: 1750

43: 1792

44: 1833

45: 1875

46: 1917

47: 1958

48: 2000

And for 30fps:

1: 33

2: 67

3: 100

4: 133

5: 167

6: 200

7: 233

8: 267

9: 300

10: 333

11: 367

12: 400

13: 433

14: 467

15: 500

16: 533

17: 567

18: 600

19: 633

20: 667

21: 700

22: 733

23: 767

24: 800

25: 833

26: 867

27: 900

28: 933

29: 967

30: 1000

 

31: 1033

32: 1067

33: 1100

34: 1133

35: 1167

36: 1200

37: 1233

38: 1267

39: 1300

40: 1333

41: 1367

42: 1400

43: 1433

44: 1467

45: 1500

46: 1533

47: 1567

48: 1600

49: 1633

50: 1667

51: 1700

52: 1733

53: 1767

54: 1800

55: 1833

56: 1867

57: 1900

58: 1933

59: 1967

60: 2000

Link to comment
Share on other sites

What I would most like to see is the ability to add new animations to existing things. Like, for example, adding a dance animation to the player character.

I imagine you would then have to get into stategraphs, and all that tricky stuff, to add it, and figure out a way to make it start... but definitely, the first thing I would like to see is the ability to take an existing asset, and add a new animation, or tweak an existing one.

 

It's also not quite clear to me how animating an equippable item works... so I'd definitely need some more information, when that is possible.

Link to comment
Share on other sites

  • Developer

Let's see if I got this correctly, regarding builds and anims (based on this and that).

 

It sounds like you've got it right though I've never expressed it in those terms so I may be overlooking. How I would phrase the process:

 

Prior to being processed by the buildanimations.py script, the build specifies the size and offset of a symbol, an anim keyframe specifies a transform matrix for a symbol. An animated object is a clump of quads of those particular sizes in the build, which are first offset by the value in the build (to change the reference point), and then further transformed by the animation. The quad is then UV mapped to a subtexture in its atlas, but that has nothing to do with the transformation of the geometry.

 

The script crunches down some of that directly into build.bin but that's the gist of it.

 

(Note: in actually a symbol's geometry is a cluster of triangles somewhat fitted to the graphic, but in terms of understanding the values in build and anim, think of them as quads.)

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

×
  • Create New...