Download presentation
Presentation is loading. Please wait.
Published byGwen Gray Modified over 9 years ago
1
Computing & Information Sciences Kansas State University Lecture 12 of 42CIS 636/736: (Introduction to) Computer Graphics CIS 636/736 Computer Graphics Lecture 12 of 42 William H. Hsu Department of Computing and Information Sciences, KSU KSOL course pages: http://snipurl.com/1y5gchttp://snipurl.com/1y5gc Course web site: http://www.kddresearch.org/Courses/CIS636http://www.kddresearch.org/Courses/CIS636 Instructor home page: http://www.cis.ksu.edu/~bhsuhttp://www.cis.ksu.edu/~bhsu Readings: All slides from SIGGRAPH 2000 tutorial on OpenGL, Shreiner, Angel, Shreiner: http://www.cs.unm.edu/~angel/SIGGRAPH/ http://www.cs.unm.edu/~angel/SIGGRAPH/ Sections 2.6, 3.1, 20.3 – 20.13, Eberly 2 e – see http://snurl.com/1ye72http://snurl.com/1ye72 NeHe tutorials: 6 – 10, http://nehe.gamedev.nethttp://nehe.gamedev.net Article: http://www.kuro5hin.org/story/2003/10/28/9853/1617http://www.kuro5hin.org/story/2003/10/28/9853/1617 Surface Detail 5: Pixel and Vertex Programs
2
Computing & Information Sciences Kansas State University Lecture 12 of 42CIS 636/736: (Introduction to) Computer Graphics Lecture Outline Based in part on OpenGL Tutorials from SIGGRAPH 2000 Vicki Shreiner: Animation and Depth Buffering Double buffering Illumination: light positioning, light models, attenuation Material properties Animation basics in OpenGL Vicki Shreiner: Imaging and Raster Primitives Ed Angel: Texture Mapping Dave Shreiner: Advanced Topics Display lists and vertex arrays Accumulation buffer Fog Stencil buffering Fragment programs (to be concluded in Tutorial 3)
3
Computing & Information Sciences Kansas State University Lecture 12 of 42CIS 636/736: (Introduction to) Computer Graphics Lighting Dave Shreiner
4
Computing & Information Sciences Kansas State University Lecture 12 of 42CIS 636/736: (Introduction to) Computer Graphics Lighting Principles Lighting simulates how objects reflect light material composition of object light’s color and position global lighting parameters ambient light two sided lighting available in both color index and RGBA mode
5
Computing & Information Sciences Kansas State University Lecture 12 of 42CIS 636/736: (Introduction to) Computer Graphics Surface Normals Normals define how a surface reflects light glNormal3f( x, y, z ) Current normal is used to compute vertex’s color Use unit normals for proper lighting scaling affects a normal’s length glEnable( GL_NORMALIZE ) or glEnable( GL_RESCALE_NORMAL ) CPU DL Poly. Per Vertex Per Vertex Raster Frag FB Pixel Texture
6
Computing & Information Sciences Kansas State University Lecture 12 of 42CIS 636/736: (Introduction to) Computer Graphics Light Properties glLightfv( light, property, value ); light specifies which light multiple lights, starting with GL_LIGHT0 glGetIntegerv( GL_MAX_LIGHTS, &n ); properties colors position and type attenuation
7
Computing & Information Sciences Kansas State University Lecture 12 of 42CIS 636/736: (Introduction to) Computer Graphics Light Sources Light color properties GL_AMBIENT GL_DIFFUSE GL_SPECULAR
8
Computing & Information Sciences Kansas State University Lecture 12 of 42CIS 636/736: (Introduction to) Computer Graphics Turning on the Lights Flip each light’s switch glEnable( GL_LIGHT n ); Turn on power glEnable( GL_LIGHTING );
9
Computing & Information Sciences Kansas State University Lecture 12 of 42CIS 636/736: (Introduction to) Computer Graphics Light Material Tutorial
10
Computing & Information Sciences Kansas State University Lecture 12 of 42CIS 636/736: (Introduction to) Computer Graphics Controlling a Light’s Position Modelview matrix affects a light’s position Different effects based on when position is specified eye coordinates world coordinates model coordinates Push and pop matrices to uniquely control a light’s position
11
Computing & Information Sciences Kansas State University Lecture 12 of 42CIS 636/736: (Introduction to) Computer Graphics Light Position Tutorial
12
Computing & Information Sciences Kansas State University Lecture 12 of 42CIS 636/736: (Introduction to) Computer Graphics Frame Buffer Rasterization (including Pixel Zoom) Per Fragment Operations TextureM emory Pixel-Transfer Operations (and Pixel Map) CPU Pixel Storage Modes glReadPixels(), glCopyPixels() glBitmap(), glDrawPixels() glCopyTex*Image(); Pixel Pipeline Programmable pixel storage and transfer operations CPU DL Poly. Per Vertex Per Vertex Raster Frag FB Pixel Texture
13
Computing & Information Sciences Kansas State University Lecture 12 of 42CIS 636/736: (Introduction to) Computer Graphics Texture Mapping Ed Angel
14
Computing & Information Sciences Kansas State University Lecture 12 of 42CIS 636/736: (Introduction to) Computer Graphics Texture Mapping CPU DL Poly. Per Vertex Per Vertex Raster Frag FB Pixel Texture Apply 1-D, 2-D, or 3-D image to geometric primitives Uses of Texturing simulating materials reducing geometric complexity image warping reflections
15
Computing & Information Sciences Kansas State University Lecture 12 of 42CIS 636/736: (Introduction to) Computer Graphics Texture Mapping s t x y z image geometry screen
16
Computing & Information Sciences Kansas State University Lecture 12 of 42CIS 636/736: (Introduction to) Computer Graphics Texture Mapping and OpenGL Pipeline geometry pipeline vertices pixel pipeline image rasterizer Images and geometry flow through separate pipelines that join at the rasterizer “complex” textures do not affect geometric complexity
17
Computing & Information Sciences Kansas State University Lecture 12 of 42CIS 636/736: (Introduction to) Computer Graphics Texture Example The texture (below) is a 256 x 256 image that has been mapped to a rectangular polygon which is viewed in perspective
18
Computing & Information Sciences Kansas State University Lecture 12 of 42CIS 636/736: (Introduction to) Computer Graphics Three steps specify texture read or generate image assign to texture assign texture coordinates to vertices specify texture parameters wrapping, filtering Applying Textures [1]
19
Computing & Information Sciences Kansas State University Lecture 12 of 42CIS 636/736: (Introduction to) Computer Graphics Applying Textures [2] specify textures in texture objects set texture filter set texture function set texture wrap mode set optional perspective correction hint bind texture object enable texturing supply texture coordinates for vertex coordinates can also be generated
20
Computing & Information Sciences Kansas State University Lecture 12 of 42CIS 636/736: (Introduction to) Computer Graphics Define a texture image from array of texels in CPU memory glTexImage2D( target, level, components, w, h, border, format, type, *texels ); dimensions of image must be powers of 2 Texel colors are processed by pixel pipeline pixel scales, biases and lookups can be done Specify Texture Image CPU DL Poly. Per Vertex Per Vertex Raster Frag FB Pixel Texture
21
Computing & Information Sciences Kansas State University Lecture 12 of 42CIS 636/736: (Introduction to) Computer Graphics Tutorial: Texture
22
Computing & Information Sciences Kansas State University Lecture 12 of 42CIS 636/736: (Introduction to) Computer Graphics Summary OpenGL Tutorials from SIGGRAPH 2000 Vicki Shreiner: Animation and Depth Buffering Double buffering Illumination: light positioning, light models, attenuation Material properties Animation basics in OpenGL Vicki Schreiner: Imaging and Raster Primitives Ed Angel: Texture Mapping in OpenGL More in CG Basics 5: GL Primer 2 of 3
23
Computing & Information Sciences Kansas State University Lecture 12 of 42CIS 636/736: (Introduction to) Computer Graphics Terminology Double Buffering Lighting Illumination Equation – describes light in scene Ambient light – catch-all term for whole scene, all lights Diffuse reflectance – omnidirectional, from matte surfaces Specular reflectance – unidirectional, for highlights: shiny surfaces Attenuation – how quickly light drops off as function of distance Pixel and Fragment Programs (“Pixel Shaders”) Vertex Shaders Texture Maps Other Mappings Discussed in Course Bump aka displacement – perturb surface normal, calculate lighting Reflection and transparency Shadow Environment
24
Computing & Information Sciences Kansas State University Lecture 12 of 42CIS 636/736: (Introduction to) Computer Graphics Next: Polygons, OpenGL Tutorial 3 Dave Shreiner: Advanced Topics (concluded) Advanced Primitives: Cubic Curves, Bicubic Surfaces More on Shadow Stencil Buffer Alpha, Blending, Antialiasing Accumulation Buffer, Fog, Jitter Using the OpenGL Shading Language More on fragment programs Demo: color interpolation Example: Fast Phong shading Special Effects
Similar presentations
© 2024 SlidePlayer.com. Inc.
All rights reserved.