Presentation is loading. Please wait.

Presentation is loading. Please wait.

Computer Graphics Inf4/MSc Computer Graphics Lecture 9 Antialiasing, Texture Mapping.

Similar presentations


Presentation on theme: "Computer Graphics Inf4/MSc Computer Graphics Lecture 9 Antialiasing, Texture Mapping."— Presentation transcript:

1 Computer Graphics Inf4/MSc Computer Graphics Lecture 9 Antialiasing, Texture Mapping

2 Computer Graphics Inf4/MSc 2 Today Texture mapping –Common texture coordinates mapping –Texture coordinates Antialiasing Antialiasing-textures

3 Computer Graphics Inf4/MSc Texture Mapping : Why needed? We don't want to represent all this detail with colour / geometry

4 Computer Graphics Inf4/MSc 4 Texture mapping. Method of improving surface appearance by adding details on surface. Done at the rasterization stage

5 Computer Graphics Inf4/MSc Photo-textures

6 Computer Graphics Inf4/MSc Interpolating the uv coordinates Again, we use baricentric Coordinates u= α u 1 + β u 2 + γ u 3 v = α v 1 + β v 2 + γ v 3 Or scan conversion u 1 v 1 u 2 v 2 u 3 v 3 u 2 v 2 u 1 v 1

7 Computer Graphics Inf4/MSc What will the textured triangle look like?

8 Computer Graphics Inf4/MSc Interpolation - What Goes Wrong? texture sourcewhat we get|what we want Linear interpolation in screen space:

9 Computer Graphics Inf4/MSc Why does it happen? Uniform steps on the image plane does not correspond to uniform steps along the edge

10 Computer Graphics Inf4/MSc How do we deal with it? Use hyperbolic interpolation –(u,v) cannot be linearly interpolated, but 1/w and (u/w, v/w) can –w is the last component after the canonical view transformation –A w is computed for every 3D point

11 Computer Graphics Inf4/MSc Texture Mapping Examples Linear interpolation vs. Hyperbolic interpolation Two triangles per square

12 Computer Graphics Inf4/MSc In what case hyperbolic interpolation is essential? 1. ? 2. ?

13 Computer Graphics Inf4/MSc Common Texture Coordinate Mappings Orthogonal Cylindrical Spherical

14 Computer Graphics Inf4/MSc Texture Mapping & Illumination Texture mapping can be used to alter some or all of the constants in the illumination equation: – pixel color, diffuse color

15 Computer Graphics Inf4/MSc 15 Today Texture mapping Common texture coordinates mapping Texture coordinates Antialiasing Antialiasing textures

16 Computer Graphics Inf4/MSc 16 Anti-aliasing Aliasing: distortion artifacts produced when representing a high-resolution signal at a lower resolution. Anti-aliasing : techniques to remove aliasing Aliased polygons (jagged edges)‏ Anti-aliased polygons

17 Computer Graphics Inf4/MSc Nyquist Limit The signal frequency (f signal ) should be no greater than half the sample frequency (f sample ) f signal < 0.5 f sample In the top, f signal = 0.8 f sample -> cannot reconstruct the original signal In the bottom f signal =0.5 f sample -> the original signal can be reconstructed by slightly increasing the sampling rate

18 Computer Graphics Inf4/MSc 18 Each pixel is subdivided (sub-sampled) into n regions, and each sub-pixel has a color; Compute the average color value Screen-based Anti-aliasing

19 Computer Graphics Inf4/MSc Accumulation Buffer (A-Buffer)‏ Use a buffer that has the same resolution as the original image To obtain a 2x2 sampling of a scene, 4 images are made by shifting the buffer horizontally/vertically for half a pixel The results are accumulated and the final results are obtained by averaging Various sampling schemes are available Pixel center Subsampled point

20 Computer Graphics Inf4/MSc Different Sampling Schemes

21 Computer Graphics Inf4/MSc

22 Accumulation Buffer (A-Buffer)‏ The lighting computation is usually done only once per vertex Not doing the lighting computation at each sample point The A-buffer’s focus is on the edge anti- aliasing Also useful for rendering transparent objects, motion blur (will be covered later in the course) Edges

23 Computer Graphics Inf4/MSc Stochastic Sampling A scene can be produced of objects that are arbitrarily small A regular pattern of sampling will always exhibit some sort of aliasing By irregular sampling, the higher frequencies appear in the image as noise rather than aliases Humans are more sensitive to aliases than noise

24 Computer Graphics Inf4/MSc Stochastic Sampling One approach to solve this is to randomly sample over the pixels Jittering : subdivide into n regions of equal size and randomly sample inside each region Compute the colour at the sample and average Can precompute a table and recycle it or simply jitter on the fly

25 Computer Graphics Inf4/MSc Comparison

26 Computer Graphics Inf4/MSc 26 Today Texture mapping Common texture coordinates mapping Texture coordinates Antialiasing Antialiasing textures

27 Computer Graphics Inf4/MSc 27 Aliasing of textures Happens when the camera is zoomed too much into the textured surface (magnification)‏ Several texels (pixels of the texture) covering a pixel’s cell (minification)‏

28 Computer Graphics Inf4/MSc 28 Texture Magnification Zooming too much into a surface with a texture One texel covering many pixels

29 Computer Graphics Inf4/MSc 29 Bilinear Interpolation Mapping the pixel centre to the uv coordinates Computing the pixel colour by interpolating the surrounding texel values

30 Computer Graphics Inf4/MSc Bilinear Interpolation - 2 For (p u, p v ), compute its (u,v) coordinates by barycentric coordinates u = p u – (int)p u, v = p v - (int)p v x l = p u, x r = p u +1, y b = p v, y t = p v +1, –( p u, p v) : the pixel centre mapped into the texture space –b(p u, p v ) : the colour at point pu, pv –t(x,y) : the texel colour at (x,y) –u = p u – (int) p u, v = p v - (int) p v

31 Computer Graphics Inf4/MSc Texture Minification Which texture will cause more aliasing when mapped onto the floor?

32 Computer Graphics Inf4/MSc 32 Texture Minification Many texels covering a pixel’s cell Results in aliasing (remember Nyquist limit)‏ The artifacts are even more noticeable when the surface moves Solution Mipmapping

33 Computer Graphics Inf4/MSc 33 MIP map Multum In Parvo = Many things in a small place Produce a texture of multiple resolutions Switch the resolution according to the number of texels in one pixel Select a level that the ratio of the texture and the pixel is 1:1

34 Computer Graphics Inf4/MSc 34 Selecting the resolution in Mipmap Map the pixel corners to the texture space Find the resolution that roughly covers the mapped quadrilateral Apply a bilinear interpolation in that resolution, Or find the two surrounding resolutions and apply a trilinear interpolation (also along the resolution axis)‏

35 Computer Graphics Inf4/MSc 35 Texture Minification Multiple textures in a single pixel Solution: Nearest neighbour Bilinear blending Mipmapping

36 Computer Graphics Inf4/MSc Readings Chapter 5.1-2 of Real-Time Rendering Second edition –http://books.google.co.uk/books?id=mOKEfBT w4x0C&printsec=frontcover&source=gbs_v2_s ummary_r&cad=0#v=onepage&q=&f=falsehttp://books.google.co.uk/books?id=mOKEfBT w4x0C&printsec=frontcover&source=gbs_v2_s ummary_r&cad=0#v=onepage&q=&f=false “Hyperbolic Interpolation” IEEE Computer Graphics and Applications, vol12, no.4, 89- 94, 1992


Download ppt "Computer Graphics Inf4/MSc Computer Graphics Lecture 9 Antialiasing, Texture Mapping."

Similar presentations


Ads by Google