TxdGen/Mipmapping San Andreas for PC

From GTAMods Wiki
Jump to navigation Jump to search

Mipmapping is an important final touch to game textures. Using mipmaps you can improve the visual quality of models when they are rendered in the distance. Both CPU and GPU performance is increased: Mipmaps do not have to be generated during runtime, the GPU has an easier job mapping lower resolution textures onto triangles. When done correctly mipmapping only bears advantages. Unfortunately, Rockstar Games has not entirely done things right, which is the cause in the "black roads bug" that plagues the PC and XBOX version of San Andreas. In this tutorial, we want to put a closure to the dark history and fix San Andreas textures how they were supposed to be.

At time of writing, TxdGen version 0.9 is current.

And yes, we will fix the irritating black roads.

Video tutorial (high quality download)

Directions

Step 1: Requirements

There are only a few requirements for fixing your game textures.

Step 2: Downloading and Preparing

First off, you need to install GTA:SA if you have not already. The recommended location to install to is C:/Program Files (x86)/Rockstar Games/GTA San Andreas/. If you have installed somewhere different, please adjust the following steps accordingly.

How to install TxdGen

  • Place the downloaded txdgen_*.zip archive onto your desktop
  • Right click on the icon and select "Extract All"
  • Press the "Extract" button.
  • You now have a txdgen_* folder on your desktop

Next we want to configure the tool. Inside of the TxdGen folder you see a txdgen.ini file. This is the central configuration file. You should fiddle around with the settings if you got spare time.

This is a specialized version of that file that we need.

txdgen.ini
[Main]
gameRoot=C:/Program Files (x86)/Rockstar Games/GTA San Andreas/models/
outputRoot=txdgen_out/
targetVersion=SA
targetPlatform=PC
clearMipmaps=false
generateMipmaps=true
mipGenMode=default
mipGenMaxLevel=15
mipGenSafe=false
improveFiltering=true
compressTextures=false
compressionQuality=1.0
palRuntimeType=PNGQUANT
dxtRuntimeType=SQUISH
warningLevel=3
ignoreSecureWarnings=false
reconstructIMGArchives=true
fixIncompatibleRasters=true
dxtPackedDecompression=false
imgArchivesCompressed=false

Keep the TxdGen directory window around.

Step 3: The Conversion

That is all you need to do to prepare the conversion. Once you are ready, execute txdgen.exe. A console window will open in which you can see debug information. Most importantly it displays what TXD files it currently processes. Since it requires a long time (even more so depending on your workstation processing power) please be patient.

Console window

Just like it was stated earlier the converter will fix a lot of textures. For each fixed texture it will display a warning which tells you about the bugs that the texture had. So if you cannot wait, sit back and relax while reading the output of the console window!

When the console window has closed automatically, the conversion is finished.

Step 4: Modding the game

  • open the game directory of GTA:SA (C:/Program Files (x86)/Rockstar Games/GTA San Andreas/)
  • browse into the "models/" subdirectory
  • (OPTIONAL): back up the .img and .txd files inside of this directory
  • return to the TxdGen directory window
  • browse into the "txdgen_out/" directory
  • copy the entire contents of that directory into the "models/" directory we opened earlier
Copying the generated files into the game

Congratulations! You have fixed the 'black-roads' bug! Every world texture is now using mipmaps!

Comparison Shots

These screenshots were taken with the following game configuration.

  • draw distance: full
  • frame limiter: off
  • widescreen: on
  • FX quality: low
  • mip mapping: on
  • anti aliasing: 3
  • resolution: 1680x1050x32
  • Windows 98 compatibility mode + administrator
  • IMPORTANT: no driver overrides

Follow these configurations to reproduce the issues dipicted in the screenshots. Make sure that you go into the game options before loading the game!

Black-roads bug

Before After
Brf ls highwayexit side.png
Brf ls highwayexit side fixed.png
Brf lv toairstrip.png
Brf lv toairstrip fixed.png
Brf sf mainroad.png
Brf sf mainroad fixed.png
Brf sf scraper.png
Brf sf scaper fixed.png

Technical Details

Streaming Memory

Adding mipmaps to game textures significantly increases their size. Since the San Andreas engine uses a concept called streaming memory, you may encounter slower loading of the world around you. This effect is increased if you have set a high draw distance in your game settings.

To fix this issue, I recommend that you install one of the many streaming memory fixes from the GTA modding community.

Conversion Behavior

Each texture that has been converted will just be extended by mipmaps if it did not have them already. The converter has been carefully crafted so that textures do not loose quality (avoiding recompression). Automatic mipmap generation is turned off for all textures.

Filtering modes are fixed for all textures. This enables mipmapping for textures that had it disabled previously. Using improveFiltering=true the rendering quality of textures is upscaled closely to how the GTA:SA engine does it.