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 the Wii's hardware functionality. They can be used to simulate distortions, waves, bumps, and many other effects.

Indirect textures do not need to be the same size or have same mapping as the base texture (texture that is being warped/affected), which gives 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

The Red Component is not used at all.

G Component

The Green Component is usually not used.

It impacts the Translate result when its value is different than zero. A value of 128 means no translation.

B Component

The Blue Component expresses the warping amount of base texture in the vertical direction. With a range from 0 to 255, a value of 128 on a pixel means no warping.

Darker pixels (<128) will be expressed with warping in the upward direction. A value of 0 indicates warping of 128 pixels in the upward direction of the indirect texture.

Brighter pixels (>128) will be expressed with warping in the downward direction. A value of 255 indicates warping of 127 pixels downwards.

A Component

Similar to the B Component; however, the Alpha Component expresses the warp amount in the horizontal direction.

Darker pixels (<128) will be expressed with warping in the leftward direction, while brighter pixels (>128) are warped in the rightward direction.

Example

Indirect-Texture-Warp-Example.png

In a region where values of the B and A Components are different from 128 (B. 158 = 128 + 30), the warping occurs (no warping on 128 - A). The result in that region (C.) is the portion of the base texture, which is shifted by 30 pixels right and down of the indirect texture. Since the warping is pixel depended, the dimensions of indirect textures 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 the horizontal direction. (Warping = [AValue - 128] * Scale S).
Scale T Expands (shrinks) the amount of warping in the 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 similarly to Scale. (Warping = [GValue - 128] * Translate S)
Translate T Adds (subtracts) the amount of warping in the vertical direction. Works very similarly 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.

As 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 the B and A Components.

Mipmaps

Mipmap processing can be performed on indirect textures just like with ordinary textures.

The use of mipmaps allows the warping to be modified in response to the distance from the camera.