• Sign up for the Black Forest 2v2 Tournament on Community Patch 1.6 RC and win a Voobly premium membership.     

    [ More Information ]

3.3 Porting graphics from Definitive Edition (old version)

We now look at the case where we want to port the graphic of a unit from Definitive Edition. This explanation is a bit outdated as Definitive Edition no longer uses ''.smx'' files but you could still find them in old builds of the game or from other visual mods. The new way to port graphics is covered in the next section.

We’ll use the Coustillier as an example. This guide will cover the angle count, the reduction on the number of frames, the recoloring and reduction of the shadow and the generation of data graphics.

The same process is used for buildings, although without having to worry about angles.

1. Locating graphic files from Definitive Edition.​

Graphics in Definitive Edition follow a similar path as in AoE II HD. That is “AoE2DE\resources\_common\drs\graphics”. In there you will see a bunch of .smx files. This folder is easier to navigate since the names are self-descriptive.

The one we are going to use as an example is “u_cav_coustillier_walkA_x1.smx”, which corresponds to the coustillier walking.

Open SLX Studio and drop the .smx file in it. SLX Studio will load all the individual frames and display them.

porting1-800x450.png


2. Angles and frame count​

In order to work with the .smx file, SLX Studio needs to save it as an .slx file. This implies saving each frame individually as a bmp file, both the graphic and the data.
But before we do that, we can greatly reduce the number of frames of the graphic to ease up this process. This is due to two factors:
  1. Definitive Edition graphics use 16 angles, that is, 16 directions the unit faces. On the other hand, AoC uses 5 angles and the mirror mode to mimic all directions. This means that two thirds of the frames are not needed.
  2. Definitive Edition uses way more frames to ensure smoother animations. Of the valid angles, we will delete several of them to accomodate the number of frames programmed in AGE.

2.1 Angles​

Let’s delete the unnecessary angles. First of all, note that the Coustillier file has 481 frames. It’s common in Definitive Edition files that the first and last frame are actually the same. It’s easily identifiable if the total number of frames is not divisible by 16. Select the last frame and, on the left panel, click “Delete” and “Apply”. This will put the frame count in 480 frames, which means 30 frames per angle.

This step of having a number of frames divisible by 16 is important so that the next one works out. Go to “Edit/Multi-Select Frames”. This is a dialog box to automatically select a bunch of frames. The field “Per Direction” is at first set to 1. If you change it to 16, you’ll see the field fpd (Frames Per Direction) is 30. Leave the field “Select Every” to 1 and in “Skip Directions” write “5, 7, 9, 11, 13”. This will select all frames in every direction, except for directions 5, 7, 9, 11, 13, the ones used in AoC.

Press “Apply” and let the program select the desired frames. All these are frames we don’t need so you can delete them as you did before. Once that’s done, we have only 150 frames remaining.

2.2 Frames per angle​

If we look at the data for this graphic in Advanced Genie Editor, Sprite 80, we see that it’s programmed to have 20 frames per angle, not 30. If we were to create the slp like this, the displayed frames would not align to the direction the unit is facing, we have to set them to exactly 20 frames per angle.

To do this we use again the “Multi-Select Frames” tool. This time, we leave the fields “Per Direction” and “Skip Directions” empty, and use only the “Select Every” field. There is no exact formula for the following, as the number of frames in Definitive Edition and in the AGE code vary a lot. The idea is to select the frames in an evenly spaced manner so as to hide the fact the we deleted some when the animation is played.

In our particular case, we need to go from 30 frames per angle to 20, that is, delete 10 out of every 30. This can be done by selecting every 3rd frame with the “Multi-Select” tool, which will select a total of 50 frames evely spaced across the animation. When we delte them, we end up with 100 frames, exactly the 20 times 5 we needed.

2.3 Save the .slx file​

Once we have reduced the frames to the necessary amount, we can save the file. The best practice is to save it in a folder for itself, as you are still going to create 200 bmp files for the graphics and data.

3. Color and shadow correction.​

The next step covers two aspects of the port. First, it converts the bmp files of the graphic to the palete AoC uses, so that when we create the slp files, the colors are correct. Second, it will reduce the shadow of units. Shadows in Definitive Edition have various levels of gray, so as to get a smooth look. However, AoC only has one shade of gray for it. If we were to leave the shadow as it is in the port, we would end up with very obstrussive shadows. Because of this, we’ll modify the shadows and only keep the darkest part.

Go to “Tools/Color Replace Graphics”. The window that opens lets you modify the color of images. Note that in the bottom it already has the palette “Standard Graphics” selected, so it will apply the palette automatically. What we need to use is the section “Replace Color”; there we can choose a “Source Color” to replace, a “New Color” to replace with and a “Tolerance” for similar colors to the source one. When you select a combination of these parameters, click “Add” to put it on the list bellow. The ones that you need to create are the following:
  • AA2F9B to FF0000, 20% tolerance.
  • 850C79 to FF0000, 20% tolerance.
  • 4F004B to FF0000, 20% tolerance.
  • D33AC9 to FF00FF, 20% tolerance.
You can save this configuration as a .csv file, as you will always use the same.

porting2-1200x675.png


Now apply the color replace TWO times. The first one almost does nothing, as it barely detetcs the specified colors, but does apply the color palette and thus changes the colors to the ones the color replace will identify in the second pass.

Once this is done, you will see that the units have a red shadow smaller than before. The reason for it being red is so that the data graphic creator of the next step recognises it as shadow.

Save the file to overwrite the images.

4. Creating data graphics.​

Now that we have corrected the shadow in the graphics, we need to recompile the data graphics, as the red pixels in it are what will create the shadow in the end. Also, we need to add the outline around the unit for when it passes behind buildings.

The problem with recompiling data graphics is that we may loose the green player color pixels, that identify the changes in color of the unit depending on the owner. For this problem, there are two options:
  1. Save the data graphics under a different name so that SLX Studio doesn’t replace them. Then, when you create new data graphics and erase the player color, you still have the original ones to copy those pixels back to the newly generated data graphic. This method requires a way of copying only green pixels and do it automatically for all the frames but preserves the exact same pixels.
  2. Have SLX Studio detect the “blue” pixels and treat them as player color pixels. This option is subjected to the actual colors in the image and the tolerance, and is unlikely that you will get the same result as the original version. However is simpler to do and will cover all frames.
We’ll use option 2 here and mention how to use option 1 at the end of this chapter.
Go to “Tools/Generate Data Graphics”. This tool covers the detection of background, the detection of shadow, the player color and the outlines. Let’s go bit by bit:
  • The Mask section detects the pink pixels as background and will omit them from the graphic. Set the tolernce to 20%.
  • The Shadow section detects the red pixels as shadow and will paint them gray. Set the tolernce to 20%. Note that there is also the option of “Split Shadows”; this creates the shadow in a different file and is uses for buildings like castles and walls.
  • The Player section detects all the pixels that should change color with the owner. Here do the following:
    • Set the tolerance to 30 %.
    • Load the preset [Blue] AoE1.
    • Add two more colors to the preset: 0000FF and 004ABB.
  • The Outlines section will draw the outline around the unit. It should not be used for buildings and for corpse units. Mark the option “Draw outlines” and “Player only”.
Once all that is done, apply the changes. The program will detect the necessary pixels and regenerate the data graphics. Save the file to overwrite the images.

porting-1200x781.png


5. Exporting the graphics.​

Now that the graphics have the correct palette and data graphics. We only need to export them. Go to “File/Export” and select the option “AoE2/SWGB Standard 2.0N SLP File (*.slp)”. SLX will ask you again about the palette, leave Standard_Graphics. This will create an slp that you can open with Turtle Pack.
It only remains to set the name of the file to the slp number written in AGE (175054.slp in the case of the Coustillier) and move it to the drs folder of the mod.

Batch processing​

SLX Studio also has the option to batch process several graphics in one go:
  1. “Graphics/Batch Extract SMX to SLX” will convert all the .smx files in a folder into .slx ones, creating a folder for each one. You’ll have to manually go over them and delete extra frames if necessary but it’s useful for buildings.
  2. “Tools/Batch Image Color Replace” will replace the color of all the graphics. It works exactly as the “Color Replace Graphics” tool.
  3. “Tools/Batch Generate Data Graphics” will create the data graphics. This one is more tricky as it’s bugged. You need to set the options in the single “Generate Data Graphics” tool and then move to the batch version, the configuration will remain. Once the process finishes and you close the tool, SLX studio will freeze so you need to close it through the Task Manager.
  4. “Graphics/Batch Convert SLX to SLP/Standard 2.0N SLP” will export to .slp files all the .slx files in a folder.

Handling the color pixels​

The option for detecting color pixels in the “Generate Data Graphics” tool doesn’t give too good results. As I’ve mentioned before. One way around it is to save the original data graphics before SLX studio replaces them and not generate player color pixels. This leaves you with two sets of data graphics: the new ones with small shadow and outline but without color pixels, and the old ones with big shadows, no outline but with color pixels. Now it’s a question of only copying green pixels from the old data graphics to the new ones.
As far as I know, I’ve come up with two solutions to this, use Paint or a script.

Color pixels with Paint​

This method uses the “transparent selection” functionality of Paint:
  1. Open both the original and new data graphics with Paint.
  2. Select the whole new data graphic, copy it and paste it into the original data graphic. This will momentarily hide the original data graphic completly.
  3. On the “Select” option, select “Transparent Selection”. This will make Paint ignore white pixels from the new data graphic and the green pixels from the image bellow will appear.
This process still requires changing images frame by frame.

porting3-600x449.png


Color pixels with a script​

A script can handle all the graphics in a folder in a single go. I created a function in Python that takes two images, goes over the pixels and copies green pixels from one to the other. We used it for creating all new architecture and units.
The following code covers the needed module and the function itself. You will need to add the code that goes over all the images in a folder but, if you know your way with programming, this shouldn’t be difficult.

Code:
#This module lets Python handle images
from PIL import Image

#Function to copy the color pixels (green in the data file) to the new data file
#As inputs, it receives the two file paths
def data_graphics(original_name,new_name):
    #open both files
    original = Image.open(original_name)
    new = Image.open(new_name)
    #get the size of the image
    (w,h) = original.size
    #go over all pixels in the image
    for i in range(w):
        for j in range(h):
            #if the pixel in the original one is green, change it in the new one
            if original.getpixel((i,j)) == (0,255,0):
                new.putpixel((i,j),(0,255,0))
    #save the modified image
    new.save(new_name)

Brighter images​

Appart from all the stuff explained in this guide, katsuie also worked on making the unit graphics brighter. I wasn’t part of the process but, as far as I understood, he kept a copy of the original images. After the whole process described here, he had the original graphics (with 24 bit color and not the palette) and the modified data graphics. He then corrected the images with imagebatch, making them brighter, and after that, he compiled the slp. This way, he had 24 bit color image right until the end. If you want to know more, write to any of us (Pancrol or katusie) and we’ll share more details.
 
Last edited by a moderator:
Copyright © 2009 - 2026 Member Plus Headquarters. All rights reserved.
This website was created by volunteers of the Member Plus Program and is not affiliated with Voobly.
Back
Top Bottom