tile-based texture mapping on graphics hardware li-yi wei nvidia

25
Tile-Based Texture Mapping on Graphics Hardware Li-Yi Wei NVIDIA

Upload: makenna-platter

Post on 29-Mar-2015

226 views

Category:

Documents


2 download

TRANSCRIPT

Page 1: Tile-Based Texture Mapping on Graphics Hardware Li-Yi Wei NVIDIA

Tile-Based Texture Mapping on Graphics Hardware

Li-Yi WeiNVIDIA

Page 2: Tile-Based Texture Mapping on Graphics Hardware Li-Yi Wei NVIDIA

Texture Mapping with Large Repetitive PatternTexture Mapping with Large Repetitive Pattern

Large terrain textures are very commonGames, simulation

IssuesBandwidth for texture access

Memory/Cache for texture storage

Need texture compression

Page 3: Tile-Based Texture Mapping on Graphics Hardware Li-Yi Wei NVIDIA

Method 1:General Image CompressionMethod 1:General Image Compression

image pattern

Implemented in graphics hardwareVQ [Beers*96], S3TC/DXT [S3 Corporation]

○ Good for general images

× Suboptimal for repetitive patterns

Page 4: Tile-Based Texture Mapping on Graphics Hardware Li-Yi Wei NVIDIA

Method 2:Texture TilingMethod 2:Texture Tiling

Only works for repetitive patterns

○ Good compression ratio

× Requires changing texture coordinates

× No native texture filtering support

Page 5: Tile-Based Texture Mapping on Graphics Hardware Li-Yi Wei NVIDIA

Our Goal: Texture Tiling on GPUOur Goal: Texture Tiling on GPU

○ No need to change texture coordinates

○ Native texture filtering

○ Implementation in fragment program

Page 6: Tile-Based Texture Mapping on Graphics Hardware Li-Yi Wei NVIDIA

Texture Tiling: Simple CaseTexture Tiling: Simple Case

○ Infinite compression

○ Good for GPU

○ Fast decoding

× Repetition

Input tile

Arbitrarily large output texture

tiling

Page 7: Tile-Based Texture Mapping on Graphics Hardware Li-Yi Wei NVIDIA

Texture Tiling: Wang TilesTexture Tiling: Wang Tiles

Arbitrarily large output texture

Input tiles

tiling

○ replace repetition by non-periodic tiling

Page 8: Tile-Based Texture Mapping on Graphics Hardware Li-Yi Wei NVIDIA

How Wang Tile WorksHow Wang Tile Works

Input tiles

tiling

adjacent tiles share identical edge colorcontinuous pattern across identical edge color

11 22

33 44

Page 9: Tile-Based Texture Mapping on Graphics Hardware Li-Yi Wei NVIDIA

Wang Tiles for Texture Mapping on GPU ?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

Page 10: Tile-Based Texture Mapping on Graphics Hardware Li-Yi Wei NVIDIA

Overview of Our SystemOverview of Our System

Packed input tiles(correct filtering across tiles) Output virtual texture

Tile hashing

Page 11: Tile-Based Texture Mapping on Graphics Hardware Li-Yi Wei NVIDIA

Random Access by Tile HashingRandom Access by Tile Hashing

Page 12: Tile-Based Texture Mapping on Graphics Hardware Li-Yi Wei NVIDIA

Random Access by Tile HashingRandom 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) )

○ Consistencye.g. Ce(1, 2) = Cw(2, 2)

○ Direct evaluationNo sequential dependency

○ Easy to computeOh0 1 2 3 4

Ov

0

1

2

3

4

Cw

Cs

Cn

Ce

Page 13: Tile-Based Texture Mapping on Graphics Hardware Li-Yi Wei NVIDIA

Tile Hashing QualityTile Hashing Quality

• H() simply a permutation table

• Hashing quality depends on table size

8 entries 16 entries 32 entries

Image size 32 x 32

Page 14: Tile-Based Texture Mapping on Graphics Hardware Li-Yi Wei NVIDIA

Random Access Needs All Possible Tile Edge ColorsRandom Access Needs All Possible Tile Edge Colors

Output virtual texture

Input tiles

No matching input!

with all edge colors

Page 15: Tile-Based Texture Mapping on Graphics Hardware Li-Yi Wei NVIDIA

How to Filter Tiled Texture ?How to Filter Tiled Texture ?

Shader filtering○ flexible

× slow

× > 1 texture

Boundary padding○ fast

○ 1 texture

× size not in 2n

× MIPMAP

Tile packing○ fast

○ 1 texture

○ size in 2n

○ MIPMAP

× how to pack?

No good packing

(for general case)

Page 16: Tile-Based Texture Mapping on Graphics Hardware Li-Yi Wei NVIDIA

Tile Packing for Texture FilteringTile 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

Page 17: Tile-Based Texture Mapping on Graphics Hardware Li-Yi Wei NVIDIA

Tile Packing in 1DTile Packing in 1D

Index(e1, e2) =

0, e1 = e2 = 0;

e12 + 2×e2 – 1, e1 > e2 > 0;

e22 + 2×e1, e2 > e1 ≥ 0;

(e2 + 1)2 - 2, e1 = e2 > 0;

(e1 + 1)2 - 1, e1 > e2 = 0;

0 0 0 01 2 2 21 1e1 e2

○ each tile used once

○ continuous boundary

○ easy to compute

Page 18: Tile-Based Texture Mapping on Graphics Hardware Li-Yi Wei NVIDIA

Tile Packing in 2DTile Packing in 2D

Index(e1, e2) =

0, e1 = e2 = 0;

e12 + 2×e2 – 1, e1 > e2 > 0;

e22 + 2×e1, e2 > e1 ≥ 0;

(e2 + 1)2 - 2, e1 = e2 > 0;

(e1 + 1)2 - 1, e1 > e2 = 0;

as 2 orthogonal 1D packinghorizontal: Index(cw, ce)

vertical: Index(cs, cn)

cecw

cn

cs

Page 19: Tile-Based Texture Mapping on Graphics Hardware Li-Yi Wei NVIDIA

Implementation and PerformanceImplementation and Performance

ImplementationCg 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

Page 20: Tile-Based Texture Mapping on Graphics Hardware Li-Yi Wei NVIDIA

ResultsResults

Input tiles Result with virtual texture size 8192x8192

Page 21: Tile-Based Texture Mapping on Graphics Hardware Li-Yi Wei NVIDIA

ResultsResults

Input tiles

Traditional texture mapCorrect tile edge/corner

Correct tile edgeIncorrect low-res tile

Page 22: Tile-Based Texture Mapping on Graphics Hardware Li-Yi Wei NVIDIA

LimitationsLimitations

× Incorrect lower-resolution MIPMAP levels

× Need tile set with all possible edge colors

× Not fast enough

Page 23: Tile-Based Texture Mapping on Graphics Hardware Li-Yi Wei NVIDIA

Future WorkFuture Work

• Performance improvement

• Driver implementation

• Hash instruction in hardware

• 3D texture tile

Page 24: Tile-Based Texture Mapping on Graphics Hardware Li-Yi Wei NVIDIA

AcknowledgementsAcknowledgements

Wei-Chao ChenRead the 1st paper draft

Says I should submit

John DanskinPermission to submit

Reviewers

NVIDIANS

Page 25: Tile-Based Texture Mapping on Graphics Hardware Li-Yi Wei NVIDIA

Questions?Questions?