Post by Josephine 'Pidge' Tremblay on Jan 30, 2024 3:39:40 GMT
CK's Guide to Fixing Pixelated Horse Coats
Originally posted on The Equestrian Sims Discord & Tumblr!
Above: before-and-after pictures of this process. Thank you to @cloudywithachanceofsims, @silverthornestudfarm, and @blueridgeequines for giving me permission to use their coats as examples!
As we all know, every time you paint a horse (or any pet or werewolf, really) in Create-a-Pet, it inevitably gets pixelated. This is due to the TS4 engine's compression of Sims textures, which it does to theoretically save on file space and load time. The more you paint on your horse (and the more you save it over and over again), the greater the artifact damage becomes, until you're left with a pixelated mess.
Luckily, I've figured out a way to fix it. Yay!
This method uses a program called chaiNNER, which is an incredibly versatile node-based graphics UI that (among many other things) uses AI models to upscale and process images. After a month and a half of experimenting on multiple different types of coats with about a dozen different models, I've identified two AI models that work best at repairing the artifacting damage done by TS4: RealESRGAN_x2plus and 2xAniscale. I extract the painted coats from the tray files using Cmar's Coat Converter, process them using chaiNNER, use Photoshop to make any touch ups (softening hard edges, fixing seams, adding in the appropriate hoof texture), and then create a new hoof swatch to put the newly fixed coat back into the game.
Fair warning: chaiNNER is a bit of a hefty program that requires significant RAM and VRAM to run. If you have a beefy gaming computer, you should have no issues running this (as long as no other major programs - games, graphics programs, etc. - are running as well). If you've got a lower end computer, though, your computer might not be able to handle it and this method might not be for you. Make sure to read all the documentation on chaiNNer's github before proceeding.
Before we begin, we're going to need to gather some resources. We will need:
- A graphics program. I use Photoshop, but GIMP or any other program that can work in layers will work too.
- chaiNNER
- AI Models; these are the ones I use are RealESRGAN_x2plus and 2xAniscale
- Cmar's Coat Converter to extract the coat textures from your tray files
- Tray Importer (Optionally) to isolate your household tray files and save you the trouble of searching the Tray Folder
- The TS4 Horse UV as a helpful guide to make sure all our textures are lined up properly
- Sims 4 Studio to create your new package.
- I recommend using S4S to export hoof swatch textures from the game or from existing hoof swatch cc. Some popular hoof swatch CC include Walnut Hill's Striped Hooves and Pure Winter's Glorious Striped Hooves
This tutorial assumes you are familiar with the basics in how to use Sims 4 Studio, such as how to clone a base-game item & how to import and export textures, and the basic functions of your graphics program, such as adding multiple different image files together as layers. I'll try to keep my explanations as straight-forward as possible.
STEP ONE: Extract the Coats
Install Cmar's Coat Converter and run it. Cmar's Coat Converter works by looking through your tray files for specific texture files (ie. The coats of cats, dogs, horses, and werewolves) and converting them to png files. You can go through the households of your Tray folder one by one, but I typically just use Tray Importer to separate the household containing the horses I want to fix.
Save the extracted coats in a project folder. These are your OG coats.
Install Cmar's Coat Converter and run it. Cmar's Coat Converter works by looking through your tray files for specific texture files (ie. The coats of cats, dogs, horses, and werewolves) and converting them to png files. You can go through the households of your Tray folder one by one, but I typically just use Tray Importer to separate the household containing the horses I want to fix.
Save the extracted coats in a project folder. These are your OG coats.
STEP TWO: Extract the hoof textures
Open up S4S. To extract the hoof swatches from the base game, create a new package by clicking CAS -> New Package, filter everything by species (ie. Horse) and then part type (Hoof color). Highlight all the basegame swatches and then save your new package.
Open up that package and then extract the texture for each swatch. Save them in your project folder (In a 'basegame hooves' folder to keep things organized).
To extract the textures from Hoof Swatch CC files, simply open them up in S4S and repeat the above.
Open up S4S. To extract the hoof swatches from the base game, create a new package by clicking CAS -> New Package, filter everything by species (ie. Horse) and then part type (Hoof color). Highlight all the basegame swatches and then save your new package.
Open up that package and then extract the texture for each swatch. Save them in your project folder (In a 'basegame hooves' folder to keep things organized).
To extract the textures from Hoof Swatch CC files, simply open them up in S4S and repeat the above.
Helpful tip: switch to the warehouse tab in S4S, hit CTRL+SHIFT+C, and then type studio.exportall . This is a handy little shortcut to export ALL resources from a package files. The files you need are labelled 'diffuse'.
STEP THREE: Download the AI Models
Right as it says on the tin. These are the models I use currently & some notes about them:
RealESRGAN_x2plus - this model is THE workhorse. It repairs artifact damaging with minimal loss to texture quality and results in a very smooth coat. It may sometimes darken the texture a little bit, but it's not noticeable in-game. That being said, it has a harder time with finer details such as spots, individual ticking for roans, dapples etc. I run this one first on all the coats because it usually does the job.
These models are trained to find and repair any incidence of artifacting/jpeg damage and approximate what the image is supposed to look like. The reason RealESRGAN_x2plus has an especially hard time with spots/dapples/tiny repetitive details etc. because it registers those areas as particularly damaged and works extra hard to smooth it out… which can sometimes result in a bit of an iffy coat repair. When things don't turn out the way I want, I turn to...
2xAniscale - I use this model for any appaloosas, roans, sabinos etc. that have very fine detail and came out mangled by RealESRGAN_2xPlus. It's also good for light-duty repairing (in cases where people have only 'saved' the coat once, as opposed to working on it on and off). While not strong enough on its own to tackle the more heavily damaged coats, it still does a decent job while keeping the fine details intact.
Go make a folder somewhere and name it 'AI Models' or something similar, and drop these guys in there.
STEP FOUR: Setting up chaiNNER
Obviously, go ahead and download chaiNNER, and then (through chaiNNER itself) download & install the dependencies. You really only need PyTorch for this, so if you'd like, you can skip NCNN, ONNX, and Stable Diffusion.
At first glance, chaiNNER is a bit overwhelming. It is unlike any other graphics ui I've seen before, but the basic premise is pretty straightforward: you 'chain' together specific functions ('nodes') in order to get your result.
We're going to start by setting up a chain for single coat conversions.
Right as it says on the tin. These are the models I use currently & some notes about them:
RealESRGAN_x2plus - this model is THE workhorse. It repairs artifact damaging with minimal loss to texture quality and results in a very smooth coat. It may sometimes darken the texture a little bit, but it's not noticeable in-game. That being said, it has a harder time with finer details such as spots, individual ticking for roans, dapples etc. I run this one first on all the coats because it usually does the job.
These models are trained to find and repair any incidence of artifacting/jpeg damage and approximate what the image is supposed to look like. The reason RealESRGAN_x2plus has an especially hard time with spots/dapples/tiny repetitive details etc. because it registers those areas as particularly damaged and works extra hard to smooth it out… which can sometimes result in a bit of an iffy coat repair. When things don't turn out the way I want, I turn to...
2xAniscale - I use this model for any appaloosas, roans, sabinos etc. that have very fine detail and came out mangled by RealESRGAN_2xPlus. It's also good for light-duty repairing (in cases where people have only 'saved' the coat once, as opposed to working on it on and off). While not strong enough on its own to tackle the more heavily damaged coats, it still does a decent job while keeping the fine details intact.
Go make a folder somewhere and name it 'AI Models' or something similar, and drop these guys in there.
STEP FOUR: Setting up chaiNNER
Obviously, go ahead and download chaiNNER, and then (through chaiNNER itself) download & install the dependencies. You really only need PyTorch for this, so if you'd like, you can skip NCNN, ONNX, and Stable Diffusion.
At first glance, chaiNNER is a bit overwhelming. It is unlike any other graphics ui I've seen before, but the basic premise is pretty straightforward: you 'chain' together specific functions ('nodes') in order to get your result.
We're going to start by setting up a chain for single coat conversions.
Drag & drop these nodes into your workspace:
Load Image
Save Image
Upscale Image
Load Model (From the PyTorch tab only!)
Text append
Next, connect the nodes just as I have connected them in the image.
Load Image, obviously, loads your image. We then tell the program we want to upscale that image by linking to the Upscale Image node. Upscaling can't happen without a model, so we then want to link Upscale Image with Load Model.
Text Append takes the original name of the image and combines it with the model name. This is super helpful, because if you're playing with many models at a time, you need to tell your result images apart. Link the output text to the Save Image Model.
Finally, Save Image obviously saves the image. We link the directory from Load Image to save it in the same place as the OG image, or, optionally, add in a file path link to another folder (in my case, I load images from a folder called 'Unprocessed' and save them into a folder called 'Processed'. Link the image from Upscale Image to Save Image to complete this chain.
Go in and select your image, model, and save locations.
Ta dah! You made your first chain.
To create an Iterator to batch process coats, we follow the same general idea, only we use 'Load Images'.
STEP FIVE: Run chaiNNER
Go ahead and run chaiNNER. Repeat using 2xAniscale if your spotty/dappled coat comes out funky.
Optionally, you can also add 'Resize' between 'Upscale' and 'Save Image' so the output texture is the same size as the OG. I like keeping mine big, as it makes it easier to fix any fine details in Photoshop.
STEP SIX: Combine in Photoshop
Go ahead and open up the horse UV, your coat texture & hoof swatches in Photoshop. This is a fairly straightforward process: layer the hooves overtop the texture, and then hide all hoof layers except the one you want. Make sure everything is lined up properly using the horse UV.
This is also where you would go in and fix any sharp, jagged edges you might spot. I often notice jagged edges on white face markings. Since the head is often one of the worst areas for artifacting, the AI models don't really have much to work with, resulting in jagged edges as they try to extrapolate what had been there 'before'. Either paint over it or use blur to smooth it out.
I personally would also remove any stray color that isn't the horse texture (body + ears). It won't hurt to leave it there, but I personally like things neat and tidy. Use the horse UV as a guide.
I also add in any little details using extracted stencils & layer masks.
Save your new coat as a png. Optionally, downsize it by 50% back to the original size. I don't do this because I'm very forgetful, but this would definitely help in keeping your package size smaller.
STEP SEVEN (Optional): Make a thumbnail
I make thumbnails for all the coats I do because it makes it much easier to identify them under the Hoof Swatch category. TS4 thumbnails are 144 x 148. You can label it with your horse's name, or stick a headshot in there etc. whatever works for you that will help it stand out from the other hoof swatches.
STEP EIGHT: Put it all Together
Finally, we've come to the end.
Using S4S, create a new package cloned from a hoof swatch. Import your new coat into 'Texture', and your thumbnail into 'Thumbnail'. Make sure you import the thumbnail for both Male and Female!
Check to make sure there aren't major seams, and that your texture is properly projected onto the S4S horse model. If there are seams, go back to check that your texture is lined up properly with the Horse UV. If there are minor seams (legs, chest, underbelly etc.) you can carefully paint (using the same color as on either side of the seam) just beyond the UV mesh boundaries to close the seam.
Then, go into Categories, scroll down, and uncheck Random. This will prevent random townie horses from wearing the coat.
Save your package.
Congratulations! You're done!