Virtual Textures Dealing with Enormous Texture-Based Resources Anders Scheel Nielsen 1 Anders Scheel Nielsen
Textures 2 Anders Scheel Nielsen
Textures 3 Anders Scheel Nielsen
Mipmaps 4 Anders Scheel Nielsen
Mipmaps 5 Anders Scheel Nielsen
Real life problems Problems: • Limited amount of resources (avg. 256 MB) • Large variation in system resources • Maximum texture sizes from: fra 2048 x 2048 til 8192 x 8192 • Atomic Resource 6 Anders Scheel Nielsen
Real life problems Problems: • Limited amount of resources (avg. 256 MB) • Large variation in system resources • Maximum texture sizes from: fra 2048 x 2048 til 8192 x 8192 • Atomic Resource 6 Anders Scheel Nielsen
Real life problems Problems: • Limited amount of resources (avg. 256 MB) • Large variation in system resources • Maximum texture sizes from: fra 2048 x 2048 til 8192 x 8192 • Atomic Resource 6 Anders Scheel Nielsen
Real life problems Problems: • Limited amount of resources (avg. 256 MB) • Large variation in system resources • Maximum texture sizes from: fra 2048 x 2048 til 8192 x 8192 • Atomic Resource Solution for ’large’ models: • Repeating textures • Blending 6 Anders Scheel Nielsen
Repeating Textures 7 Anders Scheel Nielsen
Repeating textures 8 Anders Scheel Nielsen
Texture blending 9 Anders Scheel Nielsen
Static handling of Texture budget Using too much memory? • Permanently reduce the texture resolution • Load lower mip map levels 10 Anders Scheel Nielsen
Static handling of Texture budget Using too much memory? • Permanently reduce the texture resolution • Load lower mip map levels 10 Anders Scheel Nielsen
Static handling of Texture budget Using too much memory? • Permanently reduce the texture resolution • Load lower mip map levels 10 Anders Scheel Nielsen
Static handling of Texture budget Using too much memory? • Permanently reduce the texture resolution • Load lower mip map levels 10 Anders Scheel Nielsen
Observations 11 Anders Scheel Nielsen
Observations Large Textures • All ’points’ in a surface can be truly unique • Artists can add all the details to the texture they want 11 Anders Scheel Nielsen
Observations Large Textures • All ’points’ in a surface can be truly unique • Artists can add all the details to the texture they want Texture loading with higher granularity • Load only visible parts of the texture 11 Anders Scheel Nielsen
Observations Large Textures • All ’points’ in a surface can be truly unique • Artists can add all the details to the texture they want Texture loading with higher granularity • Load only visible parts of the texture Load Textures Runtime: • Artists/developers: No headaches from keeping texture budgets! • Smoother scaling for different hardware configurations • Artists can (in theory) work in arbitrary resolution 11 Anders Scheel Nielsen
The Method 12 Anders Scheel Nielsen
Basic Data Structures 13 Anders Scheel Nielsen
Flow 14 Anders Scheel Nielsen
Calculation of visible tiles Readback of the framebuffer: 15 Anders Scheel Nielsen
Barrett’s Fragment shader 1 float mipmapLevel = calcMipmapLevel(uv * textureSize); 2 float2 tilePos = floor(uv * indirectionSize); 3 tilePos /= 256.0; 4 float2 tilePos_low = frac(tilePos); 5 float2 tilePos_high = floor(tilePos); 6 color.bg = floor(tilePos_low * 256.0 + 0.5)/255.0; 7 color.r = (tilePos_high.x + tilePos_high.y * 16)/255.0; 8 color.a = (mipmapLevel + textureId * 16)/255.0; 9 10 float calcTextureMipmapLevel(float2 uv) { 11 float2 dtdx = dFdx(uv); 12 float2 dtdy = dFdy(uv); 13 float2 dtex = dtdx*dtdx + dtdy*dtdy; 14 float minDelta = max(dtex.x,dtex.y); 15 float miplevel = max(0.5 * log2(minDelta), 0.0); 16 return miplevel; 17 } 16 Anders Scheel Nielsen
Barrett’s Fragment shader 1 float mipmapLevel = calcMipmapLevel(uv * textureSize); 2 float2 tilePos = floor(uv * indirectionSize); 3 tilePos /= 256.0; 4 float2 tilePos_low = frac(tilePos); 5 float2 tilePos_high = floor(tilePos); 6 color.bg = floor(tilePos_low * 256.0 + 0.5)/255.0; 7 color.r = (tilePos_high.x + tilePos_high.y * 16)/255.0; 8 color.a = (mipmapLevel + textureId * 16)/255.0; 9 10 float calcTextureMipmapLevel(float2 uv) { 11 float2 dtdx = dFdx(uv); 12 float2 dtdy = dFdy(uv); 13 float2 dtex = dtdx*dtdx + dtdy*dtdy; 14 float minDelta = max(dtex.x,dtex.y); 15 float miplevel = max(0.5 * log2(minDelta), 0.0); 16 return miplevel; 17 } 17 Anders Scheel Nielsen
TD-texture 18 Anders Scheel Nielsen
TD-texture Texture usage: • 5 texture types • 4096 x 4096 • Usage: 80 MB 18 Anders Scheel Nielsen
TD-texture Texture usage: • 5 texture types • 4096 x 4096 • Usage: 80 MB 18 Anders Scheel Nielsen
TD-texture Texture usage: • 5 texture types • 4096 x 4096 • Usage: 80 MB My fragment shader: 1 color = tex2D(tdTexture, vertexIn.uv * coordScale); 2 color.w = tex2Dbias(tdTexture, vertexIn.uv, mipBias + resolutionBias).w; 18 Anders Scheel Nielsen
Tilbagelæsning Tilbagelæsning fra grafikkort til systemhukommelse 19 Anders Scheel Nielsen
Which tiles to load first? • Screen area prioritized • Based on error metric: •Mip map level 20 Anders Scheel Nielsen
Which tiles to discard? • First In First Out • Least Frequently Used • Least Recently Used • Weighted Least Recently Used 21 Anders Scheel Nielsen
Updating the Indirection Map 22 Anders Scheel Nielsen
Updating the Indirection Map 23 Anders Scheel Nielsen
Rendering 24 Anders Scheel Nielsen
Rendering 25 Anders Scheel Nielsen
Visual Results Screenshots 26 Anders Scheel Nielsen
Resultater Resultater 27 Resultater Anders Scheel Nielsen
Diskussion Diskussion 28 Diskussion Anders Scheel Nielsen
Resultater: Tilbagelæsning 29 Anders Scheel Nielsen
Resultater: Tilbagelæsning 30 Anders Scheel Nielsen
Resultater: Tilbagelæsning 31 Anders Scheel Nielsen
Resultater: tilbagelæsning + CPU 32 Anders Scheel Nielsen
Resultater: HDD read 33 Anders Scheel Nielsen
Resultater: Hvilke tiles skal indlæses? 34 Anders Scheel Nielsen
Resultater: Hvilke tiles skal kasseres? 35 Anders Scheel Nielsen
The demo Virtual Textures: 36 Anders Scheel Nielsen
The demo Virtual Textures: • Efficient handling of giant textures: Demo: 128k x 128k, theoretical: 2M x 2M (16 TB) 36 Anders Scheel Nielsen
The demo Virtual Textures: • Efficient handling of giant textures: Demo: 128k x 128k, theoretical: 2M x 2M (16 TB) • Texture usage for a 20 GB texture: 17 MB 36 Anders Scheel Nielsen
The demo Virtual Textures: • Efficient handling of giant textures: Demo: 128k x 128k, theoretical: 2M x 2M (16 TB) • Texture usage for a 20 GB texture: 17 MB • Frame rate: 150-200 FPS (8800GT) 36 Anders Scheel Nielsen
Demo time 37 Anders Scheel Nielsen
Future work Prediction of visible tiles • Camera vector • A priori map Virtuel Terrain • Height map as a Virtual Texture Other uses than games • Browsing pictures • Google Earth’ish applications • Streaming Casual Games with Instant Game Play 38 Anders Scheel Nielsen
Contributions Contributions • Calculating visible tiles at greater precision with 2 lines of code • Simple, but effective tile prediction method • New strategies for prioritizing tiles • Faster methods for critical tasks in the VT-system 39 Anders Scheel Nielsen
40 Konklusion Anders Scheel Nielsen
Thank you! Andreas Bærentzen , DTU Carsten Kjær , Dalux Daniel Povlsen , Aptocore Martin Mittring , CryTek GmbH Sean Barrett Per Rasmussen Hardware provided by HwT.dk Anders.Scheel@gmail.com 40 Konklusion Anders Scheel Nielsen
Media 41 Anders Scheel Nielsen
Media Seek time is a killer: 10 tiles @ 256 x 256 = 650KB 41 Anders Scheel Nielsen
Reading tiles from media 42 Anders Scheel Nielsen
Reading tiles from media • Maximizing throughput MPixels/s: • Compression = more MPixels/s • Texture Layout on media: minimizing seek time 42 Anders Scheel Nielsen
Reading tiles from media • Maximizing throughput MPixels/s: • Compression = more MPixels/s • Texture Layout on media: minimizing seek time 42 Anders Scheel Nielsen
Reading tiles from media • Maximizing throughput MPixels/s: • Compression = more MPixels/s • Texture Layout on media: minimizing seek time 42 Anders Scheel Nielsen
Reading tiles from media • Maximizing throughput MPixels/s: • Compression = more MPixels/s • Texture Layout on media: minimizing seek time • Invalidated by the future: SSD harddrives? 42 Anders Scheel Nielsen
Diskussion 1 Ulemper ved metoden: Transparente objekter • Et ekstra prepass Antal unikke teksturer • Pakke flere teksturer i ét VT • 8 bit tile-position Kvalitetstab pga. manglende tekstur • Højere teksturkomprimering • Fjern visuel pops 43 Anders Scheel Nielsen
Recommend
More recommend