Tile-Based Texture Mapping on Graphics Hardware Li-Yi Wei NVIDIA
Texture Mapping with Large Repetitive Pattern Large terrain textures are very common Games, simulation Issues Bandwidth for texture access Memory/Cache for texture storage Need texture compression
Method 1: General Image Compression imagepattern Implemented in graphics hardware VQ [Beers*96], S3TC/DXT [S3 Corporation] Good for general images × Suboptimal for repetitive patterns
Method 2: Texture Tiling Only works for repetitive patterns Good compression ratio × Requires changing texture coordinates × No native texture filtering support
Our Goal: Texture Tiling on GPU No need to change texture coordinates Native texture filtering Implementation in fragment program
Texture Tiling: Simple Case Infinite compression Good for GPU Fast decoding × Repetition Input tile Arbitrarily large output texture tiling
Texture Tiling: Wang Tiles Arbitrarily large output texture Input tiles tiling replace repetition by non-periodic tiling
How Wang Tile Works Input tiles tiling adjacent tiles share identical edge colorcontinuous pattern across identical edge color 12 34
Wang Tiles for Texture Mapping on GPU ? Original [Cohen*03] × Sequential tiling × No texture filtering across tiles × Not good for GPU Our approach Random-accessible tiling Native texture filtering across tiles Good for GPU × Need more tiles
Overview of Our System Packed input tiles (correct filtering across tiles) Output virtual texture Tile hashing
Random Access by Tile Hashing
Tile index (O h, O v ) Hash function H() Edge color (O h, O v ) C s = H( H(O h ) + O v ) C n = H( H(O h ) + O v + 1) C w = H( O h + H(2×O v ) ) C e = H( O h H(2×O v ) ) Consistency e.g. C e (1, 2) = C w (2, 2) Direct evaluation No sequential dependency Easy to compute OhOh OvOv CwCw CsCs CnCn CeCe
Tile Hashing Quality H() simply a permutation table Hashing quality depends on table size 8 entries16 entries32 entries Image size 32 x 32
Random Access Needs All Possible Tile Edge Colors Output virtual texture Input tiles No matching input! with all edge colors
How to Filter Tiled Texture ? Shader filtering flexible × slow × > 1 texture Boundary padding fast 1 texture × size not in 2 n × MIPMAP Tile packing fast 1 texture size in 2 n MIPMAP × how to pack? No good packing (for general case)
Tile Packing for Texture Filtering × tiles with all colors (for random access) each tile used once (no wasted memory) continuous boundary (native filtering) easy to compute Packed input tiles
Tile Packing in 1D Index(e 1, e 2 ) = 0, e 1 = e 2 = 0; e ×e 2 – 1, e 1 > e 2 > 0; e ×e 1, e 2 > e 1 0; (e 2 + 1) 2 - 2, e 1 = e 2 > 0; (e 1 + 1) 2 - 1, e 1 > e 2 = 0; e1e1 e2e2 each tile used once continuous boundary easy to compute
Tile Packing in 2D Index(e 1, e 2 ) = 0, e 1 = e 2 = 0; e ×e 2 – 1, e 1 > e 2 > 0; e ×e 1, e 2 > e 1 0; (e 2 + 1) 2 - 2, e 1 = e 2 > 0; (e 1 + 1) 2 - 1, e 1 > e 2 = 0; as 2 orthogonal 1D packing horizontal: Index(c w, c e ) vertical: Index(c s, c n ) cece cwcw cncn cscs
Implementation and Performance Implementation Cg without hand optimization Performance (million tri-linear texels per second on Geforce FX 5600) 2.7 – full fragment program implementation 20 – pre-compute tile hashing in a texture
Results Input tiles Result with virtual texture size 8192x8192
Results Input tiles Traditional texture mapCorrect tile edge/corner Correct tile edgeIncorrect low-res tile
Limitations × Incorrect lower-resolution MIPMAP levels × Need tile set with all possible edge colors × Not fast enough
Future Work Performance improvement Driver implementation Hash instruction in hardware 3D texture tile
Acknowledgements Wei-Chao Chen Read the 1 st paper draft Says I should submit John Danskin Permission to submit Reviewers NVIDIANS
Questions?
Limitations × Incorrect lower-resolution MIPMAP levels × Need tile set with all possible edge colors × Not fast enough
Filtering Result: Tile Edge Input tiles Result without correct input tile packing Result with correct input tile packing
Filtering Result: Tile Corner Input tiles Result without corner handling Result with corner handling
Ungrouped Border and Image
Grouped Border and Image
aph/shutbug.htm
S2004 Arial, Bold, 37 points This subtitle is 31 points Bullets are orange; text is 26 points They have 110% line spacing, 6 points before/after Longer bullets in the form of a paragraph are harder to read if there is insufficient line spacing. This is the maximum recommended number of lines per slide (seven). –Sub-bullets look like this.