Indirect Textures

From Custom Mario Kart
Jump to navigation Jump to search

Introduction

Indirect textures are textures that allow normal textures to be additionally warped using Wii's hardware functionality. They can be used to simulate distorions, waves, bumps and many other effects. Indirect textures does not need to be the same size or have same mapping as the base texture (texture that is being warped/affected) which give a lot more freedom with creating effects.

Indirect Processing

This section describes how indirect textures are processed.

Texture Components

Different components (color channels) are used for different functions. The basic amount of warping in vertical and horizontal direction is determined by components' values.

R Component

Red Component is not used at all.

G Component

Green Component is usually not used.
It impacts the Translate result when it's value is different than zero. Value of 128 means no translation

B Component

Blue Component expresses the warping amount of base texture in vertical direction. With range from 0 to 255, a value of 128 on pixel means no warping.
Darker pixels (<128) will be expressed with warping in the upward direction. Value of 0 indicates warping of 128 pixels in the upwards direction of indirect texture.
Brighter pixels (>128) will be expressed with warping in the downward direction. Value of 255 indicates warping of 127 pixels downwards.

A Component

Similar to B Component, however Alpha Component expresses the warp amount in horizontal direction.
Darker pixels (<128) will be expressed with warping in the leftward direction, while brighter (>128) with warping in rightward direction.

Example

Indirect-Texture-Warp-Example.png

In a region where value of B and A Compenent are different from 128 (B. 158 = 128 + 30), the warping occurs (No warping on 128 - A.). The result in a that region (C.) is portion of the base texture, which is shifted by 30 pixels right and down of indirect texture.
Because the warping is pixel depended, the dimentions of indirect texture matter.

Indirect Matrix

The Indirect Matrix determines the amount of warping in both directions.

Type Description
Scale S Expands (shrinks) the amount of warping in horizontal direction. (Warping = [AValue - 128] * Scale S).
Scale T Expands (shrinks) the amount of warping in vertical direction. (Warping = [BValue - 128] * Scale T).
Rotate Rotates the warping for both directions.
Translate S Adds (subtracts) the amount of warping in the horizontal direction. Works very similary to Scale. (Warping = [GValue - 128] * Translate S)
Translate T Adds (subtracts) the amount of warping in the vertical direction. Works very similary to Scale. (Warping = [GValue - 128] * Translate T)

Creating Indirect Textures

Image Size

It is not necessary to have the indirect texture dimensions to be the same as the base texture.
Because the warping is based on pixels, smaller dimensions, while reducing data size, will make the warping more abrupt.

Texture Formats

For indirect textures to work properly the alpha channel is required for horizontal warping.
The most common format is IA8 with 256 levels for B and A Components.

Mipmaps

Mipmap processing can be performed on indirect textures just as is done on ordinary textures. The use of mipmaps allows the warping to be modified in response to distance from the camera.