GPU/Procedural Texture Generation

< GPU
Revision as of 17:35, 23 August 2015 by Neobrain (talk | contribs)


The 3DS GPU supports procedural generation of texture data using texture unit 3. Little is known about this feature, albeit a few public hints have been dropped. The contents of this page are solely based on reports on a presentation given by DMP.

Overview

Procedural texture generation has four stages:

  • Noise Module (outputs uā€²,vā€²)
  • Repeat Module (outputs uā€²ā€²,vā€²ā€²)
  • Base Shape (also notated as G(uā€²ā€²,vā€²ā€²), output g)
  • F(g) and Lookup Table

Noise Module

This stage applies noise on the input coordinates. Little is known about this other than that there are three noise parameters:

  • Amplitude
  • Frequency
  • Phase

Repeat Module

This stage performs basic texture coordinate wrapping on the noised coordinates. It supports symmetric and mirrored wrapping. They don't seem to be configurable beyond that.

Base Shape

The Uā€™ā€™ and Vā€™ā€™ coordinates are used to generate a scalar value in the range [0;1] from the wrapped coordinates using one of six functions:

  • ADDSQRT2: sqrt(Uā€™ā€™*Uā€™ā€™+Vā€™ā€™*Vā€™ā€™) (?)
  • Uā€™ā€™: Uā€™ā€™ (discards Vā€™ā€™)
  • Vā€™ā€™: Vā€™ā€™ (discards Uā€™ā€™)
  • MIN: min(Uā€™ā€™,Vā€™ā€™)
  • MAX: min(Uā€™ā€™,Vā€™ā€™)
  • ADD: Uā€™ā€™+Vā€™ā€™

The output of this function is named "g".

F(g) and Lookup Table

F is a selectable function which transforms g to another scalar value. There are two known options for F:

  • the identity function
  • a triangle function

The final texel color is determined by using the value of F(g) as an index into a configurable lookup table (which is presumed to span 3 kilobytes of data).