Jump to content

[GUIDE] Modding Practices: Introdution to Atlas and .Tex Files

Recommended Posts

[CH 03] Introduction to Atlas and Texture Files
In this chapter you will learn how to create an atlas (.xml) file and their associated texture (.tex) file. You will learn the basics of how to set up the atlas file and how to properly assign the regions associated inside the texture files. You do not need special software to create the atlas files, however, you will need special software to create the texture files.
Required Conversion Software
Both of these software's have README files which it is highly recommended to read them before attempting to create any texture file.
What is a .tex file?
A .tex file is a texture file which holds images which will be used by the Don't Starve engine. A .tex file must be used in conjunction with an atlas file.
What is an atlas file?
An atlas file is a special .xml file which contains information about the .tex file. The information which is contained in the file is the texture name, the region of the texture and the file in which the textures are located.
Creating your first .tex file
In order to create your first .tex file you will need to create an image file, specifically a .png which has a transparent background. This may be done with your favorite photo or image editing software. When creating your file, it must have a power of 2 dimensions; that means it must be 8x8, 16x16, 32x32, 64x64, 128x128, 256x256, 512x512, or 1024x1024. Any other size and you will receive warnings or errors about it being the wrong dimensions.
Note: Any combination of width or height specified above may be used with each other, however, it is recommended to keep the file the same width and height.
After you've created your .png file open your preferred conversion software and convert the file to a .tex file.
Congratulations, you've successfully made your first texture file.
Creating your first atlas file
An atlas file is simply an .xml file which denotes the placement of regions for the images within the .tex file. Below will be a sample of a generic atlas file.
    <Texture filename="modicon.tex" />
        <Element name="modicon.tex" u1="0" u2="1" v1="0" v2="1" />
Inside the atlas file we can see that we denote the texture filename and the element name. u1, u2, v1 and v2 are point of references inside the texture file which will denote the region of the image.
  • u1 represents the left side.
  • u2 represents the right side.
  • v1 represents the bottom.
  • v2 represents the top.

Please note that the coordinates are a percentage measurement; this means that 1 is equal to 100%. The V coordinate measures from the bottom to top and the UI coordinate measures from left to right.

Note: For each additional element you will need a new <Element /> line. Each element must be named after a texture which it is representing. That means it needs to end in ".tex", example, rope.tex, car.tex, ground.tex, etc.
With the above information we learned how to create proper texture files and their associated atlas files. From here we may create more complicated texture files which house multiple images or we make create many small texture files which only house 1 or 2 textures.
Please post any questions, concerns or suggestions below.
MidrealmDM for explaining the atlas file.
Alternatively you can use this software provided by myself on the workshop: Texture and Atlas Packer
Edited by Kzisor
Link to comment
Share on other sites

How to create complicated texture files? For example, I want to combine 15 images 64x64 each. What software do I need? Just a calculator and notepad++ ? :)



One more question. Very often I see atlas:

u1="0.0078125" u2="0.9921875" v1="0.0078125" v2="0.9921875"

​This is standard numbers for single 64x64 image. But why? Why not u1=0 u2=1 v1=0 and v2=1? Also, the game engine uses these or similar numbers.

P.P.S. This guide should be pinned.

Link to comment
Share on other sites

@Maris, to answer your first questions, that all really depends on how good at math you are...as far as applications there are applications on the internet, but they do not create them for Don't Starve or Don't Starve Together. They will combine the image into a single file much like you can do with Photoshop, but the file map will be wrong.


To answer the questions about why you use the exact location instead of relative location is simply to save memory. When the atlas file is loaded back into the game the equation is looking for that specific location and thus you will use less memory if you're exact.


The guide can easily be found using the search function, there is no reason to clutter the stickied topic area's with guides.






All Hallows Eve images in a single .tex and .xml file.


Edited by Kzisor
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

  • Create New...