Anders Scheel Nielsen 1
Virtual Textures
Dealing with Enormous Texture-Based Resources
Anders Scheel Nielsen 3
Anders Scheel Nielsen 5
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
Anders Scheel Nielsen 6
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
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
Anders Scheel Nielsen 6
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
Anders Scheel Nielsen 8
Anders Scheel Nielsen 10
Static handling of Texture budget
Using too much memory?
• Permanently reduce the texture resolution
• Load lower mip map levels
Static handling of Texture budget
Using too much memory?
• Permanently reduce the texture resolution
• Load lower mip map levels
Anders Scheel Nielsen 10
Static handling of Texture budget
Using too much memory?
• Permanently reduce the texture resolution
• Load lower mip map levels
Static handling of Texture budget
Using too much memory?
• Permanently reduce the texture resolution
• Load lower mip map levels
Anders Scheel Nielsen 11
Observations
Large Textures
• All ’points’ in a surface can be truly unique
Anders Scheel Nielsen 11
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
Observations
Large Textures
• All ’points’ in a surface can be truly unique
• Artists can add all the details to the texture they want
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
Texture loading with higher granularity
Anders Scheel Nielsen 12
Anders Scheel Nielsen 14
Calculation of visible tiles
Anders Scheel Nielsen 16
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;
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;
Anders Scheel Nielsen 18
TD-texture
Texture usage:
• 5 texture types
• 4096 x 4096
• Usage: 80 MB
Anders Scheel Nielsen 18
TD-texture
Texture usage:
• 5 texture types
• 4096 x 4096
• Usage: 80 MB
TD-texture
1 color = tex2D(tdTexture, vertexIn.uv * coordScale);
2 color.w = tex2Dbias(tdTexture, vertexIn.uv, mipBias +
Texture usage:
• 5 texture types
• 4096 x 4096
• Usage: 80 MB
Anders Scheel Nielsen 19
Tilbagelæsning
Which tiles to load first?
•
Screen area prioritized
• Based on error metric:
Anders Scheel Nielsen 21
Which tiles to discard?
• First In First Out
• Least Frequently Used • Least Recently Used
Anders Scheel Nielsen 23
Anders Scheel Nielsen 25
Visual Results
Anders Scheel Nielsen 27
Resultater
Resultater
Resultater
Anders Scheel Nielsen 27
Resultater
Resultater
Diskussion
Anders Scheel Nielsen 29
Anders Scheel Nielsen 31
Anders Scheel Nielsen 33
Anders Scheel Nielsen 35
The demo
Anders Scheel Nielsen 36
The demo
Virtual Textures:
• Efficient handling of giant textures:
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
Anders Scheel Nielsen 36
The demo
Virtual Textures:
• Efficient handling of giant textures:
Demo: 128k x 128k, theoretical: 2M x 2M (16 TB)
• Frame rate: 150-200 FPS (8800GT)
Anders Scheel Nielsen 38
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
Contributions
Contributions
• Calculating visible tiles at greater precision with 2 lines of code
• Simple, but effective tile prediction method
• New strategies for prioritizing tiles
Anders Scheel Nielsen 40
Thank you!
Andreas Bærentzen
,
DTU
Carsten Kjær
,
Dalux
Daniel Povlsen
,
Aptocore
Martin Mittring
,
CryTek
GmbH
Sean Barrett
Per Rasmussen
Anders Scheel Nielsen 41
Media
Anders Scheel Nielsen 42
Reading tiles from media
•
Maximizing throughput MPixels/s:
• Compression = more MPixels/s
Anders Scheel Nielsen 42
Reading tiles from media
•
Maximizing throughput MPixels/s:
• Compression = more MPixels/s
Reading tiles from media
•
Maximizing throughput MPixels/s:
• Compression = more MPixels/s
Anders Scheel Nielsen 42
Reading tiles from media
•
Maximizing throughput MPixels/s:
• Compression = more MPixels/s
• Texture Layout on media: minimizing seek time
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
Anders Scheel Nielsen 44
Diskussion 2
Hastighedstab pga. indirection
• men mindre state change • Genbrug
Filtrering
• Manuel i shader • Border padding
• Hardwareunderstøttelse
Anders Scheel Nielsen 46
Backup: SVT
Tilbagelæsning
Tilbagelæsning fra grafikkort til systemhukommelse
• Grundlag for metoden er tilbagelæsning til
systemhukommelsen
Anders Scheel Nielsen 48
Backup: SVT
Backup: Teksturrepetition
Introduktion Litteratur Metode Resultater Diskussion KonklusionAnders Scheel Nielsen 50
Tekstur
Teksturrepetition Introduktion Litteratur Metode Resultater Diskussion KonklusionTeksturrepetition
Introduktion Litteratur Metode Resultater KonklusionAnders Scheel Nielsen 51
Teksturrepetition
Introduktion Introduktion Litteratur Metode Resultater KonklusionTeksturrepetition
Introduktion Litteratur Metode Resultater KonklusionAnders Scheel Nielsen 51
Teksturrepetition
Introduktion Introduktion Litteratur Metode Resultater KonklusionTeksturrepetition
Introduktion Litteratur Metode Resultater KonklusionAnders Scheel Nielsen 52
Resultater: Tekstur download
Resultater Introduktion Litteratur Metode Resultater Diskussion Konklusion