Computing & Information Sciences Kansas State University Lecture 12 of 42 CIS 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/1y5gc Course web site: http://www.kddresearch.org/Courses/CIS636 Instructor home page: http://www.cis.ksu.edu/~bhsu Readings: All slides from SIGGRAPH 2000 tutorial on OpenGL, Shreiner, Angel, Shreiner: http://www.cs.unm.edu/~angel/SIGGRAPH/ Sections 2.6, 3.1 , 20.3 – 20.13 , Eberly 2 e – see http://snurl.com/1ye72 NeHe tutorials: 6 – 10, http://nehe.gamedev.net Article: http://www.kuro5hin.org/story/2003/10/28/9853/1617 Surface Detail 5: Pixel and Vertex Programs
CIS 636/736 Computer Graphics Lecture 12 of 42. Surface Detail 5: Pixel and Vertex Programs. William H. Hsu Department of Computing and Information Sciences, KSU KSOL course pages: http://snipurl.com/1y5gc Course web site: http://www.kddresearch.org/Courses/CIS636 - PowerPoint PPT Presentation
Welcome message from author
This document is posted to help you gain knowledge. Please leave a comment to let me know what you think about it! Share it to your friends and learn new things together.
Transcript
Computing & Information SciencesKansas State University
Lecture 12 of 42CIS 636/736: (Introduction to) Computer Graphics
CIS 636/736 Computer GraphicsLecture 12 of 42
William H. Hsu
Department of Computing and Information Sciences, KSU
KSOL course pages: http://snipurl.com/1y5gc
Course web site: http://www.kddresearch.org/Courses/CIS636
Instructor home page: http://www.cis.ksu.edu/~bhsu
Readings:
All slides from SIGGRAPH 2000 tutorial on OpenGL, Shreiner, Angel, Shreiner: http://www.cs.unm.edu/~angel/SIGGRAPH/
Sections 2.6, 3.1, 20.3 – 20.13, Eberly 2e – see http://snurl.com/1ye72
Dave Shreiner: Advanced Topics Display lists and vertex arrays
Accumulation buffer
Fog
Stencil buffering
Fragment programs (to be concluded in Tutorial 3)
Computing & Information SciencesKansas State University
Lecture 12 of 42CIS 636/736: (Introduction to) Computer Graphics
LightingLighting
Dave Shreiner
Computing & Information SciencesKansas State University
Lecture 12 of 42CIS 636/736: (Introduction to) Computer Graphics
Lighting PrinciplesLighting Principles
Lighting simulates how objects reflect light
material composition of object
light’s color and position
global lighting parametersambient light
two sided lighting
available in both color indexand RGBA mode
Computing & Information SciencesKansas State University
Lecture 12 of 42CIS 636/736: (Introduction to) Computer Graphics
Surface NormalsSurface 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 )
CPUCPU
DLDL
Poly.Poly. Per
Vertex
PerVertex
RasterRaster Frag
FragFB
FB
PixelPixel
TextureTexture
Computing & Information SciencesKansas State University
Lecture 12 of 42CIS 636/736: (Introduction to) Computer Graphics
Light PropertiesLight Properties
glLightfv( light, property, value ); light specifies which light
multiple lights, starting with GL_LIGHT0
glGetIntegerv( GL_MAX_LIGHTS, &n );
propertiescolorsposition and typeattenuation
Computing & Information SciencesKansas State University
Lecture 12 of 42CIS 636/736: (Introduction to) Computer Graphics
Light Sources
Light color properties GL_AMBIENT GL_DIFFUSE GL_SPECULAR
Computing & Information SciencesKansas State University
Lecture 12 of 42CIS 636/736: (Introduction to) Computer Graphics
Turning on the LightsTurning on the Lights
Flip each light’s switch
glEnable( GL_LIGHTn ); Turn on power
glEnable( GL_LIGHTING );
Computing & Information SciencesKansas State University
Lecture 12 of 42CIS 636/736: (Introduction to) Computer Graphics
Light Material TutorialLight Material Tutorial
Computing & Information SciencesKansas State University
Lecture 12 of 42CIS 636/736: (Introduction to) Computer Graphics
Controlling a Light’s PositionControlling a Light’s Position
Modelview matrix affects a light’s position Different effects based on when position is specified
eye coordinatesworld coordinatesmodel coordinates
Push and pop matrices to uniquely control a light’s position
Computing & Information SciencesKansas State University
Lecture 12 of 42CIS 636/736: (Introduction to) Computer Graphics
Light Position TutorialLight Position Tutorial
Computing & Information SciencesKansas State University
Lecture 12 of 42CIS 636/736: (Introduction to) Computer Graphics
FrameBuffer
Rasterization(including
Pixel Zoom)
Per FragmentOperations
TextureMemory
Pixel-TransferOperations
(and Pixel Map)CPU
PixelStorageModes
glReadPixels(), glCopyPixels()
glBitmap(), glDrawPixels()
glCopyTex*Image();
Pixel PipelinePixel Pipeline
Programmable pixel storage and transfer operations
CPUCPU
DLDL
Poly.Poly. Per
Vertex
PerVertex
RasterRaster
FragFrag
FBFB
PixelPixel
TextureTexture
Computing & Information SciencesKansas State University
Lecture 12 of 42CIS 636/736: (Introduction to) Computer Graphics
Texture MappingTexture Mapping
Ed Angel
Computing & Information SciencesKansas State University
Lecture 12 of 42CIS 636/736: (Introduction to) Computer Graphics
Texture MappingTexture Mapping
CPUCPU
DLDL
Poly.Poly. Per
Vertex
PerVertex
RasterRaster
FragFrag
FBFB
PixelPixel
TextureTexture
Apply 1-D, 2-D, or 3-D image to geometric primitives
Uses of Texturing simulating materials
reducing geometric complexity
image warping
reflections
Computing & Information SciencesKansas State University
Lecture 12 of 42CIS 636/736: (Introduction to) Computer Graphics
Texture MappingTexture Mapping
s
t
x
y
z
image
geometry screen
Computing & Information SciencesKansas State University
Lecture 12 of 42CIS 636/736: (Introduction to) Computer Graphics
Texture Mapping andOpenGL Pipeline
Texture Mapping andOpenGL Pipeline
geometry pipelinevertices
pixel pipelineimage
rasterizer
Images and geometry flow through separate pipelines that join at the rasterizer “complex” textures do not affect geometric complexity
Computing & Information SciencesKansas State University
Lecture 12 of 42CIS 636/736: (Introduction to) Computer Graphics
Texture ExampleTexture Example
The texture (below) is a 256 x 256 image that has beenmapped to a rectangularpolygon which is viewed inperspective
Computing & Information SciencesKansas State University
Lecture 12 of 42CIS 636/736: (Introduction to) Computer Graphics
Three steps specify texture
read or generate imageassign to texture
assign texture coordinates to vertices specify texture parameters
wrapping, filtering
Applying Textures [1]
Computing & Information SciencesKansas 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
Computing & Information SciencesKansas State University
Lecture 12 of 42CIS 636/736: (Introduction to) Computer Graphics
Define a texture image from array of texels in CPU memory