Informationsteknologi Thursday, November 29, 2007Computer Graphics - Class 131 Today’s class Antialiasing Hidden surface removal Texture mapping.

Slides:



Advertisements
Similar presentations
Visible-Surface Detection(identification)
Advertisements

15.1 Si23_03 SI23 Introduction to Computer Graphics Lecture 15 – Visible Surfaces and Shadows.
16.1 Si23_03 SI23 Introduction to Computer Graphics Lecture 16 – Some Special Rendering Effects.
Graphics Pipeline.
Texture Mapping. Texturing  process that modifies the appearance of each point on a surface using an image or function  any aspect of appearance can.
Week 7 - Monday.  What did we talk about last time?  Specular shading  Aliasing and antialiasing.
1 Understanding of OpenGL TA: Dong Hyun Jeong Instructor : Dr. Kalpathi Subramanian Texture Mapping.
3D Graphics Rendering and Terrain Modeling
1 Computer Graphics Chapter 9 Rendering. [9]-2RM Rendering Three dimensional object rendering is the set of collective processes which make the object.
CS 551 / CS 645 Antialiasing. What is a pixel? A pixel is not… –A box –A disk –A teeny tiny little light A pixel is a point –It has no dimension –It occupies.
Computer Graphics - Class 10
Chapter 6: Vertices to Fragments Part 2 E. Angel and D. Shreiner: Interactive Computer Graphics 6E © Addison-Wesley Mohan Sridharan Based on Slides.
Texture Mapping CPSC /24/03 Abhijeet Ghosh.
Hofstra University1 Texture Motivation: to model realistic objects need surface detail: wood grain, stone roughness, scratches that affect shininess, grass,
OpenGL Texture Mapping
OpenGL Texture Mapping Ed Angel Professor of Computer Science, Electrical and Computer Engineering, and Media Arts University of New Mexico.
1 Lecture 12 Texture Mapping uploading of the texture to the video memory the application of the texture onto geometry.
OpenGL Texture Mapping April 16, Angel: Interactive Computer Graphics 3E © Addison-Wesley 2002 Basic Stragegy Three steps to applying a texture.
CS 4731: Computer Graphics Lecture 17: Texturing Emmanuel Agu.
Computer Graphics Inf4/MSc Computer Graphics Lecture 11 Texture Mapping.
Texture Mapping A way of adding surface details Two ways can achieve the goal:  Surface detail polygons: create extra polygons to model object details.
Computer Graphics Mirror and Shadows
1 Perception, Illusion and VR HNRS 299, Spring 2008 Lecture 19 Other Graphics Considerations Review.
Computer Graphics Inf4/MSc Computer Graphics Lecture 9 Antialiasing, Texture Mapping.
CGMB214: Introduction to Computer Graphics
Technology and Historical Overview. Introduction to 3d Computer Graphics  3D computer graphics is the science, study, and method of projecting a mathematical.
Computer Graphics Texture Mapping Eriq Muhammad Adams
2IV60 Computer Graphics set 10: Texture mapping Jack van Wijk TU/e.
CS 376 Introduction to Computer Graphics 04 / 11 / 2007 Instructor: Michael Eckmann.
Texture Mapping. Scope Buffers Buffers Various of graphics image Various of graphics image Texture mapping Texture mapping.
Computer Graphics An Introduction. What’s this course all about? 06/10/2015 Lecture 1 2 We will cover… Graphics programming and algorithms Graphics data.
Texture Mapping Course: Computer Graphics Presented by Fan Chen
Computer Graphics Ben-Gurion University of the Negev Fall 2012.
Mapping method Texture Mapping Environmental mapping (sphere mapping) (cube mapping)
An Interactive Introduction to OpenGL Programming Ed Angel
Shading & Texture. Shading Flat Shading The process of assigning colors to pixels. Smooth Shading Gouraud ShadingPhong Shading Shading.
Visible-Surface Detection Jehee Lee Seoul National University.
Rendering Overview CSE 3541 Matt Boggus. Rendering Algorithmically generating a 2D image from 3D models Raster graphics.
Texture Mapping. 2 Motivation A typical modern graphics card can handle 10s of millions of polygons a second. How many individual blades of grass are.
OpenGL Texture Mapping. 2 Objectives Introduce the OpenGL texture functions and options.
CS 480/680 Computer Graphics OpenGL Texture Mapping Dr. Frederick C Harris, Jr. Fall 2011.
Texture Mapping Drawing Pictures on Polygons. Texture Mapping.
111/17/ :24 UML Solution Involves Selection of Discrete Representation Values.
1 Perception and VR MONT 104S, Fall 2008 Lecture 21 More Graphics for VR.
2 COEN Computer Graphics I Evening’s Goals n Discuss displaying and reading image primitives n Describe texture mapping n Discuss OpenGL modes and.
Review on Graphics Basics. Outline Polygon rendering pipeline Affine transformations Projective transformations Lighting and shading From vertices to.
RENDERING Introduction to Shading models – Flat and Smooth shading – Adding texture to faces – Adding shadows of objects – Building a camera in a program.
Lecture 6 Rasterisation, Antialiasing, Texture Mapping,
CS 325 Introduction to Computer Graphics 04 / 12 / 2010 Instructor: Michael Eckmann.
Computing & Information Sciences Kansas State University Lecture 12 of 42CIS 636/736: (Introduction to) Computer Graphics CIS 636/736 Computer Graphics.
11/24/ :45 Graphics II Shadow Maps Reflections Session 5.
Where We Stand So far we know how to: –Transform between spaces –Rasterize –Decide what’s in front Next –Deciding its intensity and color.
2D Output Primitives Points Lines Circles Ellipses Other curves Filling areas Text Patterns Polymarkers.
Details of Texture Mapping Glenn G. Chappell U. of Alaska Fairbanks CS 381 Lecture Notes Monday, December 1, 2003.
Computer Graphics One of the central components of three-dimensional graphics has been a basic system that renders objects represented by a set of polygons.
Visible-Surface Detection Methods. To identify those parts of a scene that are visible from a chosen viewing position. Surfaces which are obscured by.
Texture Mapping CEng 477 Introduction to Computer Graphics.
Texture Mapping Fall, 2016.
Week 7 - Monday CS361.
Computer Graphics Chapter 9 Rendering.
Texture Mapping We can improve the realism of graphics models by mapping a texture pattern (image) onto the modeled object surface. We refer to this technique.
OpenGL Texture Mapping
3D Graphics Rendering PPT By Ricardo Veguilla.
OpenGL Texture Mapping
3D Game Programming Texture Mapping
OpenGL Texture Mapping
OpenGL Texture Mapping
Programming Textures Lecture 15 Fri, Sep 28, 2007.
3D Game Programming Texture Mapping
OpenGL Texture Mapping
Presentation transcript:

Informationsteknologi Thursday, November 29, 2007Computer Graphics - Class 131 Today’s class Antialiasing Hidden surface removal Texture mapping

Informationsteknologi Thursday, November 29, 2007Computer Graphics - Class 132 Aliasing Result of changes in the object being drawn that occur faster than the pixel spacing Antialiasing techniques attempt to minimize the effect Attempt to have an intensity proportional to the amount of the pixel covered by the line Computations of pixel area covered are complex and time consuming If speed is important, live with the aliasing or double the resolution (doubles the scan convert time for a line, quadruples the number of pixels, is typically faster than antialiasing the original resolution)

Informationsteknologi Thursday, November 29, 2007Computer Graphics - Class 133 Types of antialiasing Supersampling Area sampling Pixel phasing

Informationsteknologi Thursday, November 29, 2007Computer Graphics - Class 134 Supersampling Displayed pixels cover finite areas In the algorithms we have discussed the intensity of each pixel has been determined by a single point on the object boundary By supersampling, we obtain intensity information from multiple points that contribute to the overall intensity of a pixel

Informationsteknologi Thursday, November 29, 2007Computer Graphics - Class 135 Line segments Divide each pixel into a number of subpixels and count the number of subpixels that overlap the line path The intensity level for the displayed pixel is set to a value that is proportionate to the count obtained Can also consider finite width lines (with a width equal to a pixel) to get more levels of intensity

Informationsteknologi Thursday, November 29, 2007Computer Graphics - Class 136 Area sampling Pixel intensity is determined by calculating the areas of overlap of each pixel with the objects to be displayed

Informationsteknologi Thursday, November 29, 2007Computer Graphics - Class 137 Pixel phasing Some raster systems can address subpixel positions within the screen grid Smoothing is accomplished by moving pixel positions closer to the line path Electron beam is shifted by a fraction of a pixel diameter, typically ¼, ½, or ¾ This plots points closer to the true path of a line

Informationsteknologi Thursday, November 29, 2007Computer Graphics - Class 138 Intensity differences Diagonal lines appear to have lower intensities than horizontal or vertical lines with an equal number of pixels because the diagonal line is longer Antialiasing techniques automatically adjust for this

Informationsteknologi Thursday, November 29, 2007Computer Graphics - Class 139 Antialiasing in OpenGL glEnable (GL_POINT_SMOOTH); glEnable (GL_LINE_SMOOTH); glEnable (GL_POLYGON_SMOOTH);

Informationsteknologi Thursday, November 29, 2007Computer Graphics - Class 1310 Z-buffer algorithm One of the simplest hidden surface removal algorithms A two-dimensional array is allocated, with one element for each pixel in the window The values stored in this array will be the z values of the faces currently displayed on the screen at the pixels As each face is processed, the pixels it covers are determined

Informationsteknologi Thursday, November 29, 2007Computer Graphics - Class 1311 Z-buffer algorithm (cont.) The z values for the face at these pixels are computed and compared to the values already stored in the z-buffer If the new face’s z values are closer to the viewer (have smaller z values) then this face covers the previous face and its color is displayed on the screen (and its z values stored in the z-buffer) If not, we ignore the face However, a pixel-by-pixel approach is taken

Informationsteknologi Thursday, November 29, 2007Computer Graphics - Class 1312 Do it by scan line Initialize z-buffer to maximum distance from viewpoint Generate incremental equations for z for the polygons Each polygon can be represented by a plane equation of the form ax + by + cz + d = 0 Given two points on the plane, we can write the plane equation in differential form: a  x + b  y + c  z = 0

Informationsteknologi Thursday, November 29, 2007Computer Graphics - Class 1313 Do it by scan line (cont.) A scan line corresponds to a line of constant y so  y = 0 As we move across the scan line  x will remain constant (we are taking unit steps, corresponding to equal increments in window coordinates) So,  z = - (a/c)  x Note that this value only has to be computed once for each polygon

Informationsteknologi Thursday, November 29, 2007Computer Graphics - Class 1314 Depth sort An object space approach to hidden surface removal A variant of the painter’s algorithm (where the farthest thing is painted first, then the next closest, etc.) Sort polygons by farthest z value If the minimum z for a polygon is greater than the maximum z for all other polygons, it can be painted first

Informationsteknologi Thursday, November 29, 2007Computer Graphics - Class 1315 Depth sort (cont.) Otherwise, for polygons with z extents that overlap the one with largest z:  test x and y extents; if the x or y extents do not overlap the polygons do not obscure each other and the farthest one can be painted (if it survives all other overlapping z polygons)  if the farthest z polygon lies entirely on the opposite side of the plane (from the viewpoint) of the polygon being tested it can be painted (if it survives all other overlapping z polygons)

Informationsteknologi Thursday, November 29, 2007Computer Graphics - Class 1316 Depth sort (cont.)  if the projections of the polygons onto the x-y plane do not overlap, the farthest z polygon can be painted (if it survives all other overlapping z polygons)  otherwise, have intersecting polygons and need to determine the intersection details and break the polygons into pieces

Informationsteknologi Thursday, November 29, 2007Computer Graphics - Class 1317 Shadow buffers A variant of the z-buffer algorithm for generating shadows Initialize shadow buffer to maximum pseudodepth possible for each element Position a camera at the light source and rasterize each face in the scene, but only test the pseudodepth of each point

Informationsteknologi Thursday, November 29, 2007Computer Graphics - Class 1318 Rendering a face Render the face as usual, determining:  Pseudodepth from the light source  Index location in shadow buffer  Value stored in shadow buffer If shadow buffer value is less than pseudodepth the point is in shadow; determine its color using only ambient light Otherwise point is not in shadow and set its color using ambient, diffuse, and specular light

Informationsteknologi Thursday, November 29, 2007Computer Graphics - Class 1319 Features of texture mapping Makes images of 3-D objects more interesting and apparently more complex Diminishes the ‘shiny plastic’ effects of Phong shading Enables different objects to exhibit different surface properties (apart from color)

Informationsteknologi Thursday, November 29, 2007Computer Graphics - Class 1320 Reality vs. computer graphics Textures on real objects modulate both the surface and the color Most texture mappings in computer graphics modulate just the color Use repeating patterns or an image (called a texture map, and its individual elements are called texels)

Informationsteknologi Thursday, November 29, 2007Computer Graphics - Class 1321 Major considerations What attribute or parameter of the model or object is to be modulated to produce the desired textual effect? How is the texture mapping to be carried out?  A texture is defined in a texture domain  An object exists in world space  Need to define a mapping between the two Texture mapping requires special anti-aliasing treatment because it tends to produce worse aliasing artifacts than other techniques associated with image synthesis

Informationsteknologi Thursday, November 29, 2007Computer Graphics - Class 1322 Things you can modulate for texture Surface color (diffuse reflection coefficient) Specular and diffuse reflection coefficients (environment mapping) Surface normal perturbation (bump mapping) Transparency

Informationsteknologi Thursday, November 29, 2007Computer Graphics - Class 1323 Implementations Mapping from texture space to object space (usually 2-D to 3-D) and then performing the viewing projection to screen space Mapping directly from texture space to screen space (usually 2-D to 2-D)  Most attention has been paid to his method  An inverse mapping is commonly used, where the screen space is uniformly sampled and the inverse or pre-image of a pixel in texture space is formed

Informationsteknologi Thursday, November 29, 2007Computer Graphics - Class 1324 Procedural texture mapping Depending on the mapping and the object, many texels may map to one pixel or many pixels may map to one texel Can circumvent the mapping problems by employing procedural texture mapping For example, consider carving an object out of a solid block of material Given the points on the object’s surface, we can determine its texture by applying a mapping function to the coordinates An advantage to this approach is that it can be applied to objects of arbitrary complexity in a ‘coherent’ fashion (no discontinuities in texture will appear on the object)

Informationsteknologi Thursday, November 29, 2007Computer Graphics - Class 1325 Example program Program texgen.c displays a texture mapped teapot First, need to make the texture image For a 2-D image you need a rectangular array no less than 64x64, with each dimension being a power of 2 If you are going to specify r,g,b values for each texel, then each element of the rectangular array must contain 3 ints between 0 and 255 Study the makeImage() routine

Informationsteknologi Thursday, November 29, 2007Computer Graphics - Class 1326 Texture generation methods glPixelStorei (GL_UNPACK_ALIGNMENT, 1);  specifies the alignment requirement for the start of each pixel row in memory  1 = byte, 2 = even-numbered bytes, 4 = word, 8 = double word

Informationsteknologi Thursday, November 29, 2007Computer Graphics - Class 1327 Texture generation methods (cont.) glTexEnvi (GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE);  specifies how texture values are interpreted when a fragment is textured  first parameter must be GL_TEXTURE_ENV or GL_TEXTURE_FILTER_CONTROL  second parameter depends on first; here it is GL_TEXTURE_ENV_MODE  third parameter is one of GL_MODULATE, GL_DECAL, GL_BLEND, GL_ADD, GL_COMBINE or GL_REPLACE

Informationsteknologi Thursday, November 29, 2007Computer Graphics - Class 1328 Texture generation methods (cont.) glTexParameteri (GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT);  sets texture parameters  first parameter indicates if texture is 1D, 2D, or 3D  second parameter identifies the texture parameter being affected  third parameter specifies the parameter’s value (in the case of wrapping it can be GL_CLAMP, GL_CLAMP_TO_EDGE, GL_CLAMP_TO_BORDER, GL_REPEAT, or GL_MIRRORED_REPEAT )

Informationsteknologi Thursday, November 29, 2007Computer Graphics - Class 1329 Texture generation methods (cont.) glTexParameteri (GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);  controls what happens when a pixel maps to a texture area less than or equal to 1 texel  GL_NEAREST returns the texel closest (in distance) to center of pixel being textured  GL_LINEAR returns the weighted average of the four texels closest to the center of the pixel being textured

Informationsteknologi Thursday, November 29, 2007Computer Graphics - Class 1330 Texture generation methods (cont.) glTexImage2D (GL_TEXTURE_2D, 0, 3, ImageLength, ImageWidth, 0, GL_RGB, GL_UNSIGNED_BYTE, Image);  specifies a 2-D texture image  level (0) indicates level of detail number (0 is base; used for mipmaps)  components (3) specifies # of colors  length and width must be powers of 2 plus 2*border  border (0) specifies border width (0 or 1)  format specifies the format of pixel data  type specifies the type of pixel data  Image is a pointer to the image data in memory

Informationsteknologi Thursday, November 29, 2007Computer Graphics - Class 1331 Texture generation methods (cont.) glTexGeni (GL_S, GL_TEXTURE_GEN_MODE, GL_OBJECT_LINEAR); glTexGenfv (GL_S, GL_OBJECT_PLANE, sgenparams);  provides automatic texture coordinate generation  first parameter indicates which coordinate  second parameter indicates coordinate generation function or its parameters  third parameter indicates which generation mode or the coefficients for the linear combination of the object coordinates

Informationsteknologi Thursday, November 29, 2007Computer Graphics - Class 1332 Image files for textures Can also use image files for texture maps Example program also shows a targa file ( stone.tga ) being used as a texture map