Replies: 3 (Who?), Viewed: 5846 times.
Ms. Byte
Original Poster
#1 Old 30th Jul 2009 at 11:15 PM Last edited by CmarNYC : 30th Jul 2009 at 11:29 PM.
Default Tutorial - custom non-replacement eyebrows
What this tutorial will do:

Show you how to make new, custom eyebrows that do not replace the game eyebrows.

What it will not do:

Tell you how to use a graphics program for texturing or how to modify alpha and RBG channels; tell you how to use a hex editor; or give you more than an outline of how to use Postal, s2pe, or the CAS Texture Unitool.

What you will need:

A package explorer/importer/exporter like Postal and/or s2pe.
Either Photoshop (pay) or GIMP (free) for the graphics, with DDS plugins.
A hex editor. I use HEdit but there are plenty of other free programs available.
A text editor like Notepad.
An FNV encoder like FNV Generator.

I already posted a lot of this in the eyebrows thread started by DragonSinger, but this is more detailed and includes some tricks I learned since then, like how to do thumbnails. Ready? Let's get started.

Create a folder for your work files.

Find the XML file and the CAS part file for the brow you want to modify, and extract them from Fullbuild0. I prefer Postal for this. What I do is load the nmap names, then click on the name column header to sort by name, then look for the item I want. In this case, "amMakeupEyebrows..." You want both the XML file and the 'unk' file (which is a CAS part file) right above it. In the hex view for each one export it to your folder.



In the XML, look up the 'Face Overlay' key, which gives you the Type, Group, and Instance numbers for the DDS overlay file. This is the graphics file that defines the shape of the brows. You can use the numbers to find and extract the overlay file from Fullbuild2 using Postal or s3p3. (Sort by instance first.)

You can also use the new version of CTU to extract all the texture files for the brow. The one you need will be the one that's 1.3 MB.



Open the DDS file in Photoshop or GIMP. Be sure to UNCHECK "open mipmaps" when you open the file or you'll get a bunch of smaller images in addition to the one you want to change. Edit the Alpha layer using white where you want the brow to be and erasing unwanted brow to background. In this case, I'm doing an upswept 'Spock' brow.



You'll notice there's no color in this graphic, not counting the RGB channels. The white parts in the alpha layer allow the underlying color of the brow to show through, while the black parts (or the blank/transparent parts, in GIMP) keep any brow from showing though.

Save the file, selecting DDS/DXT5 compression, and be sure to CHECK the "Generate mipmaps" option.

Now let's talk about file names and instance numbers. You need to make up a good descriptive name for your brows. If you follow the usual pattern in the game, it should start with the age and gender (am for adult male, etc.), then the clothing/body part (MakeupEyebrows), and then a specific name. In this case I'm changing the original "amMakeupEyebrowsBasic" to "amMakeupEyebrowsSpock". I didn't change the length of the descriptive name because then editing the CAS part file would be a pain in the butt. Not impossible, just a little more effort than lazy me is willing to make.

Every file in the game (that I know of) is referred to by a TGI key consisting of the Type, the Group, and the Instance. Since we're adding files to the game we need to give them new TGIs. In this case a new instance is sufficient. We're now going to open an FNV encoder (I use Snaif's FNV Encoder) and put the descriptive name we made up above in the text input. The resulting FNV64 hash will be our new instance.



(Due to the nature of hashing functions, it's extremely unlikely that two different text strings will produce the same hashed number. If someone else uses the same name for their mod you're in trouble; otherwise not much danger of duplication. Many creators are adding the system time and their name to make doubly sure.)

(Also note that the game uses hashes done by first converting all text to lowercase and then hashing. FNV Encoder works this way, but other utilities may not. I don't think it matters, as long as your instance number is unique.)

Postal exports files with the type, group, and instance numbers in the file name. CTU exports them with the descriptive name and the instance number. I find it easiest to name everything with the TGI numbers AND the descriptive name. In this example, I changed all the filenames accordingly, using the new instance number from FNV Encoder. Don't forget the instance IDs of the CAS part file and the XML file. Also I changed .unk to .cas for the CAS part file, just to keep things straight in my own head. (Never an easy task. )

S3_00B2D882_00000000_D24DF314B42DC4F4_amMakeupEyebrowsSpock.dds
S3_034aeecb_00000000_D24DF314B42DC4F4_amMakeupEyebrowsSpock.cas
S3_0333406c_00000000_D24DF314B42DC4F4_amMakeupEyebrowsSpock.xml

Edit the XML file in notepad or whatever text editor you prefer. Change the daeFileName to your descriptive name and change the instance ID of the Face Overlay key to your new instance number. (The Face Overlay Key should match the filename of your edited DDS file.) Save.



Edit the CAS part file in a hex editor and change the part name to your new name. Do NOT use a standard text editor like Notepad; it'll mess up the encoding in the file. Save.



Use your favorite package editor to import the XML, CAS part file, and edited DDS image file to a new package. I prefer S3PE for this since it automatically uses the name of the file and fills in your TGI and filename. I also tick off to use the resource name so it creates an index file, although I don't know if it's necessary.



Put your package in mod/packages and your brows should show up in CAS, although the thumbnail will still look like the eyebrows you used as a base.

Bonus 1: How to do a custom thumbnail.

The thumbnails used in CAS are PNG files stored in Program Files\Electronic Arts\The Sims Thumnails\CasThumbnails.package. You can find them by name and extract them the same way you found files in FullBuild0. There are three thumbnails for each eyebrow, of varying size. What I did was to open the largest PNG file in my favorite graphics program and manually edit it to look like my Spock brow. I resized the result and pasted it into the smaller PNG images to make them all the same. Then I changed the instance numbers of all three to match my new brow files and imported them into my package.

Bonus 2: A couple of extras.

If you look at the image below of the CAS part file, you'll see two areas circled in the hex codes. The first is a floating number the game uses to decide what order to show eyebrows in, from highest to lowest. I wanted to make my custom brows come at the end of the list, so I changed this number to the hex equivalent of float 1. Note that this number, like so many others in this game, has to be entered backwards: 3F 80 00 00 becomes 00 00 80 3F. Unfortunately the Unibrow uses 0, so it came after mine, and the toddler and child brows seem to all be 0, so I said the hell with it because backwards hexing gives me a headache anyway.



The second number is the code for age and gender. Using CTU, I figured out what to change this to so the brows will show up for both male and female. I think the gender code for both/unisex is the 30 you see in the image, but don't hold me to it. (And yes, more backwardsness. I think. By the time I got done with this I wasn't sure what's backwards and what's forwards.)

A couple of notes:

Brows for adults/young adults will show up for teens, too.

This may - or may not - work for beards too. I haven't tried. I did notice that when I messed up a face overlay and made it all black in GIMP, the entire face turned black including the eyes, so brows are another possibility for masks and contact lenses.

For some reason known only to EA, elder CAS part files for eyebrows seem to have the full XML content in them, unlike the CAS file in my example. There are two places where the filename should be changed, the reference to the overlay image file has to be changed, and it's harder to find the hex numbers mentioned above if you want to tweak them.

I tried doing this using CTU with no luck - didn't pursue it long enough to see if I messed up or if CTU just doesn't do this particular thing yet. If it doesn't, I'm betting Delphy will automate it at some point.

If anything's unclear or just plain wrong, please let me know. I'm not a great texture artist so I hope to see better brows from you all than what I can make!
Advertisement
Mother Function
retired moderator
#2 Old 2nd Aug 2009 at 3:06 AM
First off thanks for the tutorial

Quote:
I tried doing this using CTU with no luck - didn't pursue it long enough to see if I messed up or if CTU just doesn't do this particular thing yet. If it doesn't, I'm betting Delphy will automate it at some point


I used the CTU and it worked, and the correct thumbnail was auto-generated too. (see screenshot) All I did was replace the overlay image.

Sure saves time

Anyhoos, I followed your tutorial too, and it works. I really appreciate it because now I understand the inner working of CAS parts a lot better than I did before
Screenshots

"Holy Shift! Check out the asymptotes on that mother function!"
Lab Assistant
#3 Old 2nd Aug 2009 at 1:05 PM
Thank you for this tutorial!
Ms. Byte
Original Poster
#4 Old 2nd Aug 2009 at 3:09 PM
Quote:
Originally Posted by daluved1
I used the CTU and it worked, and the correct thumbnail was auto-generated too. (see screenshot) All I did was replace the overlay image.

Sure saves time

Anyhoos, I followed your tutorial too, and it works. I really appreciate it because now I understand the inner working of CAS parts a lot better than I did before


Good to know. I'm not sure what I did wrong using CTU (was getting garbled CAS files and general not-workingness), but I'll use it if/when I get back to brows.

I'm glad to have done it the hard way for exactly that reason - it's valuable to have some idea of the bits and bytes of what you're doing.
Back to top