Welcome! Log In Create A New Profile


[Self-Solved] Mipmapping questions

Posted by TheCodingBrony 
[Self-Solved] Mipmapping questions
January 06, 2015 12:33PM
What are the best options for gxtexconv when generating mipmapped textures and what additional texture parameters do I have to set to get mipmapping working on the Wii? I know I have to use GX_LIN_MIP_LIN and the textures must be a power of two but it didn't seem to work the last time I tried and I have no clue on how to do it properly.

Also, what is the format of mipmapped textures exactly? Are the mipmaps simply appended onto the base texture from largest to smallest or do they have to be mixed together in some way and is there any detailed documentation with example C source of all the supported texture formats on the Wii/GC as I couldn't seem to find any from what I know so far.

Any useful help will be greatly appreciated.

Edited 1 time(s). Last edit at 01/14/2015 02:33PM by TheCodingBrony.
Re: Mipmapping questions
January 10, 2015 04:25PM
I've never really used that stuff before; [www.google.com.jm]
Re: Mipmapping questions
January 14, 2015 02:32PM
Well, I managed to figure it out myself with the help of some bits of code from the Wire 3D engine and some fiddling about with GX_InitTexObjLOD() which is the function for enabling mipmapping.

To create mipmapped textures with gxtexconv, convert using the following parameters (color format can be any to your liking except color index formats):
gxtexconv -i image.png colfmt=4 mipmap=yes minlod=0 maxlod=8 -o texture.tpl
But remember, the source image must be a power-of-two in order for this to work properly... Also, because mipmapped textures are roughly 35% larger than non-mipmapped textures, it is best to use either RGB565 or DXT1 Compressed as the texture format.

Unfortunately, due to a bug with TPL_OpenTPLFromFile() which causes the system to crash when you attempt to load mipmapped textures (from what I remember), you will have to write your own TPL loader which isn't too hard to make anyway and finding documentation of the file format should be easy.

As for the actual texture format itself, mipmaps are simply appended right next to the main texture data as individual blocks based on what I've analyzed through a hex editor.

Once you got your mipmapped texture data loaded, set it up with GX_InitTexObj() as usual but you'll also need to use GX_InitTexObjLOD() to enable mipmapping.

These are the best mipmap settings that I could come up with for GX_InitTexObjLOD():
	barbTex.TexObj(),	// Texture object to set the mipmap settings to.
	GX_LIN_MIP_LIN, 	// Set minFilt (near) as Linear-mipmap-Linear.
	GX_LINEAR, 		// Set magFilt (far) as just Linear.
	0.f, 			// MinLOD... Should be 0 in most cases.
	8.f, 			// MaxLOD... 8 is good enough in most cases.
	-0.4f, 			// LOD bias... This value reduces blurring a little.
	GX_DISABLE, 		// No need to clamp LOD+Bias I think?
	GX_ENABLE, 		// Compute LOD by adjacent texels, improves sharpness of far away texels.
	GX_ANISO_4		// Anisotropy level (the higher the level, the sharper far textures will look but may also be slower).

And here's the result with a 1024x1024 texture image (tiled into a 4x4 grid) using the settings above:
Re: [Self-Solved] Mipmapping questions
January 15, 2015 01:02AM
looks sharp. what does it look like without mipmapping?
Re: [Self-Solved] Mipmapping questions
January 15, 2015 08:09AM
Without mipmapping, textures will look pretty bad when the polygon is far away as you can see:

Not only does mipmapping improve texture mapping quality, it also improves rendering performance somehow when using the lowest anisotropy level that is.
Re: [Self-Solved] Mipmapping questions
January 15, 2015 08:14AM
Awww nice, I can see the difference
Sorry, only registered users may post in this forum.

Click here to login