TileBased Texture Mapping on Graphics Hardware LiYi Wei
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 Implemented in graphics hardware VQ [Beers*96], S 3 TC/DXT [S 3 Corporation] ○ Good for general images × Suboptimal for repetitive patterns image pattern
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 Input tile tiling ○ Infinite compression ○ Good for GPU ○ Fast decoding × Repetition Arbitrarily large output texture
Texture Tiling: Wang Tiles tiling Input tiles ○ replace repetition by non-periodic tiling Arbitrarily large output texture
How Wang Tile Works 3 4 1 2 tiling Input tiles continuous pattern across identical edge color adjacent tiles share identical edge color
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 Tile hashing Packed input tiles (correct filtering across tiles) Output virtual texture
Random Access by Tile Hashing
Random Access by Tile Hashing Tile index (Oh, Ov) Hash function H() Edge color ← (Oh, Ov) Cs = H( H(Oh) + Ov ) Cn = H( H(Oh) + Ov + 1) Cw = H( Oh + H(2×Ov) ) Ce = H( Oh + 1 + H(2×Ov) ) ○ Consistency e. g. Ce(1, 2) = Cw(2, 2) ○ Direct evaluation No sequential dependency ○ Easy to compute Ov 4 3 Cn 2 Cw Ce Cs 1 0 0 1 2 3 4 Oh
Tile Hashing Quality • H() simply a permutation table • Hashing quality depends on table size Image size 32 x 32 8 entries 16 entries 32 entries
Random Access Needs All Possible Tile Edge Colors No matching input! Input tiles with all edge colors Output virtual texture
How to Filter Tiled Texture ? Shader filtering ○ flexible × slow × > 1 texture Tile packing ○ fast ○ 1 texture ○ size in 2 n ○ MIPMAP × how to pack? Boundary padding ○ fast ○ 1 texture × size not in 2 n × MIPMAP 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 1 D 0 0 1 1 0 e 1 ○ each tile used once ○ continuous boundary ○ easy to compute 2 1 2 2 0 Index(e 1, e 2) = 0, e 12 + 2×e 2 – 1, e 22 + 2×e 1, (e 2 + 1)2 - 2, (e 1 + 1)2 - 1, e 1 = e 2 = 0; e 1 > e 2 > 0; e 2 > e 1 ≥ 0; e 1 = e 2 > 0; e 1 > e 2 = 0;
Tile Packing in 2 D as 2 orthogonal 1 D packing horizontal: Index(cw, ce) vertical: Index(cs, cn) Index(e 1, e 2) = cn cw ce cs 0, e 12 + 2×e 2 – 1, e 22 + 2×e 1, (e 2 + 1)2 - 2, (e 1 + 1)2 - 1, e 1 = e 2 = 0; e 1 > e 2 > 0; e 2 > e 1 ≥ 0; e 1 = e 2 > 0; e 1 > e 2 = 0;
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 8192 x 8192
Results Incorrect low-res tile Correct tile edge Input tiles Correct tile edge/corner Traditional texture map
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 3 D texture tile
Acknowledgements Wei-Chao Chen Read the 1 st paper draft Says I should submit John Danskin Permission to submit Reviewers NVIDIANS
Questions?
- Slides: 25