1 / 20

Texture Compression

Texture Compression. Martin Kraus Visualization and Interactive Systems Group, Stuttgart. Texture Compression: Overview. Contents: Requirements for texture compression S3 Texture Compression (S3TC) Vector Quantization (VQ)

tonya
Download Presentation

Texture Compression

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Texture Compression Martin Kraus Visualization and Interactive Systems Group, Stuttgart

  2. Texture Compression: Overview Contents: • Requirements for texture compression • S3 Texture Compression (S3TC) • Vector Quantization (VQ) • Implementing VQ texture compression with programmable graphics hardware • Application: Volume Visualization

  3. Requirements for Texture Compression • Encoding/compression of texture maps: • Maximize compression rates, • Minimize information loss, • User-defined trade-off. • Access/decompression of texture maps: • Fast random access, • Simple decompression algorithm.

  4. S3 Texture Compression (S3TC) • A.k.a. DXTC in Microsoft’s DirectX API. • OpenGL extension: EXT_texture_compression_s3tc. • Hardware implementation in several graphics chips, e.g. • NVIDIA GeForce series, • ATI Radeon 7500.

  5. S3 Texture Compression (S3TC) • S3TC for RGB texture: Each block of 4 x 4 RGB pixels is encoded in 64 bits: Each 2-bit pixel code specifies the color of one pixel: 16 bits (5+6+5 for RGB) 32 bits (16 x 2 bits per pixel) 16 bits

  6. S3 Texture Compression (S3TC) • Compression ratio in this case: original RGB data of 4x4 block: 4 x 4 x 3 = 48 bytes compressed data: 64 bits = 8 bytes 6 : 1 ratio • More variants for RGBA data. • Advantages: • Simple encoding/decoding, • Data-independent. • Disadvantages: • Moderate compression ratios, • Block-artifacts, inappropriate for non-smooth data, • Fixed compression scheme.

  7. Vector Quantization (VQ) • Well established lossy compression technique, e.g. image formats with color palettes. See [Gersho 1992] for details about VQ. • Apart from palettes seldom employed for texture maps in hardware, e.g. PowerVR architecture. • Frequently employed for texture maps in software [Ning 1992, Levoy 1996].

  8. Vector Quantization (VQ) • Image formats with palettes specify for each pixel one index into a color palette (= codebook). index data decoded data palette (codebook)

  9. Vector Quantization (VQ) • Instead of one 3-D vector for the RGB color of one pixel, we can also encode 12-D vectors for the RGB colors of 2x2 pixels: 2 1 1 0 index data decoded data codebook

  10. Vector Quantization (VQ) • Compression ratio in this case: original RGB data of 2x2 block: 2 x 2 x 3 = 12 bytes index data for codebook of length 256: 1 byte 12 : 1 ratio • Advantages: • Higher compression ratios, • Less compression artifacts, • Length of codebook determines quality & comp. ratio. • Disadvantages: • Expensive encoding (codebook generation). • Less simple decoding.

  11. Implementing VQ with Prog. Graphics HW • 2D texture lookup with bilinear interpolation: • Nearest-neighbor texture lookup of up to 4 indices, • Nearest-neighbor dependent texture lookup of 4 entries of the codebook, • Bilinear interpolation. • Too expensive for current programmable graphics hardware. • But: nearest-neighbor 2D texture lookup can be implemented with per-pixel operations of current graphics hardware, i.e. ATI Radeon 8500.

  12. Implementing VQ with Prog. Graphics HW • Nearest-neighbor 2D texture lookup with VQ: • Lookup of index: Nearest-neighbor 2D texture lookup at (s,t) • Lookup in codebook: Nearest-neighbor, dependent 2D texture lookup at (s’,t’) • How to compute (s’,t’)? 2 1 t index data 1 0 s index 1 code- book t’ s’ color D1

  13. Implementing VQ with Prog. Graphics HW • Computation of (s’,t’) for codebook lookup: • Dim. of index data: Ns x Nt • Dim. of codebook: Nc • Compute (s0,t0) : s0= floor(s * Ns) / Ns t0= floor(t * Nt) / Nt • Scale offset from (s0,t0) to (s,t) and add index: s’= (s - s0)* Ns / Nc +index / Nc t’= (t - t0)* Nt 2 1 t index data t0 1 0 s s0 index 1 code- book t’ s’ color D1

  14. Implementing VQ with Prog. Graphics HW • How to implement a formula like s0= floor(s * Ns) / Ns t0= floor(t * Nt) / Nt s’= (s - s0)* Ns / Nc +index / Nc t’= (t - t0)* Nt • Note: Nc, Ns, and Nt are constants; thus, 1 / Ns, 1 / Nt, 1 / Nc, Ns / Nc are also constants. => Apart from floor only sums and products!

  15. Implementing VQ with Prog. Graphics HW • Implementation of floor(s * Ns) : 1-D functions can be implemented with 1-D textures. Apart from an addition this is a 1-D texture map for the identity function using nearest-neighbor interpolation! floor(s * Ns) s * Ns

  16. Implementing VQ with Prog. Graphics HW DirectX Pixel Shader 1.4 code, only for illustration tex r0,t0.xy // r0.r = index lookup (s,t) texcrd r1,t0 // r1.r = s, r1.g = t tex r2,t2.x // r2.r = s0 = floor(s * Ns) / Ns tex r3,t3.x // r3.r = t0 = floor(t * Nt) / Nt sub r2.r,r1,r2.r // r2.r = s – s0 sub r2.g,r1,r3.r // r2.g = t – t0 mul r2,r2,c1 // r2.r = (s – s0) * Ns / Nc // r2.g = (t – t0) * Nt mul r1,r0,c2 // r1.r = index / Nc // r1.g = 0 add r1,r2,r1 // r1.r = (s – s0) * Ns/Nc + index/Nc // r1.g = (t – t0) * Nt phase tex r1,r1.xy // dependent codebook lookup mov r0,r1 // set output color

  17. Application: Volume Visualization • Approach works also with 3-D textures! • It may be employed for texture-based volume visualization [Cabral 1994]. • Nearest-neighbor interpolation is often acceptable for large volumes. • Instead of 2 x 2 pixels, use 2 x 2 x 2 voxels. • With a codebook of length 256, a 5123 RGBA-volume is reduced to 2563 bytes = 16 MBytes, i.e. it fits easily into texture memory. • See [Kraus 2002] for more details.

  18. Application: Volume Visualization

  19. Discussion • Texture compression with vector quantization on programmable graphics hardware is possible. • But: Only with nearest-neighbor interpolation. • Main advantage compared to built-in texture compression: Programmer is in control!

  20. References [Cabral 1994] Brian Cabral, Nancy Cam, and Jim Foran. Accelerated Volume Rendering and Tomographic Reconstruction Using Texture Mapping Hardware. In Proceedings of 1994 Symposium on Volume Visualization, pages 91-97. [Gersho 1992] Allen Gersho and Robert M. Gray. Vector Quantization and Signal Compresssion. Kluwer Academic Publiushers, Boston, 1992. [Kraus 2002] Martin Kraus and Thomas Ertl. Adaptive Texture Maps. In Proceedings of SIGGRAPH/Eurographics Workshop on Graphics Hardware 2002. [Levoy 1996] Marc Levoy and Pat Hanrahan. Light Field Rendering. In Proceedings of SIGGRAPH ’96, pages 31-42. [Ning 1993] Paul Ning and Lambertus Hesselink. Vector Quantization for Volume Rendering. In Proceedings of 1992 Workshop on Volume Visualization, pages 69-74, 1992.

More Related