SC4 Devotion Forum Archives

SimCity 4 General Discussion and Tutorials => Tips, Tricks and Tutorials => Tutorials on Custom Content Creation => Topic started by: Lowkee33 on September 12, 2010, 12:36:28 PM

Title: Creating a Terrain Mod
Post by: Lowkee33 on September 12, 2010, 12:36:28 PM
   This tutorial will introduce the steps to take to make a terrain mod.  It covers the basics of editing the Terrain INI, and how to import your own textures into Sim City 4.  I am changing the titles of these two tutorials, as they aren't really basic and advanced anymore.  This tutorial explains how to make a mod, and the other explains terrain related exemplars.

This tutorial is subject to change as needed. Last Update: 11-05-2011
-Including the need for an exemplar for each texture (#post_lastmod)

Difficulty:
    -Intermediate

   While not necessarily "hard" to do, we will be exploring SimCity_1.dat, and some experience/confidence in Ilive's Reader is necessary.  To make this faster I will be sharing the TGI's of the various pieces of SimCity_1.dat that we will need.  From there we move on to editing an INI and importing a texture


Programs you will need:
    -Ilives Reader
        We will be copying the Terrain INI from SimCity_1.dat and editing it.
    -Null45's BatchPngtoFsh Tool
        We will create and import a texture.   
    -A useful tool is a text writing program that has the "Replace all" function.  Notepad, which comes with Windows, will do just fine.  Reasons to be cautious of this are talked about when notepad comes up.

Welcome to the Tutorial

Contents

    1) Setting ourselves up for success (#post_success).  Here we will find the file we need in SimCity_1.dat and understand it.
    2) Making our Mod (#post_mod).  We will then change the INI to change our terrain textures.
    3) Editing an Existing Terrain Mod (#post_editing).  A quick look at some C.P. (CycleDog) Terrains.
    4) Importing a Texture (#post_import).  We will create a texture and import it.   
   
Section 1)  Setting ourselves up for success.

Step 1)  Be Safe
     -Make a backup of your SimCity_1.dat.  We are not going to change anything in there, but who knows what could happen.
     -Backup and empty your plugin's folder.  We will be testing our terrain a lot, and want a clean slate to work with.

Step 2) Creating Our .Dat
    -Open Ilives Reader.
    -On the bottom left hand corner there is a tab that says SimcityDat.  Click on it. 
    -You will see the 8 Reader friendly files on the left side of your screen.  Click on SimCity_1.dat (topmost).
    -Find the entry:
        Type      - 0x00000000
        Group     - 0x8A5971C5
        Instance - 0xAA597172
    -Right click on the INI file and click "Copy File(s)"
    -We don't want to change SimCity_1.dat, so we will make our own .dat file
    -Open the file menu and make a new File.
    -Click "Paste File(s)" and you will have your own INI
    -Click "Save as" and save it as something you will remember and to you plugin folder.
    -You now have a terrain that will override SimCity's terrain. (At this point they are the same though).

    The INI is a long document, and getting to know it is important.  You may see right off the bat that certain lines are green.  These are lines that have been turned off (with ";"), so don't worry about them.  About halfway down this document is the Tropical Texture Map Table.  This is what we will be modding.  This table has 32 rows and 16 columns.  The blocks of the table are filled with 0x##, the ## being the last two digits of the terrain texture's Instance.

Optional Step 2.5) Finding the Maxis Textures

A terrain texture's Instance?  A terrain texture is a FSH with Type: 7ab50e44, Group: 891b0e1a, and Instance 00000?##.  The Instance is like a fingerprint, and it is important that no two textures have the same Instance (otherwise they will override).  The ## represents a variable number between "00" and "FF"  giving us 256 possible terrain textures.  The "?" represents the 5 zooms of the texture and has a value of either 0,1,2,3, or 4. 4 is the closest zoom, and in-game is the keyboard zoom 5+6.

The terrain textures can be found in SimCity_2.dat.  The optional step is to copy paste all of the terrain textures that are zoom 4 into the file we are working on.  This is purely for ease.  If you compare these textures to the ones on the Tropical Texture Map, you will see that only 31-38 are being used.  The other are miscellaneous, and include the Cliff, beach, edge of the city, and a few unused cliff textures.  Your file may look something like this:

(https://www.sc4devotion.com/forums/proxy.php?request=http%3A%2F%2Fimg403.imageshack.us%2Fimg403%2F8725%2Freaderj.jpg&hash=57e871a12449d944cd2d623fd22cea5c61c9ca10)

Here is an image of the Maxis grass textures, and their corresponding IDs:
(https://www.sc4devotion.com/forums/proxy.php?request=http%3A%2F%2Fimg825.imageshack.us%2Fimg825%2F6352%2Fmaxistextures.jpg&hash=574175bbb32d152b6b5fe8d1441b1ae94fab5677)

Step 3)  Modifying the Terrain INI

Making a terrain mod is simply changing the values in the Tropical Texture Map Table.  The 32 rows represent altitude (temperature to be exact) and the 16 column represent moisture.  The top row "00" is the highest altitude level.  This level is important.  Properties in the Terrain Exemplar (see the exemplar tutorial) define at what altitude this row appears at.  Any altitude higher than this will use this row.  The furthest left column is the driest moisture level.  These two variables temperature/moisture are not largely simulated (temperature not at all).  I have found that at no time will the Maxis Default settings display the 2 left most columns.

I am going to copy/paste the Tropical Texture map into Notepad, and quickly do some "replace all" functions.  Your work with Maxis Textures can be far more precise.  Just remember to click the "Apply" button on the top of the INI before you save.  Also, be careful using the "replace all" function.  If you replace "31" with "32", you will replace the 31 that defines that temperature row, and you will get a crash.  In my quick change I "saved" a texture value as "ab".  When I replaced "ab" with "37" I replaced the ab in "Table".  A good safety measure is to replace "0x##' with "0x##", but in the end, you will get used to CTDs.  My Tropical Texture map is on the left with the resulting terrain on the right.  I just threw some textures in that I know are recognizable as different.  Anyway, we see that Maxis textures blend pretty well with each other.

(https://www.sc4devotion.com/forums/proxy.php?request=http%3A%2F%2Fimg19.imageshack.us%2Fimg19%2F9534%2Ffinalrx.jpg&hash=ae0874dac4ec1f013bd9d5bbb5fe9d30fe65624a)

Similarly, this method can be used with the textures that C.P. (CycleDog) created.  However, he made about 70 textures, so there is a much higher learning curve when it comes to the Instances.  The next section explains how to replace a specific texture in one of his terrain Mods.

Section 3) Editing an Existing Terrain Mod

This section of the tutorial will explain how to modify an existing terrain mod.  For this example I have used the MeadowShire Terrain Controller.  I have chosen textures that are noticeable and helpful for a tutorial. 

Step 1)  Planning
   -To make this go faster we will want the plugin folder to consist of only the necessary files.  There are 4 files needed to make a terrain mod work.
          1) The Terrain Controller
          2) The CPT_No3 textures
          3) The CPT_No4 textures
          4) The Rock textures
   -Start SC4 and terraform in god mode until the target texture is apparent:
(https://www.sc4devotion.com/forums/proxy.php?request=http%3A%2F%2Fimg602.imageshack.us%2Fimg602%2F417%2Ftargety.jpg&hash=605e62af5aa23eec3bf4551a335263cf2af65662)
     
    -The texture in the white circle is our target texture.  I have chosen this because it is a warm color in an otherwise cool color Terrain mod.
    -Notice the green and red circles.  These are also warm textures.  This makes the process more complicated, but for now we will head into the Reader.

[Step 2)  The INI file.
    -An image of the Meadowshire INI:
(https://www.sc4devotion.com/forums/proxy.php?request=http%3A%2F%2Fimg511.imageshack.us%2Fimg511%2F3541%2Ftablewl.jpg&hash=dbc6800aa10d15c7543990d7755b0ee56861a915)

   -Editing this Terrain is a matter of finding the Instance of the texture we want to change, and switching it with an Instance that we want to keep.

Step 3)   Locating the Texture
   -Open CPT_No3_TerrainTextures_Essential.dat in Reader.  We will see a long list of "FSH" Entries.  I was in zoom 5 when I took that image, so I am looking for an 0x000004## file.
   -Click on the "DAT" tab, the little arrow next to "Filter", place a "4" in the Instance section, and click "Apply".  The following picture displays these steps:   
(https://www.sc4devotion.com/forums/proxy.php?request=http%3A%2F%2Fimg35.imageshack.us%2Fimg35%2F6820%2Ffiltere.jpg&hash=59ebd44f730827cd84dd4b368f1c2048bdb0a7e6)

    -That is better.  Now we can search for the target texture.  There are some that are close in No_3, but checking No_4 we find the exact texture:
(https://www.sc4devotion.com/forums/proxy.php?request=http%3A%2F%2Fimg46.imageshack.us%2Fimg46%2F1623%2Ftargettexture.jpg&hash=ad6b68589811d0cb6c4f4ad1ffbc0c78fb1847be)

   -Note the last two Instance digits (in this case "fd").

Step 4)  Replacing textures
   -Re-open the Terrain controller, open the INI, and scroll down to the Tropical Texture Map Table.
   -We can find "0xfd" listed in quite a few places.  It is possible to change these here, but better to copy/paste the whole table into a text program that has the "replace all" function.
   -For this tutorial we will just use more of the other cool (green) textures to replace the three warm textures.
   -The Instance "0xff" appears next to "0xfd" quite a lot, and checking No_4 we see that it is a cool texture.  "Replace all" of the "0xfd" with "0xff"
   -Copy/Paste this new Table over the Table in the INI, click the save icon, and then save the whole file:

(https://www.sc4devotion.com/forums/proxy.php?request=http%3A%2F%2Fhhttp%3A%2F%2Fimg201.imageshack.us%2Fimg201%2F6623%2Fstep1ht.jpg&hash=e063343f401cd03cd6cabe95d8f15fb206e3672a)

   -Opening SC4 we will now see this:

(https://www.sc4devotion.com/forums/proxy.php?request=http%3A%2F%2Fimg651.imageshack.us%2Fimg651%2F3954%2F1of3.jpg&hash=7435178b89253b2d83609d37481d276f9024d7c6)

   -We still have those other two textures, so now repeat step 3 and 4 for them.  They are Instance "0xf3" and "0xC1".  These textures appear less and have more neighboring textures.  I will change these in Reader as I see fit:
(https://www.sc4devotion.com/forums/proxy.php?request=http%3A%2F%2Fimg13.imageshack.us%2Fimg13%2F4108%2F2of3.jpg&hash=e2115b9b46a1b0ae648c0ad27e728430cbe97463)

   -There is actually a 4th warm texture there, but I will leave that for you all to change.

Section 4)  Importing our own texture

At this point you may feel that you want to add your own texture to Sim City.

Along with Reader, you will need an image editing program and a Png to Fsh converter.  I use Null45's BatchPNGtoFSH.  For this tutorial I will add one texture to the game, and will edit the INI to only use this texture.

Step 1)  Getting your texture ready for import.

Sim City can use any image that is a square with binary pixel lengths as a terrain texture (2x2,4x4,8x8...256x256...1024x1024).  Open your image in an image editing program (MSPaint works), scale it to the desired size, and save it as a PNG with the name "0x000000##".  The ## being the "fingerprint" that you desire.  I am creating an image with Texture Maker (http://www.texturemaker.com/news.php).

Step 2) Importing the PNG

Recall that all terrain textures are Group 0x891b0e1a and Instance 0x00000?##.  I am going to make a texture with Instance 0x000000ff, and simply clone it in reader to make the 4 other zooms.

-Open the "GroupID" file in the BatchPngtoFsh tool folder, and change it to "891b0e1a".  The program will now automatically make your FSH have the correct Group ID.
-Change the name of your image to the Instance that you want, including the 0x (0x000000ff for me).  BatchPngToFsh will use this file name as the Instance it creates.
-Open BatchPngtoFSH and drag/drop your image on to it.  You will now see your image listed.  Uncheck the "Automatically Process Mips" box, and click "Save Dat".  You will now be asked what to save it as, so save it as something reasonable in your plugin folder.

Step 3) Making the zooms:

This tutorial is not very complex, so I am using the same image for all zooms.  If you had more than one zoom you wanted to import, just name the files accordingly (0x000000ff, 0x000001ff, 0x000002ff, 0x000003ff, 0x000004ff).

-Open your new file in Reader and right click on the FSH.  Select "Clone File", change "number of copies" to 4, check the "Increment Instance" box, and change the value to "0x00000100".  You will then have 5 texture files with the proper zoom IDs.  Don't do this if you already have each zoom as a separate image.

Step 4) Making a texture's exemplar:

Every terrain texture needs an exemplar of its own.  Otherwise, your terrain will be black in-game blakerussell's image below (http://sc4devotion.com/forums/index.php?topic=11690.msg402360#msg402360)).  To do this, open SimCity_1.dat in Reader, don't fill the list, and enter the Navigator.  Expand the Terrain branch, and you will see a long list, mostly terrain exemplars.  The terrain exemplars have names like "Texture01" and "Texture1D".  Right click on one of these, and select "Synchronize".  You will see your exemplar in the main screen.  Copy/paste it into a blank dat (or whatever makes sense), and save the .dat.  SimCity_1 should not be saved.

I put the exemplar in the same file as the FSH textures.  Change the instance of the exemplar to that of the texture, and you are good to go.  There are some properties in there that can be changed, but for now you have something that works (perhaps I explain these later).

An image of my file:

(https://www.sc4devotion.com/forums/proxy.php?request=http%3A%2F%2Fimg21.imageshack.us%2Fimg21%2F3563%2Ftutfix.jpg&hash=fd348ff5cde26677bff454e8b55e7612e51d87df)


Step 5) Editing the INI:

-Now that we have a valid Terrain Texture we can change the INI to use that Instance.  I only made one texture, so the whole thing is filled with 32 columns and 16 rows of "0xFF"

In-Game I have this:

(https://www.sc4devotion.com/forums/proxy.php?request=http%3A%2F%2Fimg220.imageshack.us%2Fimg220%2F9159%2Fimporteds.jpg&hash=5d9ddb169fa212e99e0c27cf563a721bfc600ee5)

This concludes the tutorial on how to create a terrain mod.  The advanced tutorial is now "Terrain Exemplars", and describes further ways to make your terrain your own.

Please feel free to ask any questions or add tips of your own.  If you feel I could organize this better please say how.  I will be watching this thread and adding these tips into the tutorial.  So, if you see someone posting something that is already in there, that is why.

A big thanks goes out to CycleDogg for the textures and Ennedi who's various posts taught me how to do this.
Title: Re: Terrain Mod Tutorial - Basic
Post by: marsh on December 21, 2010, 12:46:47 AM
I have a question. I have some textures, not by c.p., and I want them in a terrain mod. I can get them into i-live fine as fsh.'s. My question is what do you do with the exemplar file so they can be read correctly.
Title: Re: Terrain Mod Tutorial - Basic
Post by: Lowkee33 on December 21, 2010, 08:16:42 AM
You will need a terrain texture exemplar whos Instance is the Instance of the FSH in zoom "0".  For example, the cp snow texture is 0x0000008f (and 1,2,3,4 as the 6th digit for zooms).  The exemplar would be Instance 0x0000008f.

Best bet would be to copy/paste an exemplar from SimCity_1.dat (found using the Navigator in the Terrain Tab) and change the Instance to your texture.  There are interesting properties that can be changed there, but I haven't explored them enough to speak of. 
Title: Re: Terrain Mod Tutorial - Basic
Post by: marsh on December 21, 2010, 02:39:39 PM
Thanks. I've got it. Now the only problem I have is making the textures blend together in photoshop so there's not grids through the textures. :P

Also, I'm pretty sure this is the case, do they have to be a certain size? I noticed that when trying to put a texture in smaller than 255x255 will crash the game.  %wrd
Title: Re: Terrain Mod Tutorial - Basic
Post by: Lowkee33 on December 21, 2010, 05:50:36 PM
QuoteThanks. I've got it. Now the only problem I have is making the textures blend together in photoshop so there's not grids through the textures. Tongue

Sort of where I am at too, that and having to make the 4 other zooms.

Textures must be a square with Binary sides, 1,2,4,8,16...256,512,1024...  Making 1024x1024 textures seems to be the name of the game right now.  The interesting thing is that with larger textures you can decrease the Texture Tiling Factor (found in the Terrain Exemplar), and get far less repetition.  To get the most out of Ennedi's rock mods the TTF should be decreased.  It basically stretches the textures out.

If you are going to make your own textures you may want to learn the behavior of the Z0-4 Texture spread curve properties in the Texture exemplar.  They may be able to help with your griddyness. 

Title: Re: Creating a Terrain Mod
Post by: blakerussell on November 04, 2011, 08:03:34 PM
I have attempted to upload my own texture via PngToFsh. I followed your instructions exactly (i think). What do you think I am doing wrong? What EXACTLY were your options in uploading through the PngtoFsh program? Maybe I have something checked that isn't supposed to be checked. What do you think?  ()what()

(https://www.sc4devotion.com/forums/proxy.php?request=http%3A%2F%2Fi1090.photobucket.com%2Falbums%2Fi370%2Fscotscot13%2Fblackland.jpg&hash=0421330ca1115bfabce11b5e3131d37d2d97d5d4)
Title: Re: Creating a Terrain Mod
Post by: Lowkee33 on November 05, 2011, 05:53:36 AM
Hmm, looks like I forgot something in the tutorial.  I've seen this on my own computer quite a few times.

Terrain textures need an exemplar to go with them.  You want to use reader to copy/paste one from SimCity_1.dat into a new dat (or perhaps the one with the texture(s) in it.  They can be found in the Navigator, under the terrain branch (where the terrain properties is found as well).  Change the instance of this exemplar to that of your texture.

Good Luck  :thumbsup:

Edit: would you also mind changing your PNG to a jpeg?  It makes loading this page faster.  You don't really want any direct links to PNGs in this forum.  Thanks.
Title: Re: Creating a Terrain Mod
Post by: blakerussell on November 05, 2011, 09:22:24 AM
Excellent. Thanks so much!
Title: Re: Creating a Terrain Mod
Post by: Indiana Joe on November 22, 2012, 10:15:04 AM
Hey Lowkee; I was wondering if you would help me edit a terrain mod.  I'm fairly happy with the original Columbus mod, but there's one instance of textures that bothers me.  Right before it fades to beach textures at the shoreline, it turns from the common grass texture into one with flowers and fallen logs.  That doesn't exactly blend well with the beach (and the faded-out logs look very unrealistic).  So I was hoping to replace that occurrence of textures with another one from the CPT_No3 texture pack.  That's as far as I've gotten in my planning.  I have the Reader, but I've only used it for some minor tweaking before.  I was hoping you could help me get started on swapping out these textures.
Title: Re: Creating a Terrain Mod
Post by: Lowkee33 on November 22, 2012, 10:44:14 AM
I do believe Editing an Existing Terrain Mod (#post_editing) is what you are looking for.
Title: Re: Creating a Terrain Mod
Post by: Indiana Joe on November 22, 2012, 10:53:58 AM
Ah, I missed that part of the tutorial.  That helps, but what I really want to do is just alter where some textures appear.  I don't want to replace them completely.  Is there an easy way to change the texture so that it, for example, doesn't show up within x tiles of the shoreline?  Or at a certain altitude?
Title: Re: Creating a Terrain Mod
Post by: Lowkee33 on November 22, 2012, 11:03:19 AM
QuoteThat helps, but what I really want to do is just alter where some textures appear.

Thats exactly what this tutorial is.  Find the instance of the texture you want to change and the instance of the texture you want to change it too.  Then find that instance in the Terrain INI and switch it with the one you want.  Textures appearing on the beach would be the lowest row.
Title: Re: Creating a Terrain Mod
Post by: Indiana Joe on November 22, 2012, 11:07:33 AM
I don't want to change the beach textures.  I want to change the textures that appear on the hills that slope down to the beach (the ones adjacent to the beach textures).  But I still want them to appear on hills elsewhere.  Can I keep the texture from appearing at these low altitudes, but still appear in the same instance at higher altitudes?

Okay, after some tinkering I've begun to figure out how this works.  Do you know enough about the texture map to be able to help me with this:

What I'm aiming to do is have there be a single, uniform texture that the beach textures transition into.  Sort of like an "upper beach" texture.  Any idea which instances I'll have to replace to get this to happen?  Or am I in for a lot of experimenting?
Title: Re: Creating a Terrain Mod
Post by: c.p. on November 22, 2012, 03:27:53 PM
The circled numbers are the ones with the logs.  If you change the numbers in the bottom row, beginning with the circled fa, and working to the right, to 0xf9 or 0xab, that might get you something close to what you want, maybe.
(https://www.sc4devotion.com/forums/proxy.php?request=http%3A%2F%2Fimg690.imageshack.us%2Fimg690%2F511%2Fcolumbuschanges.jpg&hash=15ca7e0099bf849587e8849cc5cd9a115f3987c5)
Title: Re: Creating a Terrain Mod
Post by: Indiana Joe on November 22, 2012, 08:13:24 PM
Woah, it's the master of terrain himself, come back from the dead!   ;D  Thanks a ton; I've been messing with it all day and I'll try that out.