Jump to content

How to extract the game's graphics/animations using Krane (KTools) and TEXTool


Garamonde
 Share

Recommended Posts

Hello there! This is going to be my first ever tutorial, so apologies if anything is unclear (though let me know if it is and I'll try to update this/help out!) or, in worst case, flat out incorrect. Let's jump in!

EDIT: Just wanted to clarify, this guide is only for extracting the sprites. It does not cover the process of recompiling the assets back into the game. I have linked the Steam post guide for that down further into the guide. Sorry, I just don't know how to do that personally and I apologize if anyone feels this guide is useless because of that lack of information.

So I've noticed a lot of people lately (including myself) struggling to do this, for one of 2 reasons (possibly more):

First, Krane's intended command prompt usage simply doesn't work, no matter how you do it

Second, the desired graphics/animations don't come with a corresponding anim.bin file

I have solutions to both of these problems (though maybe not perfect ones), so hopefully anyone else looking to do this and running into the same issues will be able to accomplish what they want to do. Alright, let's get started!

You'll need:

-KTools

-TEXTool

-A program that can open/extract .zip archive files

-An image editing program that supports transparency (this is really important)

1. First, you want to make sure you have KTools. Without this, you won't be able to extract any graphics or animations. The downloaded folder for KTools can be saved anywhere (though I recommend renaming the folder to simply "ktools". E.g. "ktools-4.4.4" changes to just "ktools") to avoid any errors. Also be sure you've downloaded the Microsoft Redistributable Package linked on KTools' download page to avoid errors as well.

2. Now you'll need TEXTool, which comes with Handsome Matt's set of tools. With this, you can extract the .tex files themselves in their "raw" state, just in case KTools doesn't extract the sprites correctly and you have to take the sprites from the texture atlas itself (more on that later).

3. Time to look for the sprites/animations you want to extract from the game. This works for both Don't Starve and Don't Starve Together, so it will work the same for whichever one you need. In this example, we'll want to go to [disk drive that has your Steam folder in it]\Steam\steamapps\common\Don't Starve Together\data\anim. So in my case, it would be D:\Games\Steam\steamapps\common\Don't Starve Together\data\anim, though it may be under C:\Program Files\Steam\steamapps\common\Don't Starve Together\data\anim for most people.

4. So, say you want to extract Wolfgang's sprites/animations. You would go to Wolfgang's .zip file (simply called wolfgang) located under the "anim" folder we just navigated to. Open that or extract the contents using whatever archive-opening program you have (I have WinRAR for example), You'll notice that it contains an "atlas-0.tex" and a "build.bin" file. Extract these directly into your ktools folder. ...But the .zip file doesn't have an "anim.bin" file! We need that in order for Krane to be able to extract the sprites and animations for us, so what do we do? Well, I discovered a solution to this through trial and error.

5. Now, we'll go to the player_idles.zip file, extract the anim.bin from that and place it, again, directly into the ktools folder along with your atlas-0.tex and build.bin files we just extracted from Wolfgang's archive.

6. Next thing we want to do will ensure that we can actually use Krane in the first place, because, as some of us know, trying to run it through command prompt simply doesn't work. So, we'll want to open our text editor (I use Notepad++, but plain old Notepad should work just fine) and create a new file. It can be named whatever you want (I named mine "slurtle" because I started testing this with Slurtle's files), but make sure that this exact code is pasted into the very first line of the text file:

krane anim.bin build.bin output_dir

And that's it! All we have to do now is save that text file as a .bat file in the ktools folder, again. This is a Windows Batch File which will run Krane as if it were an executable file. What that means is, we can simply double-click this .bat file and it will run Krane without having to go through command prompt! How exciting!

7. Now that all that's done, our folder structure should look exactly like this:

image.png.26e49e81edb9e8f656682dbc41847f6d.png

...with "slurtle" being our .bat file. Now, double-click on your new .bat file, and watch the magic happen!

image.thumb.png.7e01834c516ee7fefce9af0d9c374132.png

Look! It's not closing immediately like it would if you had simply tried opening Krane itself. Now, look what happened...

8.

image.png.78d5177f455e8460f7ab14324f11c431.png

That "output_dir" folder has all our newly extracted assets in it! Let's look inside...

image.thumb.png.5b40f52d904b144f482427715bbde01b.png

Hooray! If you made it to this point, you should now have your sprites in proper animation order!

9. ...But hold up. We looked in Wolfgang's "torso" and "torso_pelvis" folders, and something's not right here...

image.thumb.png.273662248d4ea875b3bd65aa311d715f.png

image.thumb.png.19498a428f73f7c07e08982ac402453e.png

They look kinda blurry and stretched, don't they? And they're the only sprites like that! Why did that happen? Well, to tell you the truth, I don't know why this happens. It just does with certain assets, even for entities that DO have all three matching anim, atlas, and build files. How do we fix it then? Well, I don't know of a "proper" fix yet, but I do know a workaround. It will involve TEXTool that I had you download earlier.

10. Go to where you downloaded and saved your folder for Handsome Matt's tools. You should see TEXTool and TEXCreator in there. TEXTool is what we want.

Now, once you open TEXTool, click the little folder icon to browse to where you saved your atlas-0.tex file. We will load this into TEXTool. So, once we load Wolfgang's .tex file, it will look like this:

image.thumb.png.295679c2af2b80d04b450c8b99430180.png

It looks like a total nightmare, doesn't it? Well, this is how the game stores its graphical assets. Good thing Krane automatically cuts these sprites out for us. So, we won't actually be doing much here aside from clicking the little floppy disk icon to save this texture atlas to wherever we want, as a .png file. Now comes the slightly tedious part.

11. Now, if you don't already have one, acquire that image editing program I mentioned. I personally recommend Paint.NET as it is free, supports transparency, and it suits all our purposes here just fine. Just please make sure you don't use MS Paint.

So, let's open our new atlas-0.png file in our image editing program.

image.thumb.png.d16303a20d9249099a6ca40fd3317a5c.png

As you can see, the atlas is quite a large image. This is all the sprites for Wolfgang at their proper resolution. Now, here comes the tedious part (though it's not that hard):

If using Paint.NET, you'll first want to click the paint bucket tool. Why? It'll just make our lives a bit easier when we go to pick the sprites we need out of the atlas. We aren't keeping this atlas anyway (unless you intend to change the actual sprites and put them back into the game, but that's not what this guide is for). Now, pick a gaudy color that sticks out from the sprites but won't burn your eyes. We'll pick a nice shade of pink for this.

image.thumb.png.eb6fca7c0b1a0634f8bc7bc58c94008b.png

Now, the left and right arrows point to the paint bucket tool and color palettes, obviously. But what's this middle part? That would be the Flood Mode, Fill Type, Tolerance, and Anti-Aliasing toggle. What does all this mean? I'll tell you!

First, make sure Flood Mode looks like an empty lightbulb as I have it (aka don't set it to "global"). "Fill" basically just changes the pattern you want to use for the paint bucket tool. So if you want it to only fill a grid pattern with our chosen pink, change that option. But for this purpose, keep it on Solid Color. Next, make sure Tolerance is all the way down at 0%. This is very important, because if it's at any number above that, it could mess up our sprites. Sampling isn't important and is difficult to explain, so for now let's just keep it on Layer. This next one is also very important. Right after the Sampling setting, make sure the little "connect the dots" icon is jagged like I have it in the screenshot, not curvy and smooth. This basically means, if you hover over it and it says that the paint bucket is set to "anti-aliasing enabled", then the pink color will blend into our sprites, and we do not want that.

Now, having all our settings the way we want them,, let's actually do it. Select the paint bucket tool with our color chosen and click in any space that has the white and gray checkerboard pattern. This is the image's transparency. It's what lets the sprites "hover" over other sprites and be see-through, without any background or color behind them. Let's see what happens when we do this:

image.thumb.png.a28084c95182e8cd50d3a06afd841ca9.png

Now, if you can still see little transparent "junk pixels" around the sprites, then you did it correctly. Alright, now here actually comes the tedious part. Use your select tool (click the little rectangle icon in the top left, or press the S key once) and carefully click and drag the selection rectangle around the sprite we want. In this case, we'll start with this torso sprite here as it is the first sprite frame in the "torso" folder (be sure to zoom in with ctrl + scroll up on the mouse wheel to make this easier):

image.thumb.png.0e3b426b686bcac0f2c2b2d3debc87d7.png

Now, press shift + s (or click the magic wand tool in your tool box on the left). Then, press alt + left click anywhere on the pink background to "snap" the selection to the exact boundaries of the sprite, like so:

image.png.4f2e67b292b6f6cf9402f0976823ec06.png

Now, press ctrl + X to cut the sprite out of the image. Then press ctrl + alt + V to paste this sprite as a new image. Like this:

image.thumb.png.6fb2c0547cee6b6eca08e67572869d6a.png

Save this sprite as a new image with ctrl + S. It will ask you where to save this sprite. You can either save it in another folder or you can overwrite the blurry export. Compare the difference between the sprites:

torso-0.png.4ed125cf1f8cb09adfdff6f4f1e5d65d.png

torso-00.png.b75a0631782a15cefe150bf252ea6b38.png

The bottom one from the atlas is the correct version of the sprite. Now you have to do this same process for the rest of the sprites that came out wrong (in Wolfgang's case, only the torso and pelvis came out wrong), using the blurry exports as reference for the animation order. Always be sure to check the exported sprites closely and, if they look off, compare them with those from the texture atlas itself to make sure they are at the correct resolution.

12. Congratulations! You now know how to export sprites in their correct animation order and, in some cases, fix the sprites that don't come out as they should and use them for whatever you want! Now, bear in mind that this probably won't work if you're trying to edit the sprites and re-insert them back into the game. However, there's a guide on that here.

I hope this helped! This is my first guide so I apologize that it's so long and wordy when it probably doesn't need to be. I just wanted to make sure I covered all the bases and didn't under-explain anything. If you encounter any problems or find anything I missed, please let me know and I will try to help as best I can!

~Garamonde

EDIT: Sorry about these last two images at the bottom of the post. I can't seem to remove them. They can be safely ignored though.

EDIT 2: If anyone has problems getting Krane to run, despite following this guide, try checking out this thread.

 

image.png

image.png

Edited by Garamonde
  • Like 4
  • Thanks 1
Link to comment
Share on other sites

On 3/6/2022 at 2:13 PM, Hyuyu said:

Heya,

Followed through the whole tutorial and once I get to the step of extracting it creates the folder but then instantly closes without having anything extracted.

 

Any idea ?

Hmm, I think I've had that happen to me before too, but it's been so long since I've done this I don't quite remember the details. Are you sure you have the right trio of files? Actually, what is it you're trying to extract?

Link to comment
Share on other sites

4 hours ago, Garamonde said:

Hmm, I think I've had that happen to me before too, but it's been so long since I've done this I don't quite remember the details. Are you sure you have the right trio of files? Actually, what is it you're trying to extract?

I fixed it by downloading an older version of ImageMagick, it was essentially just that the decompiler was too outdated for an actual version of the image maker. 

(Fyi : It was a wigfrid effect and had the files).

So my piece of advice is to go for a slightly older version of imagemagick then anyone can make it work.

  • Like 1
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...