textures – image, solid and procedural -...
TRANSCRIPT
![Page 1: Textures – Image, Solid and Procedural - WPIweb.cs.wpi.edu/.../cs563/S07/talks/solid_proctextures_wk9_p1.pdf · CS 563 Advanced Topics in Computer Graphics Textures – Image, Solid](https://reader033.vdocuments.site/reader033/viewer/2022051600/5a9f63b77f8b9a71178cb389/html5/thumbnails/1.jpg)
CS 563 Advanced Topics in Computer Graphics
Textures – Image, Solid and Procedural
by Alex White
![Page 2: Textures – Image, Solid and Procedural - WPIweb.cs.wpi.edu/.../cs563/S07/talks/solid_proctextures_wk9_p1.pdf · CS 563 Advanced Topics in Computer Graphics Textures – Image, Solid](https://reader033.vdocuments.site/reader033/viewer/2022051600/5a9f63b77f8b9a71178cb389/html5/thumbnails/2.jpg)
Outline
§ Image Textures§ MIP Map§ Filter Methods
§ Solid and Procedural Textures§ Avoiding Aliasing§ Averaging§ Supersampling
![Page 3: Textures – Image, Solid and Procedural - WPIweb.cs.wpi.edu/.../cs563/S07/talks/solid_proctextures_wk9_p1.pdf · CS 563 Advanced Topics in Computer Graphics Textures – Image, Solid](https://reader033.vdocuments.site/reader033/viewer/2022051600/5a9f63b77f8b9a71178cb389/html5/thumbnails/3.jpg)
Image Textures
§ Images are used to enhance objects§ Unit name: Texels§ Texture images ambiguously termed “texture
maps”
![Page 4: Textures – Image, Solid and Procedural - WPIweb.cs.wpi.edu/.../cs563/S07/talks/solid_proctextures_wk9_p1.pdf · CS 563 Advanced Topics in Computer Graphics Textures – Image, Solid](https://reader033.vdocuments.site/reader033/viewer/2022051600/5a9f63b77f8b9a71178cb389/html5/thumbnails/4.jpg)
Texture Mapped Images
Physically Based Rendering - Figure 11.8 Wikipedia
![Page 5: Textures – Image, Solid and Procedural - WPIweb.cs.wpi.edu/.../cs563/S07/talks/solid_proctextures_wk9_p1.pdf · CS 563 Advanced Topics in Computer Graphics Textures – Image, Solid](https://reader033.vdocuments.site/reader033/viewer/2022051600/5a9f63b77f8b9a71178cb389/html5/thumbnails/5.jpg)
PBRT Implementation
§ Image maps = lots of memory§ Why especially in default for PBRT?
§ Texture caching alleviates some load§ However…the filter parameters must match
§ Implemented in PBRT as ImageTexture class§ Give it filename and three simple parameters§ If it cannot open or read the file, a map with
a single sample of 1 is created
![Page 6: Textures – Image, Solid and Procedural - WPIweb.cs.wpi.edu/.../cs563/S07/talks/solid_proctextures_wk9_p1.pdf · CS 563 Advanced Topics in Computer Graphics Textures – Image, Solid](https://reader033.vdocuments.site/reader033/viewer/2022051600/5a9f63b77f8b9a71178cb389/html5/thumbnails/6.jpg)
PBRT Implementation
§ ImageTexture::Evaluate handles the coordinate transformation
§ Takes a DifferentialGeometry§ Uses _____Mapping2D::Map§ Computes s,t and associated partial
derivatives§ Performs lookup on the created MIP Map§ Returns a value for that point
![Page 7: Textures – Image, Solid and Procedural - WPIweb.cs.wpi.edu/.../cs563/S07/talks/solid_proctextures_wk9_p1.pdf · CS 563 Advanced Topics in Computer Graphics Textures – Image, Solid](https://reader033.vdocuments.site/reader033/viewer/2022051600/5a9f63b77f8b9a71178cb389/html5/thumbnails/7.jpg)
MIP Map
§ The guts of Image Textures§ Handles reconstruction and filtering§ Trivia: MIP from Latin “multum in parvo”
§ Texture sampling vs. image (geometry) sampling§ No ray tracing required§ Only an array lookup§ Highest frequency already known§ No surprises
![Page 8: Textures – Image, Solid and Procedural - WPIweb.cs.wpi.edu/.../cs563/S07/talks/solid_proctextures_wk9_p1.pdf · CS 563 Advanced Topics in Computer Graphics Textures – Image, Solid](https://reader033.vdocuments.site/reader033/viewer/2022051600/5a9f63b77f8b9a71178cb389/html5/thumbnails/8.jpg)
Prefiltering
§ Many more texelsthan texture space sampling rate
§ However, this sampling rate varies spatially
§ No single prefilterfits all Figure 11.9
(s,t)
(dsdx,dtdx)
![Page 9: Textures – Image, Solid and Procedural - WPIweb.cs.wpi.edu/.../cs563/S07/talks/solid_proctextures_wk9_p1.pdf · CS 563 Advanced Topics in Computer Graphics Textures – Image, Solid](https://reader033.vdocuments.site/reader033/viewer/2022051600/5a9f63b77f8b9a71178cb389/html5/thumbnails/9.jpg)
MIP Maps Ease the Pain
§ MIP Map creates an image pyramid§ Instead of filtering over 50+ samples per ray§ Store images (each as ¼ size)
Wikipedia
![Page 10: Textures – Image, Solid and Procedural - WPIweb.cs.wpi.edu/.../cs563/S07/talks/solid_proctextures_wk9_p1.pdf · CS 563 Advanced Topics in Computer Graphics Textures – Image, Solid](https://reader033.vdocuments.site/reader033/viewer/2022051600/5a9f63b77f8b9a71178cb389/html5/thumbnails/10.jpg)
MIP Map Setup
§ Image dimensions need to be a power of 2§ What do we do?§ Upsample – (Lanczos works well)§ Important not to lose information § Since a continuous function, we can reconstruct
effectively
§ Get scaled images using a lowly box filter§ Average the 4 texels from more detailed level
§ Store in memory-access-efficient BlockedArray
![Page 11: Textures – Image, Solid and Procedural - WPIweb.cs.wpi.edu/.../cs563/S07/talks/solid_proctextures_wk9_p1.pdf · CS 563 Advanced Topics in Computer Graphics Textures – Image, Solid](https://reader033.vdocuments.site/reader033/viewer/2022051600/5a9f63b77f8b9a71178cb389/html5/thumbnails/11.jpg)
Isotropic Triangle Filter
§ Not high quality, but efficient§ Takes (s,t) coordinate and a filter width§ Yields a square to filter over§ Isotropic – does not support non-square or non-
axis aligned filter extents
§ Performs trilinear interpolation over nearest MIP Map levels
Figure 11.13
![Page 12: Textures – Image, Solid and Procedural - WPIweb.cs.wpi.edu/.../cs563/S07/talks/solid_proctextures_wk9_p1.pdf · CS 563 Advanced Topics in Computer Graphics Textures – Image, Solid](https://reader033.vdocuments.site/reader033/viewer/2022051600/5a9f63b77f8b9a71178cb389/html5/thumbnails/12.jpg)
Elliptically Weighted Average
§ EWA regarded as one of best texture filtering algorithms
§ Carefully derived from sampling theory§ Utilizes Gaussian filter§ Anisotropic – can adapt to sampling rates
Figure 11.15
(s,t)
(dsdx,dtdx)
![Page 13: Textures – Image, Solid and Procedural - WPIweb.cs.wpi.edu/.../cs563/S07/talks/solid_proctextures_wk9_p1.pdf · CS 563 Advanced Topics in Computer Graphics Textures – Image, Solid](https://reader033.vdocuments.site/reader033/viewer/2022051600/5a9f63b77f8b9a71178cb389/html5/thumbnails/13.jpg)
How is EWA Computed?
§ Use the partial derivatives to create major and minor axes§ Defines the ellipse
§ Compute the eccentricity§ Why?§ But end result may end up blurry§ The third parameter, maxAnisotropy, is used as a
scaling factor - higher values = less clamping§ Graphics cards implement 1x – 16x (though in a
different fashion - parallelogram vs ellipse)
![Page 14: Textures – Image, Solid and Procedural - WPIweb.cs.wpi.edu/.../cs563/S07/talks/solid_proctextures_wk9_p1.pdf · CS 563 Advanced Topics in Computer Graphics Textures – Image, Solid](https://reader033.vdocuments.site/reader033/viewer/2022051600/5a9f63b77f8b9a71178cb389/html5/thumbnails/14.jpg)
How is EWA Computed? (2)
§ Like in the Triangle Filter, EWA takes advantage of the MIP Map pyramid§ This time based on the length of the minor
axis§ The implicit equation for an ellipse:
FCtBstAstse <++= 22),(
![Page 15: Textures – Image, Solid and Procedural - WPIweb.cs.wpi.edu/.../cs563/S07/talks/solid_proctextures_wk9_p1.pdf · CS 563 Advanced Topics in Computer Graphics Textures – Image, Solid](https://reader033.vdocuments.site/reader033/viewer/2022051600/5a9f63b77f8b9a71178cb389/html5/thumbnails/15.jpg)
How is EWA Computed? (3)
§ Loop over candidate texels in bounding box§ Weight inside texels by Gaussian centered in
the middle of the ellipse§ Done with a Look-Up-Table§ Independent of coordinate space§ Exponential term computationally expensive
§ Sum each texel’s weight
![Page 16: Textures – Image, Solid and Procedural - WPIweb.cs.wpi.edu/.../cs563/S07/talks/solid_proctextures_wk9_p1.pdf · CS 563 Advanced Topics in Computer Graphics Textures – Image, Solid](https://reader033.vdocuments.site/reader033/viewer/2022051600/5a9f63b77f8b9a71178cb389/html5/thumbnails/16.jpg)
Triangle versus EWA
Figure 11.10
Notice the added detail where normals near perpendicularity?
Isotropic Triangle EWA
![Page 17: Textures – Image, Solid and Procedural - WPIweb.cs.wpi.edu/.../cs563/S07/talks/solid_proctextures_wk9_p1.pdf · CS 563 Advanced Topics in Computer Graphics Textures – Image, Solid](https://reader033.vdocuments.site/reader033/viewer/2022051600/5a9f63b77f8b9a71178cb389/html5/thumbnails/17.jpg)
Anisotropic Filtering
Trilinear MIP Mapping w/ Anisotropic Filtering
(Real-Time Graphics)Wikipedia
![Page 18: Textures – Image, Solid and Procedural - WPIweb.cs.wpi.edu/.../cs563/S07/talks/solid_proctextures_wk9_p1.pdf · CS 563 Advanced Topics in Computer Graphics Textures – Image, Solid](https://reader033.vdocuments.site/reader033/viewer/2022051600/5a9f63b77f8b9a71178cb389/html5/thumbnails/18.jpg)
Texture Filtering Comparison
www.extremetech.com - The Naked Truth About Anisotropic Filtering
(Real-Time Graphics)
![Page 19: Textures – Image, Solid and Procedural - WPIweb.cs.wpi.edu/.../cs563/S07/talks/solid_proctextures_wk9_p1.pdf · CS 563 Advanced Topics in Computer Graphics Textures – Image, Solid](https://reader033.vdocuments.site/reader033/viewer/2022051600/5a9f63b77f8b9a71178cb389/html5/thumbnails/19.jpg)
Solid/Procedural Textures
§ What do we do for the popular triangle meshes?§ They don’t have a natural (u,v) parameterization
§ The (s,t) image map coordinates can be computed by any arbitrary function
§ Solid textures – texture functions are generalized over 3-D domains
![Page 20: Textures – Image, Solid and Procedural - WPIweb.cs.wpi.edu/.../cs563/S07/talks/solid_proctextures_wk9_p1.pdf · CS 563 Advanced Topics in Computer Graphics Textures – Image, Solid](https://reader033.vdocuments.site/reader033/viewer/2022051600/5a9f63b77f8b9a71178cb389/html5/thumbnails/20.jpg)
Solid/Procedural Textures (2)
§ Travis discussed an interface to computer 3D texture coordinates (TextureMapping3D)§ Photos are easy 2D images§ Difficult to acquire 3D representations
§ Procedural texturing – small programs generate texture values are arbitrary positions§ Growing field§ Possibly infinite detail!
![Page 21: Textures – Image, Solid and Procedural - WPIweb.cs.wpi.edu/.../cs563/S07/talks/solid_proctextures_wk9_p1.pdf · CS 563 Advanced Topics in Computer Graphics Textures – Image, Solid](https://reader033.vdocuments.site/reader033/viewer/2022051600/5a9f63b77f8b9a71178cb389/html5/thumbnails/21.jpg)
The Ultimate Technique?
§ Unfortunately, subtle details of appearance can be hard to control
§ Antialiasing becomes a problem
§ Expensive evaluation
![Page 22: Textures – Image, Solid and Procedural - WPIweb.cs.wpi.edu/.../cs563/S07/talks/solid_proctextures_wk9_p1.pdf · CS 563 Advanced Topics in Computer Graphics Textures – Image, Solid](https://reader033.vdocuments.site/reader033/viewer/2022051600/5a9f63b77f8b9a71178cb389/html5/thumbnails/22.jpg)
Procedural Textures
§ UV Texture§ Map U to red§ Map V to green§ Get a smooth
color change§ Good for
debugging
![Page 23: Textures – Image, Solid and Procedural - WPIweb.cs.wpi.edu/.../cs563/S07/talks/solid_proctextures_wk9_p1.pdf · CS 563 Advanced Topics in Computer Graphics Textures – Image, Solid](https://reader033.vdocuments.site/reader033/viewer/2022051600/5a9f63b77f8b9a71178cb389/html5/thumbnails/23.jpg)
Procedural Textures
§ Checkerboard§ Alternating textures§ Passed in by user
§ ConstantTextures used here
![Page 24: Textures – Image, Solid and Procedural - WPIweb.cs.wpi.edu/.../cs563/S07/talks/solid_proctextures_wk9_p1.pdf · CS 563 Advanced Topics in Computer Graphics Textures – Image, Solid](https://reader033.vdocuments.site/reader033/viewer/2022051600/5a9f63b77f8b9a71178cb389/html5/thumbnails/24.jpg)
Avoiding Aliasing
§ Simplest case, filter box lies within one of the textures§ Compute bounding box on check§ Check with axis-aligned bounding box
Figure 11.20
![Page 25: Textures – Image, Solid and Procedural - WPIweb.cs.wpi.edu/.../cs563/S07/talks/solid_proctextures_wk9_p1.pdf · CS 563 Advanced Topics in Computer Graphics Textures – Image, Solid](https://reader033.vdocuments.site/reader033/viewer/2022051600/5a9f63b77f8b9a71178cb389/html5/thumbnails/25.jpg)
Lookup Method
§ Blend two subtextures§ Integrate the function to compute the average
value over some extent§ Complete each 1D direction and average
§ However can be incorrect§ Each subtexture
evaluates and antialiases as if completely visible
Figure 11.20
![Page 26: Textures – Image, Solid and Procedural - WPIweb.cs.wpi.edu/.../cs563/S07/talks/solid_proctextures_wk9_p1.pdf · CS 563 Advanced Topics in Computer Graphics Textures – Image, Solid](https://reader033.vdocuments.site/reader033/viewer/2022051600/5a9f63b77f8b9a71178cb389/html5/thumbnails/26.jpg)
Supersampling
§ Function is evaluated at a set of random stratified position around (s,t)§ 4 in s direction, 4 in t = 16 samples§ These are jittered to roughly cover the
surface area
§ Jitter values obtained though StratifiedSample2D()§ Shift by partial derivatives scaled by the jitter§ Finally, weight evaluated texture with a
Gaussian filter§ Sum the results
![Page 27: Textures – Image, Solid and Procedural - WPIweb.cs.wpi.edu/.../cs563/S07/talks/solid_proctextures_wk9_p1.pdf · CS 563 Advanced Topics in Computer Graphics Textures – Image, Solid](https://reader033.vdocuments.site/reader033/viewer/2022051600/5a9f63b77f8b9a71178cb389/html5/thumbnails/27.jpg)
Antialiasing Comparison
Figure 11.23a: No effort to remove high frequency variation
Figure 11.23b: Compute filter region and average texture function
One sample per pixel
![Page 28: Textures – Image, Solid and Procedural - WPIweb.cs.wpi.edu/.../cs563/S07/talks/solid_proctextures_wk9_p1.pdf · CS 563 Advanced Topics in Computer Graphics Textures – Image, Solid](https://reader033.vdocuments.site/reader033/viewer/2022051600/5a9f63b77f8b9a71178cb389/html5/thumbnails/28.jpg)
Antialiasing Comparison (2)
Figure 11.23b: Compute filter region and average texture function
Figure 11.23c: Supersampled 16 times
One sample per pixel
![Page 29: Textures – Image, Solid and Procedural - WPIweb.cs.wpi.edu/.../cs563/S07/talks/solid_proctextures_wk9_p1.pdf · CS 563 Advanced Topics in Computer Graphics Textures – Image, Solid](https://reader033.vdocuments.site/reader033/viewer/2022051600/5a9f63b77f8b9a71178cb389/html5/thumbnails/29.jpg)
Solid Checkerboard
§ A checkerboard, but in 3D cubes§ Object “carved out of”§ Checkerboard3D
Figure 11.27
![Page 30: Textures – Image, Solid and Procedural - WPIweb.cs.wpi.edu/.../cs563/S07/talks/solid_proctextures_wk9_p1.pdf · CS 563 Advanced Topics in Computer Graphics Textures – Image, Solid](https://reader033.vdocuments.site/reader033/viewer/2022051600/5a9f63b77f8b9a71178cb389/html5/thumbnails/30.jpg)
Review
§ MIP Maps§ Solve high frequency textures§ Average relatively small number of samples§ Only 1/3 more space
§ Isotropic Triangle Filter§ Quick and better than unfiltered§ Cannot show oblique surfaces in detail
§ Elliptically Weighted Average§ Preserves detail approaching perpendicual
normals§ Anisotropic (user controllable)
![Page 31: Textures – Image, Solid and Procedural - WPIweb.cs.wpi.edu/.../cs563/S07/talks/solid_proctextures_wk9_p1.pdf · CS 563 Advanced Topics in Computer Graphics Textures – Image, Solid](https://reader033.vdocuments.site/reader033/viewer/2022051600/5a9f63b77f8b9a71178cb389/html5/thumbnails/31.jpg)
Review (2)
§ Solid Textures are 3D maps§ Carved out of, rather than painted on
§ Procedual Textures utilize functions to calculate values at positions (2D or 3D)§ Can be powerful, provide immense detail§ Reduces memory requirements§ Expensive to calculate§ Introduces aliasing
![Page 32: Textures – Image, Solid and Procedural - WPIweb.cs.wpi.edu/.../cs563/S07/talks/solid_proctextures_wk9_p1.pdf · CS 563 Advanced Topics in Computer Graphics Textures – Image, Solid](https://reader033.vdocuments.site/reader033/viewer/2022051600/5a9f63b77f8b9a71178cb389/html5/thumbnails/32.jpg)
Review (3)
§ Procedural Antialiasing Techniques§ Use average area in box filter to weight§ Works fine for solid textures§ Can introduce “incorrectness” for others§ Guarantees no aliasing due to texture§ But prone to blurring
§ Supersampling§ Slower (multiple evaluations)§ Susceptible to aliasing (poor sampling)§ Less prone to blurring
![Page 33: Textures – Image, Solid and Procedural - WPIweb.cs.wpi.edu/.../cs563/S07/talks/solid_proctextures_wk9_p1.pdf · CS 563 Advanced Topics in Computer Graphics Textures – Image, Solid](https://reader033.vdocuments.site/reader033/viewer/2022051600/5a9f63b77f8b9a71178cb389/html5/thumbnails/33.jpg)
References
§ Physically Based Rendering. Pharr and Humphreys.§ Wikipedia. Assorted Entries§ www.extremetech.com.The Naked Truth
About Anisotropic Filtering.
![Page 34: Textures – Image, Solid and Procedural - WPIweb.cs.wpi.edu/.../cs563/S07/talks/solid_proctextures_wk9_p1.pdf · CS 563 Advanced Topics in Computer Graphics Textures – Image, Solid](https://reader033.vdocuments.site/reader033/viewer/2022051600/5a9f63b77f8b9a71178cb389/html5/thumbnails/34.jpg)
Questions?