packing square tiles into one texture eurographics 2004 philippe decaudin fabrice neyret...
TRANSCRIPT
Packing Square Tiles Packing Square Tiles into One Textureinto One Texture
Eurographics 2004Eurographics 2004
Philippe Decaudin Fabrice NeyretPhilippe Decaudin Fabrice Neyret GRAVIR/IMAG-INRIA, Grenoble, FranceGRAVIR/IMAG-INRIA, Grenoble, France
?
2 Packing Square Tiles into One Texture EG ’04
IntroductionIntroduction
AimAim Pack square texture tiles of the same size into 1 texturePack square texture tiles of the same size into 1 texture Reduce space lossReduce space loss
Packing is importantPacking is important Graphic context switching Graphic context switching performance penalty performance penalty Easier to manage one texture instead of a setEasier to manage one texture instead of a set
10tiles
3 Packing Square Tiles into One Texture EG ’04
Introduction (Introduction (contcont.).)
Why packing Why packing NN tiles with no space loss is difficult ? tiles with no space loss is difficult ? Texture size is constrainedTexture size is constrained
ww // h = 2h = 2 ii w and h are bounded (w and h are bounded (<<
4096)4096)
For others For others NN, efficient schemes are not obvious…, efficient schemes are not obvious…
Trivial packing with no space loss: Trivial packing with no space loss: NN == 22nn and and NN == nn22
N = 20 21 22 23 24 … N = 22 32 …
4 Packing Square Tiles into One Texture EG ’04
Packing an arbitrary number of tilesPacking an arbitrary number of tiles
Space loss can be substantialSpace loss can be substantial E.g.,E.g., packing 5 tiles packing 5 tiles
10 tiles 17 tiles
Best known packingsBest known packings [Jennings’95, Fridman’98][Jennings’95, Fridman’98] Complex schemesComplex schemes And still space lostAnd still space lost
37% unused 55% unused
5 Packing Square Tiles into One Texture EG ’04
Our packing schemeOur packing scheme
We propose a packing scheme with no loss for many We propose a packing scheme with no loss for many NN Ranges of uncovered numbers are smallRanges of uncovered numbers are small
loss greatly reduced for other values of loss greatly reduced for other values of NN
The trick: texture space has special propertiesThe trick: texture space has special properties Torus topologyTorus topology texture addresses wrap texture addresses wrap
((GL_REPEATGL_REPEAT or or D3DADDRESS_WRAPD3DADDRESS_WRAP))
Can be rotatedCan be rotated
6 Packing Square Tiles into One Texture EG ’04
?
Using these properties, 2 tiles can be packed into 1 square textureUsing these properties, 2 tiles can be packed into 1 square texture
Basic exampleBasic example
7 Packing Square Tiles into One Texture EG ’04
2, 2, 22nn and and nn22 packing schemes packing schemes
22nn scheme scheme nn22 scheme scheme 2 scheme2 scheme
2 4 8
Packing schemes can be combinedPacking schemes can be combined E.g.,E.g.,
8 Packing Square Tiles into One Texture EG ’04
GeneralizationGeneralization
We can define We can define ((nn22 + + kk22) …) …
First, let consider the packing of 5 tiles (2First, let consider the packing of 5 tiles (222 ++ 1122))
9 Packing Square Tiles into One Texture EG ’04
here,n=3k=2
n
k
nk
The The ((nn22 + + kk22) packing scheme, with ) packing scheme, with kk nn
nn nn square subdivided by 2 sets of parallel slanted lines square subdivided by 2 sets of parallel slanted lines
13 tiles(n2+k2)
This construction results in This construction results in nn22 ++ kk22 square tiles square tiles Proof is in the paperProof is in the paper
k=1 10 tiles
k=0 9 tiles
k=3 18 tiles
10 Packing Square Tiles into One Texture EG ’04
Reachable numbersReachable numbers
((nn22 + + kk22) schemes provide a dense set of reachable ) schemes provide a dense set of reachable NN with no loss with no loss
By combining these schemes, any tiles number By combining these schemes, any tiles number
of the form can be reached (of the form can be reached (kki i < < nnii , , ppii positive int.) positive int.) i
pii
ikn )( 22
11 Packing Square Tiles into One Texture EG ’04
ConclusionConclusion
We have shown that We have shown that NN tiles can be packed into 1 texture tiles can be packed into 1 texture
with no space loss for all with no space loss for all NN of the form of the form i
pii
ikn )( 22
Allows many more possible schemes for no loss packing than Allows many more possible schemes for no loss packing than the common schemesthe common schemes
Could be extended to 3D textures for cubic tilesCould be extended to 3D textures for cubic tiles
space saved for volume data could be consequentialspace saved for volume data could be consequential[Kraus-Ertl’02, Lefebvre-Neyret’03][Kraus-Ertl’02, Lefebvre-Neyret’03]
For an arbitrary For an arbitrary NN, it provides a packing with little loss, it provides a packing with little loss
12 Packing Square Tiles into One Texture EG ’04
Thanks…Thanks…
http://www-imagis.imag.fr/Publications/2004/DN04bhttp://www-imagis.imag.fr/Publications/2004/DN04b
Questions ?
13 Packing Square Tiles into One Texture EG ’04
Reachable numbers (Reachable numbers (cont.cont.))
Similarities with prime factor decomposition, with some gaps.Similarities with prime factor decomposition, with some gaps.
Some primes missing: 3, 7, 11, 19, 23,…Some primes missing: 3, 7, 11, 19, 23,…