Skip to content

Instantly share code, notes, and snippets.

@gdkchan
Last active April 16, 2024 15:40
Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save gdkchan/33405fc557d1f29c54906bae837a42de to your computer and use it in GitHub Desktop.
Save gdkchan/33405fc557d1f29c54906bae837a42de to your computer and use it in GitHub Desktop.

Introduction

This guide shows how to use texture replacement on Ryujinx. Keep in mind that the feature is WIP and is subject to change, so the steps might change in the future too.

Part 1 - PNG edit without mipmaps

First, we need to configure a path where the textures will be saved. Open the settings window by clicking on Options > Settings. Then go to the Graphics tab, scroll down and locate the field where you can place the textures directory path by scrolling down.

Ryujinx settings window

Right now the directory must exist, so make sure your path is valid and you created the directory (the emulator will not create it if doesn't exist yet). For the first part of this tutorial, I will be using the game Fire Emblem Engage. So I have created a folder called "fee_textures" on my HD, and set the path to "D:\fee_textures".

While we are still on the settings menu, it's good to take a look at the other options. The next option is the file format. There are currently two formats supported, DDS and PNG. There are a number of reasons that I will explain later to prefer DDS, but for the first part of this tutorial I will use PNG. The other two options are "Enable Texture Dump" and "Enable Real Time Texture Editing". The former does pretty much what is says, if you disable it, it will stop saving textures to the dump folder, so we should leave it enabled for now. The latter allows the emulator to apply modification made on the dumped texture file into the game while the game is still running, without requiring a restart. Let's also leave it enabled since it's quite useful.

Now let's launch the game. By the time it arrives on the title screen, you will notice there are a lot of images on the folder that we set now.

Fire Emblem Engage title screen

You'll notice there are also a lot of "versions" of the same image with different sizes. For those not aware, they are called mipmaps. Explaining exactly what they are used for is outside the scope of this guide, but basically the GPU selects which texture to use depending on the distance that the object has from the camera, and its Level Of Detail (LOD). Understanding them is important as you will also need to generate mipmaps when editing textures used on 3D models.

Now let's start editing something simple and easy to see. The "Fire Emblem" logo here on the title screen is a good candidate. First we need to locate it among all those textures, which might prove a little challenging since there's a lot of them.

Texture dumps folder

After scrolling quite a bit, I found the logo texture. Since it is just a 2D UI element, it does not have mipmaps (as you can see, there is no small "versions" of this texture like most of the other ones), so we don't need to worry about it for now.

Now let's open the texture on an image editing software. You could even use Paint if you wanted, but as it does not support images with transparency (it just pretends "transparency" doesn't exist), I will be using GIMP instead. But of course, you can use whatever you like, Photoshop would be even better.

Fire Emblem logo on GIMP

The texture is flipped. This is not really a common thing, but in this game they are flipped for some reason. Let's flip it vertically to make editing easier. To do that on GIMP, you can do Image > Transform > Mirror vertically. Pretty much any image editing software has similar functionality, even Paint, so this shouldn't be a problem at all.

Now I will do something simple, I will add "Deluxe" to the game name.

Fire Emblem logo edited on GIMP

Before we save, we need to flip the image again to make it like how it was before. After that we just need to click on File > Export and overwrite the PNG file.

Now let's go back to the emulator.

Fire Emblem logo edited on emulator

As you can see, the changes are already visible on the game! That's what the real time editing option does.

Part 2 - DDS edit with mipmaps

Now for the second part of this guide, let's switch the file format. For that, we stop the emulation and go to Options > Settings > Graphics, and then change it to DDS. Now let's clear our dump folder and launch the game again.

The first thing you will notice is that the amount of files on the dump folder is much lower, and that the smaller versions of the textures no longer exist. That is the main advantage of the DDS format. Because it was designed for textures, rather than just being a generic image format like PNG, it supports mipmaps so all of them are saved on a single file. It also supports 3D textures, cubemaps, array textures and compression! All of those would be saved as a separate file on PNG, and compressed textures would need to be decompressed.

Fire Emblem in-game on the emulator

Now let's try editing the clothes of the protagonist on the left side of the screen. First we need to find the texture. This can be a bit difficult if you don't know what it is supposed to look like, but it's basically something looking like her clothes.

Alear cloth texture on GIMP

Again, I will try to do something simple. I will change the blue and golden parts of the dress to green.

Alear cloth texture edited on GIMP

It's not perfect since I used an automated color swapping option that GIMP has, but it's good enough for this simple guide.

Now let's export the texture. DDS should have quite a bit more options than PNG.

GIMP DDS export options

There are two options you'll want to change here. The first one is compression. By default it is set to "None". It is recommended to set it to the same compression that the original texture had if possible. When in doubt, as a rule of thumb, you can use BC3 if the image has transparency, otherwise you can use BC1. BC2 also supports transparency, but it stores the data in a different way, so it might look better or worse compared to BC3 depending on the image, you might want to try both, but BC3 usually provides the best results. Since this texture has no transparency, I will just select BC1.

The second option is the mipmap option. If the original texture had mipmaps, you should select "Generate mipmaps", otherwise you should keep it on "No mipmaps". In this case, the original texture did have mipmaps, so I selected "Generate mipmaps".

Now we are good to go, we can click on "Export" and check the result in the emulator.

Fire Emblem in-game edited on the emulator

If you find that the compression artifacts are visible on the game, you can try exporting again without compression, but using compression if possible is recommended since it reduces memory usage. Keep in mind that there is people playing with 2GB VRAM cards even, so making the textures too large might make the mod unusable for them.

Final Part - Making the texture mod

After all the texture editing is finished, the last step is putting the edited textures in the proper mod folder. So once again, let's stop the emulation, go back to the games list, and right click on the game. Next, click on "Open Mods Directory" to open the mods folder for the game.

It will take you to a path called "C:\Users\YourUserName\AppData\Roaming\Ryujinx\mods\contents\0100a6301214e000" (this is for Windows, the path will be different depending on the OS, but it's the same idea). Next, let's create a folder for our mod. I will call it "green_alear". Inside that folder, create another folder called "textures". Now, copy all your edited textures inside that new "textures" folder.

After that is done, you don't need the dump folder anymore. In fact, you can delete it if you want. Go to Options > Settings > Graphics again on the emulator. Delete the texture dump path, leaving the field blank, just like it was before we started. Doing that not only disables texture dumping, but it will not try to load textures from the dump folder either, so all cost associated with that is eliminated.

It is possible to change the texture resolution, however as mentioned before, doing so is not really recommended due to the higher memory usage that higher resolution textures will cause. You will also notice that the file name of the texture contains the original resolution. If you do resize the texture, you should NOT change the resolution in the file name. The emulator uses it to find the correct texture based on the original texture parameters, so it is important that you don't change the file name. You can also change the amount of mipmap levels. When exporting as PNG, you can reduce the amount of mipmap levels by simply deleting the files for levels higher than 0.

Important considerations when making texture mods:

  • Those mods will never work on Switch hardware. If you want to make a mod compatible with Switch hardware, you should edit the original game assets inside the RomFS. You can still use emulator texture replacement for quick testing before you make the "final" version, since editing the game files is generally a lot more work and much more time consuming.
  • Be mindful of VRAM usage. Just decompressing and cranking up the resolution of all textures is a recipe for disaster. This is not an ancient console with tiny textures, so upscaling them will use a significant amount of memory, even for current standards.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment