CS 354
Compression &
Project 2
Mark Kilgard
University of Texas
March 27, 2012
CS 354                                          2



         Today’s material
        In-class quiz
            On shadows + scene graph lecture
        Lecture topic
          Project 2
          Compression for Computer Graphics
CS 354                            3



         My Office Hours
        Tuesday, before class
            Painter (PAI) 5.35
            8:45 a.m. to 9:15
        Thursday, after class
            ACE 6.302
            11:00 a.m. to 12


        Randy’s office hours
            Monday & Wednesday
            11 a.m. to 12:00
            Painter (PAI) 5.33
CS 354                                                             4



         Last time, this time
        Last lecture, we discussed
          Shadow generation algorithms
          Scene graph
                Data structures to organize the rendering of 3D
                 scenes
        This lecture
          Project 2 on Programmable Shaders
          Compression for Computer Graphics
CS 354                                                                             5

                                     On a sheet of paper
         Daily Quiz                  • Write your EID, name, and date
                                     • Write #1, #2, #3, #4 followed by its answer

        Multiple choice: Which is not         Name the dark and less dark
         a form of culling used in scene        regions of a shadow generated
         graph implementations                  by an area light source.

         a) network video culling
         b) view frustum culling               Multiple choice: When a scene
                                                graph implementation has
         c) occlusion culling                   profiling to visualize the depth
                                                complexity of a scene, that
         d) portal culling                      means:
                                                a) Monitoring the maximum
        True or False: Zpass shadow            stack depth to avoid overflows
         volume rendering has
         catastrophic artifacts when            b) Counting and displaying how
         shadow volumes are clipped by          many times each pixel in the
         the near clip plane.                   framebuffer is updated during a
                                                frame
                                                c) Underwater rendering
CS 354                                                                            6



         Mid-term Feedback
        Look for answer key on web site

                                               Percentage Grade Distribution
          Mid-term feedback           16
          Total questions:  43        14
          Maximum possible: 83
                                      12

           Top grade:          75     10

           Median:             59.0   8
           Average:            58.0   6
           Standard deviation: 9.63
                                      4
                                      2
                                      0
                                           40-49 50-59 60-69 70-79 80-89 90-100
CS 354                                                                   7



         Project 2
        Look for assignment on the web site
            PDF + code to use
        Requirements
          Mostly writing GLSL shaders
          Small amount of C/C++ code
                 Convert height map to normal map
        Intermediate milestone
            April 2nd
                 Submit snapshots and GLSL code for first two shaders
        Complete project
            Due April 6th
                 All 8 shaders
                 Embellish for additional credit
CS 354                               8



         What project code renders
CS 354                                                        9



         Your job
        Write torus shader
          Wrap a flat patch into a torus
          Compute lighting vectors
               tangent, bi-normal, normal
               light vector, eye vector, half-angle vector

        Write fragment shaders to implement
         various lighting effects
            ambient, diffuse, specular, reflection, decal
CS 354                                                  10

         Procedurally Generating a
         Torus from a 2D Grid




         2D grid over (s,t)∈[0,1]
                                    Tessellated torus
CS 354                   11



         Bumpy Diffuse
CS 354                            12



         Bumpy reflection combo
CS 354                                  13

         Compression in
         Computer Graphics
        Why?
          Lots of data
          Bandwidth intensive
        Strategies to deal with data
          Compact representations
          Mesh compression
          Image compression
          Framebufffer compression
CS 354                                      14



         Numerics
      Poor Man’s Compression…
      Fixed-point
            4-bit, 8-bit, 16-bit, etc.
        Floating-point
          Single precision, 32-bit s23e8
          Half-precision, 16-bit s10e5
CS 354                                                            15



         Image Compression
        Lossless compression
          Entropy encoding
          Run-length encoding
                Good when images are repetitive in X direction
        Lossy compression
            Palette schemes
                Vector quantization approaches
            Discrete Cosine Transform schemes
                JPEG
            Wavelet schemes
CS 354                                            16



         JPEG Compression
        Compression and Decompression pipeline
CS 354                                                    17



         Color Space
        YUV, YIQ
          Maintain chrominance data at lower precision
           and frequency than luminance data
          Recall this from color space discussion
          TV and digital video standards rely on this
CS 354                                               18



         Chroma Sampling
        Store chrominance data at lower precision
         and frequency than luminance data
CS 354                                                                    19



         Geometry Compression
        Along with images, geometric models are also
         very data-intensive
        Strategies
            Avoid vertex redundancies
            Scalar quantization
            Compact vertex attribute choices
            Mesh simplification
                 Whether automatic or manual
            Progressive representations
            Higher-level primitives
                 Saying a “sphere of radius 5 at (x,y,z)” is much more
                  compact (and exact) than its tessellation
CS 354                         20



         Mesh Simplification
CS 354                                           21

         Progressive Meshes

        Incrementally transition between mesh
         Levels-of-Detail (LOD)
            Avoids “popping” artifacts
CS 354                                                   22



         Progressive Mesh Geomorph
        Interpolate smoothly between model
         level-of-details




                                       Edge collapse &
                                       vertex split
CS 354                                                                      23


         Amplification of Standard
         Triangle Meshes
                                                      Tessellation
                                                      results in triangle
                                                      amplification
                                                      with curvature




          Original faceted mesh
                                   Results of Phong
                                  shading of curved
CS 354                                                24



         Normal Compression
        Floating-point for normalized normals is
         incredibly wasteful
          Half-precision values
          10-10-10 signed fixed point
          Palette of normals




                                     [Deering 1995]
CS 354                                                         25



         Texture Compression
        Conventional image compression
            For storage and transmission
        Texture mapping
          Requires random access
          For storage and reduced bandwidth
          So tends to use “block” schemes
                 Often 4:1 compression relying on 4x4 tiles
            Assumes lossy compression
CS 354                                        26



         DXT1 Compression
        4:1 compression blocking artifacts




    DXT1 Compressed            Uncompressed
CS 354                                                                                                                    27

                           GeForce Peak
                           Memory Bandwidth Trends
                          200
                                                          128-bit interface        256-bit interface
                          180



                                                                                                         Raw
                          160                                                                            bandwidth
   Gigabytes per second




                          140

                                                                                                         Effective raw
                                                                                                         bandwidth
                          120
                                                                                                         with
                                                                                                         compression
                          100
                                                                                                         Expon.
                                                                                                         (Effective raw
                                                                                                         bandwidth
                          80
                                                                                                         with
                                                                                                         compression)
                          60
                                                                                                         Expon. (Raw
                                                                                                         bandwidth)

                          40




                          20




                           0
                                GeForce2   GeForce3   GeForce4 T i GeForce FX    GeForce      GeForce
                                  GT S                   4600                   6800 Ultra   7800 GT X
CS 354                                                        28

         Effective GPU
         Memory Bandwidth
        Compression schemes
          Lossless depth and color (when multisampling)
           compression
          Lossy texture compression (S3TC / DXTC)
          Typically assumes 4:1 compression
        Avoidance useless work
          Early killing of fragments (Z cull)
          Avoiding useless blending and texture fetches
        Very clever memory controller designs
          Combining memory accesses for improved coherency
          Caches for texture fetches
CS 354                                              29



         Multi-sample Coverage Positions




              1x      4x jittered     8x jittered
          (aliased)




                      4x orthogonal
CS 354                                                           30



         Depth Values Compress Well
        Linear values
            Store plane equations instead of point samples
        Smooth transitions, discrete edges




              Rendered view                  Depth buffer view
CS 354                                               31



         Next Class
        Project 2 today (!?)
            On texturing, shading, & lighting
            Study GLSL
            Two weeks to complete
        Next lecture
            Interaction
            How do users interact with 3D scenes?

CS 354 Project 2 and Compression

  • 1.
    CS 354 Compression & Project2 Mark Kilgard University of Texas March 27, 2012
  • 2.
    CS 354 2 Today’s material  In-class quiz  On shadows + scene graph lecture  Lecture topic  Project 2  Compression for Computer Graphics
  • 3.
    CS 354 3 My Office Hours  Tuesday, before class  Painter (PAI) 5.35  8:45 a.m. to 9:15  Thursday, after class  ACE 6.302  11:00 a.m. to 12  Randy’s office hours  Monday & Wednesday  11 a.m. to 12:00  Painter (PAI) 5.33
  • 4.
    CS 354 4 Last time, this time  Last lecture, we discussed  Shadow generation algorithms  Scene graph  Data structures to organize the rendering of 3D scenes  This lecture  Project 2 on Programmable Shaders  Compression for Computer Graphics
  • 5.
    CS 354 5 On a sheet of paper Daily Quiz • Write your EID, name, and date • Write #1, #2, #3, #4 followed by its answer  Multiple choice: Which is not  Name the dark and less dark a form of culling used in scene regions of a shadow generated graph implementations by an area light source. a) network video culling b) view frustum culling  Multiple choice: When a scene graph implementation has c) occlusion culling profiling to visualize the depth complexity of a scene, that d) portal culling means: a) Monitoring the maximum  True or False: Zpass shadow stack depth to avoid overflows volume rendering has catastrophic artifacts when b) Counting and displaying how shadow volumes are clipped by many times each pixel in the the near clip plane. framebuffer is updated during a frame c) Underwater rendering
  • 6.
    CS 354 6 Mid-term Feedback  Look for answer key on web site Percentage Grade Distribution Mid-term feedback 16 Total questions: 43 14 Maximum possible: 83 12 Top grade: 75 10 Median: 59.0 8 Average: 58.0 6 Standard deviation: 9.63 4 2 0 40-49 50-59 60-69 70-79 80-89 90-100
  • 7.
    CS 354 7 Project 2  Look for assignment on the web site  PDF + code to use  Requirements  Mostly writing GLSL shaders  Small amount of C/C++ code  Convert height map to normal map  Intermediate milestone  April 2nd  Submit snapshots and GLSL code for first two shaders  Complete project  Due April 6th  All 8 shaders  Embellish for additional credit
  • 8.
    CS 354 8 What project code renders
  • 9.
    CS 354 9 Your job  Write torus shader  Wrap a flat patch into a torus  Compute lighting vectors  tangent, bi-normal, normal  light vector, eye vector, half-angle vector  Write fragment shaders to implement various lighting effects  ambient, diffuse, specular, reflection, decal
  • 10.
    CS 354 10 Procedurally Generating a Torus from a 2D Grid 2D grid over (s,t)∈[0,1] Tessellated torus
  • 11.
    CS 354 11 Bumpy Diffuse
  • 12.
    CS 354 12 Bumpy reflection combo
  • 13.
    CS 354 13 Compression in Computer Graphics  Why?  Lots of data  Bandwidth intensive  Strategies to deal with data  Compact representations  Mesh compression  Image compression  Framebufffer compression
  • 14.
    CS 354 14 Numerics  Poor Man’s Compression…  Fixed-point  4-bit, 8-bit, 16-bit, etc.  Floating-point  Single precision, 32-bit s23e8  Half-precision, 16-bit s10e5
  • 15.
    CS 354 15 Image Compression  Lossless compression  Entropy encoding  Run-length encoding  Good when images are repetitive in X direction  Lossy compression  Palette schemes  Vector quantization approaches  Discrete Cosine Transform schemes  JPEG  Wavelet schemes
  • 16.
    CS 354 16 JPEG Compression  Compression and Decompression pipeline
  • 17.
    CS 354 17 Color Space  YUV, YIQ  Maintain chrominance data at lower precision and frequency than luminance data  Recall this from color space discussion  TV and digital video standards rely on this
  • 18.
    CS 354 18 Chroma Sampling  Store chrominance data at lower precision and frequency than luminance data
  • 19.
    CS 354 19 Geometry Compression  Along with images, geometric models are also very data-intensive  Strategies  Avoid vertex redundancies  Scalar quantization  Compact vertex attribute choices  Mesh simplification  Whether automatic or manual  Progressive representations  Higher-level primitives  Saying a “sphere of radius 5 at (x,y,z)” is much more compact (and exact) than its tessellation
  • 20.
    CS 354 20 Mesh Simplification
  • 21.
    CS 354 21 Progressive Meshes  Incrementally transition between mesh Levels-of-Detail (LOD)  Avoids “popping” artifacts
  • 22.
    CS 354 22 Progressive Mesh Geomorph  Interpolate smoothly between model level-of-details Edge collapse & vertex split
  • 23.
    CS 354 23 Amplification of Standard Triangle Meshes Tessellation results in triangle amplification with curvature Original faceted mesh Results of Phong shading of curved
  • 24.
    CS 354 24 Normal Compression  Floating-point for normalized normals is incredibly wasteful  Half-precision values  10-10-10 signed fixed point  Palette of normals [Deering 1995]
  • 25.
    CS 354 25 Texture Compression  Conventional image compression  For storage and transmission  Texture mapping  Requires random access  For storage and reduced bandwidth  So tends to use “block” schemes  Often 4:1 compression relying on 4x4 tiles  Assumes lossy compression
  • 26.
    CS 354 26 DXT1 Compression  4:1 compression blocking artifacts DXT1 Compressed Uncompressed
  • 27.
    CS 354 27 GeForce Peak Memory Bandwidth Trends 200 128-bit interface 256-bit interface 180 Raw 160 bandwidth Gigabytes per second 140 Effective raw bandwidth 120 with compression 100 Expon. (Effective raw bandwidth 80 with compression) 60 Expon. (Raw bandwidth) 40 20 0 GeForce2 GeForce3 GeForce4 T i GeForce FX GeForce GeForce GT S 4600 6800 Ultra 7800 GT X
  • 28.
    CS 354 28 Effective GPU Memory Bandwidth  Compression schemes  Lossless depth and color (when multisampling) compression  Lossy texture compression (S3TC / DXTC)  Typically assumes 4:1 compression  Avoidance useless work  Early killing of fragments (Z cull)  Avoiding useless blending and texture fetches  Very clever memory controller designs  Combining memory accesses for improved coherency  Caches for texture fetches
  • 29.
    CS 354 29 Multi-sample Coverage Positions 1x 4x jittered 8x jittered (aliased) 4x orthogonal
  • 30.
    CS 354 30 Depth Values Compress Well  Linear values  Store plane equations instead of point samples  Smooth transitions, discrete edges Rendered view Depth buffer view
  • 31.
    CS 354 31 Next Class  Project 2 today (!?)  On texturing, shading, & lighting  Study GLSL  Two weeks to complete  Next lecture  Interaction  How do users interact with 3D scenes?