Difference between revisions of "Encoding Mipmaps with Wiimms Image Tool"

From Custom Mario Kart
Jump to navigation Jump to search
m (Small fixes.)
m (You don't need to reference a page link each time it's written in the text. Once is enough.)
Line 10: Line 10:
 
To create proper mipmaps for CTools tracks you have to use Wiimms Image Tool, which is part of [http://szs.wiimm.de/wimgt/ Wiimms SZS Tools]. You will also need BrawlBox to enable the use of mipmaps.
 
To create proper mipmaps for CTools tracks you have to use Wiimms Image Tool, which is part of [http://szs.wiimm.de/wimgt/ Wiimms SZS Tools]. You will also need BrawlBox to enable the use of mipmaps.
  
==Step 1 - Enable Mipmaps==
+
== Step 1 - Enable Mipmaps ==
  
Enable mipmaps with [[BrawlBox]] by setting MinFilter to Linear_Mipmap_Linear in your materials references (see [[BrawlBox Tricks]], if you have problems opening your [[CTools]] [[BRRES]] go to that tutorial too, to make your BRRES compatible with BrawlBox).<BR>
+
Enable mipmaps with BrawlBox by setting MinFilter to Linear_Mipmap_Linear in your materials references (see [[BrawlBox Tricks]], if you have problems opening your CTools BRRES go to that tutorial too, to make your BRRES compatible with BrawlBox).<BR>
 
'''Note:''' You can do all your BrawlBox stuff like culling, animations, shaders etc. first and after that continue with step 2.
 
'''Note:''' You can do all your BrawlBox stuff like culling, animations, shaders etc. first and after that continue with step 2.
  
==Step 2 - Extract your BRRES==
+
== Step 2 - Extract your BRRES ==
  
Now extract your [[BRRES]] with wszst with the command:  
+
Now extract your BRRES with wszst with the command:  
  
 
  wszst x course_model.brres
 
  wszst x course_model.brres
  
Open up the extracted folder and go to Textures(NW4R) and look at the name of your Textures. For [[SketchUp]] tracks, they will most likely be named something like "filename-SKP--texturename." Copy the prefix "filename-SKP--".
+
Open up the extracted folder and go to Textures(NW4R) and look at the name of your Textures. For SketchUp tracks, they will most likely be named something like "filename-SKP--texturename." Copy the prefix "filename-SKP--".
  
==Step 3 - Preparing raw images==
+
== Step 3 - Preparing raw images ==
  
For best quality results it is highly recommended to use your raw image files (the .PNG files of your [[SketchUp]] OBJ model) and not the images that were encoded with [[CTools]]. If you created your OBJ with SketchUp's OBJ Exporter they will be stored in a folder called "''trackname''_Textures". Now rename all textures you want mipmaps for with the prefix you copied from Textures(NW4R) folder of the [[BRRES]], so the PNGs are named exactly like the TEX0 in your brres. <br>
+
For best quality results it is highly recommended to use your raw image files (the .PNG files of your SketchUp OBJ model) and not the images that were encoded with CTools. If you created your OBJ with SketchUp's OBJ Exporter they will be stored in a folder called "''trackname''_Textures". Now rename all textures you want mipmaps for with the prefix you copied from Textures(NW4R) folder of the BRRES, so the PNGs are named exactly like the TEX0 in your brres. <br>
 
Example: Rename your texture named "texturename.PNG" to "filename-SKP--texturename.PNG". <br>
 
Example: Rename your texture named "texturename.PNG" to "filename-SKP--texturename.PNG". <br>
 
You can optionally sort those PNG in different folders, depending on the number of mipmaps and the image format you want. For example, a texture with 64x64 pixels can have 2 mipmaps, 128x128 3 mipmaps, etc.
 
You can optionally sort those PNG in different folders, depending on the number of mipmaps and the image format you want. For example, a texture with 64x64 pixels can have 2 mipmaps, 128x128 3 mipmaps, etc.
  
==Step 4 - Encoding TEX0==
+
== Step 4 - Encoding TEX0 ==
  
 
Next you will encode your PNGs to TEX0 with mipmaps using the following command:<br>  
 
Next you will encode your PNGs to TEX0 with mipmaps using the following command:<br>  
 
  wimgt encode filename.PNG --n-mm=5  
 
  wimgt encode filename.PNG --n-mm=5  
This command will create a TEX0 of the texture filename.PNG with 5 mipmaps ('''Note:''' In [[BrawlBox]] this would be "Level of Detail: 6"). You can also use  
+
This command will create a TEX0 of the texture filename.PNG with 5 mipmaps ('''Note:''' In BrawlBox this would be "Level of Detail: 6"). You can also use  
 
  --n-mm=auto  
 
  --n-mm=auto  
 
and wimgt will create mipmaps till the texture reaches 16 pixels in either one or both dimensions. <br> If you want to encode all textures in a certain folder (in this example with 5 mipmaps) just use: <br>
 
and wimgt will create mipmaps till the texture reaches 16 pixels in either one or both dimensions. <br> If you want to encode all textures in a certain folder (in this example with 5 mipmaps) just use: <br>
Line 42: Line 42:
 
The option --transform can encode in every known image format. For a list of all options for wimgt look [http://szs.wiimm.de/wimgt/ here].
 
The option --transform can encode in every known image format. For a list of all options for wimgt look [http://szs.wiimm.de/wimgt/ here].
  
==Step 5 - Replacing your TEX0==
+
== Step 5 - Replacing your TEX0 ==
  
 
All you need to do now is replacing your old TEX0 from your Textures(NW4R) folder with the TEX0 you just created with wimgt.
 
All you need to do now is replacing your old TEX0 from your Textures(NW4R) folder with the TEX0 you just created with wimgt.

Revision as of 22:42, 30 June 2016

Under Construction
This article is not finished. Help improve it by adding accurate information or correcting grammar and spelling.


This tutorial shows how to add proper mipmaps on BRRES files modeled in SketchUp and created with CTools BRRES Editor.

Mipmaps will immensely improve the visuals of your track. Your textures will look smoother and you can heavily reduce moiré patterns.

The problem with mipmaps on BRRES files created with CTools is that in the TEX0 Header offset 0x14 is always 0, so there will be no mipmaps shown in game even though CTools created them and mipmaps were enabled with BrawlBox. Even if textures are encoded with BrawlBox the mipmaps will be of poor quality.

To create proper mipmaps for CTools tracks you have to use Wiimms Image Tool, which is part of Wiimms SZS Tools. You will also need BrawlBox to enable the use of mipmaps.

Step 1 - Enable Mipmaps

Enable mipmaps with BrawlBox by setting MinFilter to Linear_Mipmap_Linear in your materials references (see BrawlBox Tricks, if you have problems opening your CTools BRRES go to that tutorial too, to make your BRRES compatible with BrawlBox).
Note: You can do all your BrawlBox stuff like culling, animations, shaders etc. first and after that continue with step 2.

Step 2 - Extract your BRRES

Now extract your BRRES with wszst with the command:

wszst x course_model.brres

Open up the extracted folder and go to Textures(NW4R) and look at the name of your Textures. For SketchUp tracks, they will most likely be named something like "filename-SKP--texturename." Copy the prefix "filename-SKP--".

Step 3 - Preparing raw images

For best quality results it is highly recommended to use your raw image files (the .PNG files of your SketchUp OBJ model) and not the images that were encoded with CTools. If you created your OBJ with SketchUp's OBJ Exporter they will be stored in a folder called "trackname_Textures". Now rename all textures you want mipmaps for with the prefix you copied from Textures(NW4R) folder of the BRRES, so the PNGs are named exactly like the TEX0 in your brres.
Example: Rename your texture named "texturename.PNG" to "filename-SKP--texturename.PNG".
You can optionally sort those PNG in different folders, depending on the number of mipmaps and the image format you want. For example, a texture with 64x64 pixels can have 2 mipmaps, 128x128 3 mipmaps, etc.

Step 4 - Encoding TEX0

Next you will encode your PNGs to TEX0 with mipmaps using the following command:

wimgt encode filename.PNG --n-mm=5 

This command will create a TEX0 of the texture filename.PNG with 5 mipmaps (Note: In BrawlBox this would be "Level of Detail: 6"). You can also use

--n-mm=auto 

and wimgt will create mipmaps till the texture reaches 16 pixels in either one or both dimensions.
If you want to encode all textures in a certain folder (in this example with 5 mipmaps) just use:

wimgt encode *.PNG --n-mm=5


NOTE: CTools normally encodes your TEX0 as CMPR but wimgt will encode your TEX0 as RGB5A3 by default. The quality of your textures will be a lot higher but it will blow up the size of your BRRES. So it is recommended to only use RGB5A3 on textures that really need it. To force wimgt to encode as CMPR use the command:

wimgt encode filename.PNG --transform=CMPR --n-mm=5

The option --transform can encode in every known image format. For a list of all options for wimgt look here.

Step 5 - Replacing your TEX0

All you need to do now is replacing your old TEX0 from your Textures(NW4R) folder with the TEX0 you just created with wimgt. After that repack the BRRES using:

wszst create course_model.brres.d -o 

and rename the file correctly if needed.
NOTE: If you want different textures appear in-game depending on how far the texture is away, you can decode your new TEX0 files with:

wimgt decode texturename 

Now edit the PNGs of the mipmaps and rencode the TEX0.