Presentation is loading. Please wait.

Presentation is loading. Please wait.

Fundamentals of Computer Graphics Part 9 Discrete Techniques prof.ing.Václav Skala, CSc. University of West Bohemia Plzeň, Czech Republic ©2002 Prepared.

Similar presentations


Presentation on theme: "Fundamentals of Computer Graphics Part 9 Discrete Techniques prof.ing.Václav Skala, CSc. University of West Bohemia Plzeň, Czech Republic ©2002 Prepared."— Presentation transcript:

1 Fundamentals of Computer Graphics Part 9 Discrete Techniques prof.ing.Václav Skala, CSc. University of West Bohemia Plzeň, Czech Republic ©2002 Prepared with Angel,E.: Interactive Computer Graphics – A Top Down Approach with OpenGL, Addison Wesley, 2001

2 Fundamentals of Computer Graphics2 Discrete techniques Polygons, lines and others primitives transformed, rasterized and displayed API enables major mapping texture mapping uses pattern to be put on a surface of an object bump mapping – smooth surface is distorted to get variation of the surface environmental mapping (reflection maps) – enables ray-tracing like output

3 Fundamentals of Computer Graphics3 Discrete techniques All three techniques rely on the map being stored as one-, two- or three-dimensional digital image (!!Texture mapping on a graphics card is limited!!) Causes ANTIALIASING errors buffer – a memory block with spatial resolution n x m and with k bits bitplane – single plane n x m with 1 bit only pixel – picture element

4 Fundamentals of Computer Graphics4 Texture Mapping Regular patterns are mapped to an object’s surface Two dimensional texture T(s,t) s, t – texture coordinates stored in texture memory as n x m array of texture elements - texels Texture map associate a unique point of T with each point on a geometric object – mapped to screen coordinates

5 Fundamentals of Computer Graphics5 Texture Mapping Difficulties: -mapping from texture to geometric coordinates -2D texture defined over a rectangular region in the texture space -> mapping to 3D region can be quite complex -rendering based on pixel-to-pixel approach – the inverse mapping from screen coordinates to texture coordinates is needed -because of shading – mapping areas-to-areas and not point-to- point is required -> antialising problems, moire patterns etc.

6 Fundamentals of Computer Graphics6 Texture Mapping pixel (x s, y s ) – corresponds to (x, y, z) on “curved” object problems with finding inverse mapping difficulties with mapping

7 Fundamentals of Computer Graphics7 Linear Mapping Most curved surfaces represented parametrically as p(u,v) = [x(u,v), y(u,v), z(u,v)] T a point in the texture map T(s,t) is to be mapped to a point on the surface p(u,v) by a linear map u = as + bt + c v = ds + et + f (if ae  bd mapping is invertible) -mapping is easy to use -it does not respect the curvature of the object

8 Fundamentals of Computer Graphics8 Linear Mapping Linear mapping is defined as: standard window-viewport approach.

9 Fundamentals of Computer Graphics9 Texture Mapping Two part mapping - steps 1.map the texture a simple 3D intermediate surface – cylinder cube, sphere etc. 2.the surface containing the mapped texture is mapped to the surface being rendered. Can be applied in geometric or parametric coordinates

10 Fundamentals of Computer Graphics10 Texture Mapping Suppose a cylinder x = r cos (2  u) y = r sin (2  u) z = v / h and u,v  (0,1) – then s = u & t = v we are able to map the texture WITHOUT distorting its shape for a sphere the Mercator projection can be used x = r cos (2  u) y = r sin (2  u) cos (2  v) z = r sin (2  u) sin (2  v)

11 Fundamentals of Computer Graphics11 Texture Mapping The second step is to map the texture values on the intermediate object to the desired surface Figure shows THREE possible strategies: texture value is projected on the surface in the normal direction inverse solution from the surface texture element is to be find according to the normal if the center of the object is known – intersection with intermediate surface is computed and texture value assigned

12 Fundamentals of Computer Graphics12 Texture Mapping in OpenGL OpenGL – many mapping options including 1D, 2D & 3D textures GLubyte my_texels [512][512]; /* generated somehow */ glTexImage2D(GL_TEXTURE, 0, 3, 512, 512, 0, GL_RGB, GL_UNSIGNED_BYTE, my_texels); /* 0 & 3 – level & components, 0 – border, format – see latter*/ glEnable(GL_TEXTURE_2D); /* enables texture mapping */

13 Fundamentals of Computer Graphics13 Texture Mapping in OpenGL 2D textures specification glTexImage2D(GL_TEXTURE, level, components, width, height, border, format, type, array); components (1 – 4 ) number of components RGBA to be affected with the map level & border – parameters for fine control

14 Fundamentals of Computer Graphics14 Texture Mapping in OpenGL glBegin(GL_QUAD); glTexCoord2f(0.0, 0.0); glVertex2f(x1, y1, z1); glTexCoord2f(1.0, 0.0); glVertex2f(x2, y2, z2); glTexCoord2f(0.0, 1.0); glVertex2f(x3, y3, z3); glTexCoord2f(1.0, 1.0); glVertex2f(x4, y4, z4); glEnd ( ); range of s, t changed to

15 Fundamentals of Computer Graphics15 Texture Mapping in OpenGL STOP HERE!!!


Download ppt "Fundamentals of Computer Graphics Part 9 Discrete Techniques prof.ing.Václav Skala, CSc. University of West Bohemia Plzeň, Czech Republic ©2002 Prepared."

Similar presentations


Ads by Google