81
Computing & Information Sciences Kansas State University CG Basics 5 of 8: OpenGL Primer 2 CIS 636/736: (Introduction to) Computer Graphics CIS 636 Introduction to Computer Graphics 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 CG Basics 5 of 8: OpenGL Primer, Part 2 of 3

Computing & Information Sciences Kansas State University CG Basics 5 of 8: OpenGL Primer 2 CIS 636/736: (Introduction to) Computer Graphics CIS 636 Introduction

Embed Size (px)

Citation preview

Page 1: Computing & Information Sciences Kansas State University CG Basics 5 of 8: OpenGL Primer 2 CIS 636/736: (Introduction to) Computer Graphics CIS 636 Introduction

Computing & Information SciencesKansas State University

CG Basics 5 of 8: OpenGL Primer 2

CIS 636/736: (Introduction to) Computer Graphics

CIS 636Introduction to Computer Graphics

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

NeHe tutorials: 6 – 10, http://nehe.gamedev.net

Article: http://www.kuro5hin.org/story/2003/10/28/9853/1617

CG Basics 5 of 8:OpenGL Primer, Part 2 of 3

Page 2: Computing & Information Sciences Kansas State University CG Basics 5 of 8: OpenGL Primer 2 CIS 636/736: (Introduction to) Computer Graphics CIS 636 Introduction

Computing & Information SciencesKansas State University

CG Basics 5 of 8: OpenGL Primer 2

CIS 636/736: (Introduction to) Computer Graphics

Lecture Outline

Four More Short 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)

Page 3: Computing & Information Sciences Kansas State University CG Basics 5 of 8: OpenGL Primer 2 CIS 636/736: (Introduction to) Computer Graphics CIS 636 Introduction

Computing & Information SciencesKansas State University

CG Basics 5 of 8: OpenGL Primer 2

CIS 636/736: (Introduction to) Computer Graphics

Animation and Depth BufferingAnimation and Depth Buffering

Vicki Shreiner

Page 4: Computing & Information Sciences Kansas State University CG Basics 5 of 8: OpenGL Primer 2 CIS 636/736: (Introduction to) Computer Graphics CIS 636 Introduction

Computing & Information SciencesKansas State University

CG Basics 5 of 8: OpenGL Primer 2

CIS 636/736: (Introduction to) Computer Graphics

Animation and Depth BufferingAnimation and Depth Buffering

Double buffering and animation

Using depth buffer Hidden surface removal

aka visible surface determination

Page 5: Computing & Information Sciences Kansas State University CG Basics 5 of 8: OpenGL Primer 2 CIS 636/736: (Introduction to) Computer Graphics CIS 636 Introduction

Computing & Information SciencesKansas State University

CG Basics 5 of 8: OpenGL Primer 2

CIS 636/736: (Introduction to) Computer Graphics

Double Buffering

124816

124816

FrontBuffer

BackBuffer

Display

CPUCPU

DLDL

Poly.Poly. Per

Vertex

PerVertex

RasterRaster

FragFrag

FBFB

PixelPixel

TextureTexture

Page 6: Computing & Information Sciences Kansas State University CG Basics 5 of 8: OpenGL Primer 2 CIS 636/736: (Introduction to) Computer Graphics CIS 636 Introduction

Computing & Information SciencesKansas State University

CG Basics 5 of 8: OpenGL Primer 2

CIS 636/736: (Introduction to) Computer Graphics

Request a double buffered color bufferglutInitDisplayMode( GLUT_RGB | GLUT_DOUBLE );

Clear color bufferglClear( GL_COLOR_BUFFER_BIT );

Render scene Request swap of front and back buffers

glutSwapBuffers();

Repeat steps 2 - 4 for animation

Animation using Double Buffering

Page 7: Computing & Information Sciences Kansas State University CG Basics 5 of 8: OpenGL Primer 2 CIS 636/736: (Introduction to) Computer Graphics CIS 636 Introduction

Computing & Information SciencesKansas State University

CG Basics 5 of 8: OpenGL Primer 2

CIS 636/736: (Introduction to) Computer Graphics

Depth Buffering andHidden Surface Removal

124816

124816

ColorBuffer

DepthBuffer

Display

Page 8: Computing & Information Sciences Kansas State University CG Basics 5 of 8: OpenGL Primer 2 CIS 636/736: (Introduction to) Computer Graphics CIS 636 Introduction

Computing & Information SciencesKansas State University

CG Basics 5 of 8: OpenGL Primer 2

CIS 636/736: (Introduction to) Computer Graphics

Depth Buffering Using OpenGL

Request a depth bufferglutInitDisplayMode( GLUT_RGB | GLUT_DOUBLE | GLUT_DEPTH );

Enable depth bufferingglEnable( GL_DEPTH_TEST );

Clear color and depth buffersglClear( GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT );

Render scene Swap color buffers

Page 9: Computing & Information Sciences Kansas State University CG Basics 5 of 8: OpenGL Primer 2 CIS 636/736: (Introduction to) Computer Graphics CIS 636 Introduction

Computing & Information SciencesKansas State University

CG Basics 5 of 8: OpenGL Primer 2

CIS 636/736: (Introduction to) Computer Graphics

Updated Program Template [1]

void main( int argc, char** argv )

{

glutInit( &argc, argv );

glutInitDisplayMode( GLUT_RGB | GLUT_DOUBLE | GLUT_DEPTH );

glutCreateWindow( “Tetrahedron” );

init();

glutIdleFunc( idle );

glutDisplayFunc( display );

glutMainLoop();

}

Page 10: Computing & Information Sciences Kansas State University CG Basics 5 of 8: OpenGL Primer 2 CIS 636/736: (Introduction to) Computer Graphics CIS 636 Introduction

Computing & Information SciencesKansas State University

CG Basics 5 of 8: OpenGL Primer 2

CIS 636/736: (Introduction to) Computer Graphics

void init( void ){ glClearColor( 0.0, 0.0, 1.0, 1.0 );}

void idle( void ){ glutPostRedisplay();}

Updated Program Template [2]

Page 11: Computing & Information Sciences Kansas State University CG Basics 5 of 8: OpenGL Primer 2 CIS 636/736: (Introduction to) Computer Graphics CIS 636 Introduction

Computing & Information SciencesKansas State University

CG Basics 5 of 8: OpenGL Primer 2

CIS 636/736: (Introduction to) Computer Graphics

void drawScene( void ){

GLfloat vertices[] = { … }; GLfloat colors[] = { … }; glClear( GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT );

glBegin( GL_TRIANGLE_STRIP );/* calls to glColor*() and glVertex*() */ glEnd(); glutSwapBuffers();

}

Updated Program Template [3]

Page 12: Computing & Information Sciences Kansas State University CG Basics 5 of 8: OpenGL Primer 2 CIS 636/736: (Introduction to) Computer Graphics CIS 636 Introduction

Computing & Information SciencesKansas State University

CG Basics 5 of 8: OpenGL Primer 2

CIS 636/736: (Introduction to) Computer Graphics

LightingLighting

Dave Shreiner

Page 13: Computing & Information Sciences Kansas State University CG Basics 5 of 8: OpenGL Primer 2 CIS 636/736: (Introduction to) Computer Graphics CIS 636 Introduction

Computing & Information SciencesKansas State University

CG Basics 5 of 8: OpenGL Primer 2

CIS 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

Page 14: Computing & Information Sciences Kansas State University CG Basics 5 of 8: OpenGL Primer 2 CIS 636/736: (Introduction to) Computer Graphics CIS 636 Introduction

Computing & Information SciencesKansas State University

CG Basics 5 of 8: OpenGL Primer 2

CIS 636/736: (Introduction to) Computer Graphics

How OpenGL Simulates LightsHow OpenGL Simulates Lights

Phong lighting model

Computed at vertices

Lighting contributors

Surface material properties

Light properties

Lighting model properties

Page 15: Computing & Information Sciences Kansas State University CG Basics 5 of 8: OpenGL Primer 2 CIS 636/736: (Introduction to) Computer Graphics CIS 636 Introduction

Computing & Information SciencesKansas State University

CG Basics 5 of 8: OpenGL Primer 2

CIS 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

Page 16: Computing & Information Sciences Kansas State University CG Basics 5 of 8: OpenGL Primer 2 CIS 636/736: (Introduction to) Computer Graphics CIS 636 Introduction

Computing & Information SciencesKansas State University

CG Basics 5 of 8: OpenGL Primer 2

CIS 636/736: (Introduction to) Computer Graphics

Material PropertiesMaterial Properties

Define the surface properties of a primitiveglMaterialfv( face, property, value );

separate materials for front and back

GL_DIFFUSE Base color

GL_SPECULAR Highlight Color

GL_AMBIENT Low-light Color

GL_EMISSION Glow Color

GL_SHININESS Surface Smoothness

Page 17: Computing & Information Sciences Kansas State University CG Basics 5 of 8: OpenGL Primer 2 CIS 636/736: (Introduction to) Computer Graphics CIS 636 Introduction

Computing & Information SciencesKansas State University

CG Basics 5 of 8: OpenGL Primer 2

CIS 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

Page 18: Computing & Information Sciences Kansas State University CG Basics 5 of 8: OpenGL Primer 2 CIS 636/736: (Introduction to) Computer Graphics CIS 636 Introduction

Computing & Information SciencesKansas State University

CG Basics 5 of 8: OpenGL Primer 2

CIS 636/736: (Introduction to) Computer Graphics

Light Sources

Light color properties GL_AMBIENT GL_DIFFUSE GL_SPECULAR

Page 19: Computing & Information Sciences Kansas State University CG Basics 5 of 8: OpenGL Primer 2 CIS 636/736: (Introduction to) Computer Graphics CIS 636 Introduction

Computing & Information SciencesKansas State University

CG Basics 5 of 8: OpenGL Primer 2

CIS 636/736: (Introduction to) Computer Graphics

Types of LightsTypes of Lights

OpenGL supports two types of Lights Local (Point) light sources Infinite (Directional) light sources

Type of light controlled by w coordinate

wzw

ywxw

zyxw

at positioned Light Local

along directed LightInfinite

0

0

Page 20: Computing & Information Sciences Kansas State University CG Basics 5 of 8: OpenGL Primer 2 CIS 636/736: (Introduction to) Computer Graphics CIS 636 Introduction

Computing & Information SciencesKansas State University

CG Basics 5 of 8: OpenGL Primer 2

CIS 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 );

Page 21: Computing & Information Sciences Kansas State University CG Basics 5 of 8: OpenGL Primer 2 CIS 636/736: (Introduction to) Computer Graphics CIS 636 Introduction

Computing & Information SciencesKansas State University

CG Basics 5 of 8: OpenGL Primer 2

CIS 636/736: (Introduction to) Computer Graphics

Light Material TutorialLight Material Tutorial

Page 22: Computing & Information Sciences Kansas State University CG Basics 5 of 8: OpenGL Primer 2 CIS 636/736: (Introduction to) Computer Graphics CIS 636 Introduction

Computing & Information SciencesKansas State University

CG Basics 5 of 8: OpenGL Primer 2

CIS 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

Page 23: Computing & Information Sciences Kansas State University CG Basics 5 of 8: OpenGL Primer 2 CIS 636/736: (Introduction to) Computer Graphics CIS 636 Introduction

Computing & Information SciencesKansas State University

CG Basics 5 of 8: OpenGL Primer 2

CIS 636/736: (Introduction to) Computer Graphics

Light Position TutorialLight Position Tutorial

Page 24: Computing & Information Sciences Kansas State University CG Basics 5 of 8: OpenGL Primer 2 CIS 636/736: (Introduction to) Computer Graphics CIS 636 Introduction

Computing & Information SciencesKansas State University

CG Basics 5 of 8: OpenGL Primer 2

CIS 636/736: (Introduction to) Computer Graphics

Spotlights

localize lighting affects

GL_SPOT_DIRECTIONGL_SPOT_CUTOFFGL_SPOT_EXPONENT

Advanced Lighting Features [1]Advanced Lighting Features [1]

Page 25: Computing & Information Sciences Kansas State University CG Basics 5 of 8: OpenGL Primer 2 CIS 636/736: (Introduction to) Computer Graphics CIS 636 Introduction

Computing & Information SciencesKansas State University

CG Basics 5 of 8: OpenGL Primer 2

CIS 636/736: (Introduction to) Computer Graphics

Advanced Lighting Features [2]Advanced Lighting Features [2]

Light attenuation

decrease light intensity with distance

GL_CONSTANT_ATTENUATIONGL_LINEAR_ATTENUATIONGL_QUADRATIC_ATTENUATION

2

1

dkdkkf

qlci

Page 26: Computing & Information Sciences Kansas State University CG Basics 5 of 8: OpenGL Primer 2 CIS 636/736: (Introduction to) Computer Graphics CIS 636 Introduction

Computing & Information SciencesKansas State University

CG Basics 5 of 8: OpenGL Primer 2

CIS 636/736: (Introduction to) Computer Graphics

Light Model PropertiesLight Model Properties

glLightModelfv( property, value ); Enabling two sided lighting

GL_LIGHT_MODEL_TWO_SIDE Global ambient color

GL_LIGHT_MODEL_AMBIENT Local viewer mode

GL_LIGHT_MODEL_LOCAL_VIEWER Separate specular color

GL_LIGHT_MODEL_COLOR_CONTROL

Page 27: Computing & Information Sciences Kansas State University CG Basics 5 of 8: OpenGL Primer 2 CIS 636/736: (Introduction to) Computer Graphics CIS 636 Introduction

Computing & Information SciencesKansas State University

CG Basics 5 of 8: OpenGL Primer 2

CIS 636/736: (Introduction to) Computer Graphics

Tips for Better LightingTips for Better Lighting

Recall lighting computed only at vertices model tessellation heavily affects lighting results

better results but more geometry to process

Use a single infinite light for fastest lighting minimal computation per vertex

Page 28: Computing & Information Sciences Kansas State University CG Basics 5 of 8: OpenGL Primer 2 CIS 636/736: (Introduction to) Computer Graphics CIS 636 Introduction

Computing & Information SciencesKansas State University

CG Basics 5 of 8: OpenGL Primer 2

CIS 636/736: (Introduction to) Computer Graphics

Imaging and Raster PrimitivesImaging and Raster Primitives

Vicki Shreiner

Page 29: Computing & Information Sciences Kansas State University CG Basics 5 of 8: OpenGL Primer 2 CIS 636/736: (Introduction to) Computer Graphics CIS 636 Introduction

Computing & Information SciencesKansas State University

CG Basics 5 of 8: OpenGL Primer 2

CIS 636/736: (Introduction to) Computer Graphics

Imaging and Raster PrimitivesImaging and Raster Primitives

Describe OpenGL’s raster primitives: bitmaps and image rectangles

Demonstrate how to get OpenGL to read and render pixel rectangles

Page 30: Computing & Information Sciences Kansas State University CG Basics 5 of 8: OpenGL Primer 2 CIS 636/736: (Introduction to) Computer Graphics CIS 636 Introduction

Computing & Information SciencesKansas State University

CG Basics 5 of 8: OpenGL Primer 2

CIS 636/736: (Introduction to) Computer Graphics

Pixel-based primitivesPixel-based primitives

Bitmaps 2D array of bit masks for pixels

update pixel color based on current color Images

2D array of pixel color informationcomplete color information for each pixel

OpenGL doesn’t understand image formats

Page 31: Computing & Information Sciences Kansas State University CG Basics 5 of 8: OpenGL Primer 2 CIS 636/736: (Introduction to) Computer Graphics CIS 636 Introduction

Computing & Information SciencesKansas State University

CG Basics 5 of 8: OpenGL Primer 2

CIS 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

Page 32: Computing & Information Sciences Kansas State University CG Basics 5 of 8: OpenGL Primer 2 CIS 636/736: (Introduction to) Computer Graphics CIS 636 Introduction

Computing & Information SciencesKansas State University

CG Basics 5 of 8: OpenGL Primer 2

CIS 636/736: (Introduction to) Computer Graphics

Positioning Image PrimitivesPositioning Image Primitives

glRasterPos3f( x, y, z ) raster position transformed like geometry discarded if raster position is

outside of viewportmay need to fine tune

viewport for desired results

Raster Position

Page 33: Computing & Information Sciences Kansas State University CG Basics 5 of 8: OpenGL Primer 2 CIS 636/736: (Introduction to) Computer Graphics CIS 636 Introduction

Computing & Information SciencesKansas State University

CG Basics 5 of 8: OpenGL Primer 2

CIS 636/736: (Introduction to) Computer Graphics

Rendering BitmapsRendering Bitmaps

glBitmap( width, height, xorig, yorig, xmove, ymove, bitmap )

render bitmap in current colorat

advance raster position by after rendering

yorigyxorigx

ymovexmove

width

he

igh

t

xorig

yorig

xmove

Page 34: Computing & Information Sciences Kansas State University CG Basics 5 of 8: OpenGL Primer 2 CIS 636/736: (Introduction to) Computer Graphics CIS 636 Introduction

Computing & Information SciencesKansas State University

CG Basics 5 of 8: OpenGL Primer 2

CIS 636/736: (Introduction to) Computer Graphics

Rendering Fonts using BitmapsRendering Fonts using Bitmaps

OpenGL uses bitmaps for font rendering each character stored in display list containing bitmap window system specific routines to access system fonts

glXUseXFont()wglUseFontBitmaps()

Page 35: Computing & Information Sciences Kansas State University CG Basics 5 of 8: OpenGL Primer 2 CIS 636/736: (Introduction to) Computer Graphics CIS 636 Introduction

Computing & Information SciencesKansas State University

CG Basics 5 of 8: OpenGL Primer 2

CIS 636/736: (Introduction to) Computer Graphics

Rendering ImagesRendering Images

glDrawPixels( width, height, format, type, pixels ) render pixels with lower left of

image at current raster position numerous formats and data types

for specifying storage in memorybest performance by using format and type that matches

hardware

Page 36: Computing & Information Sciences Kansas State University CG Basics 5 of 8: OpenGL Primer 2 CIS 636/736: (Introduction to) Computer Graphics CIS 636 Introduction

Computing & Information SciencesKansas State University

CG Basics 5 of 8: OpenGL Primer 2

CIS 636/736: (Introduction to) Computer Graphics

Reading PixelsReading Pixels

glReadPixels( x, y, width, height, format, type, pixels )

read pixels from specified (x,y) position in framebuffer pixels automatically converted from framebuffer format

into requested format and type Framebuffer pixel copy

glCopyPixels( x, y, width, height, type )

Page 37: Computing & Information Sciences Kansas State University CG Basics 5 of 8: OpenGL Primer 2 CIS 636/736: (Introduction to) Computer Graphics CIS 636 Introduction

Computing & Information SciencesKansas State University

CG Basics 5 of 8: OpenGL Primer 2

CIS 636/736: (Introduction to) Computer Graphics

RasterPosition

glPixelZoom(1.0, -1.0);

Pixel ZoomPixel Zoom

glPixelZoom( x, y ) expand, shrink or reflect pixels

around current raster position fractional zoom supported

Page 38: Computing & Information Sciences Kansas State University CG Basics 5 of 8: OpenGL Primer 2 CIS 636/736: (Introduction to) Computer Graphics CIS 636 Introduction

Computing & Information SciencesKansas State University

CG Basics 5 of 8: OpenGL Primer 2

CIS 636/736: (Introduction to) Computer Graphics

Storage and Transfer ModesStorage and Transfer Modes

Storage modes control accessing memory byte alignment in host memory extracting a subimage

Transfer modes allow modify pixel values scale and bias pixel component values replace colors using pixel maps

Page 39: Computing & Information Sciences Kansas State University CG Basics 5 of 8: OpenGL Primer 2 CIS 636/736: (Introduction to) Computer Graphics CIS 636 Introduction

Computing & Information SciencesKansas State University

CG Basics 5 of 8: OpenGL Primer 2

CIS 636/736: (Introduction to) Computer Graphics

Texture MappingTexture Mapping

Ed Angel

Page 40: Computing & Information Sciences Kansas State University CG Basics 5 of 8: OpenGL Primer 2 CIS 636/736: (Introduction to) Computer Graphics CIS 636 Introduction

Computing & Information SciencesKansas State University

CG Basics 5 of 8: OpenGL Primer 2

CIS 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

Page 41: Computing & Information Sciences Kansas State University CG Basics 5 of 8: OpenGL Primer 2 CIS 636/736: (Introduction to) Computer Graphics CIS 636 Introduction

Computing & Information SciencesKansas State University

CG Basics 5 of 8: OpenGL Primer 2

CIS 636/736: (Introduction to) Computer Graphics

Texture MappingTexture Mapping

s

t

x

y

z

image

geometry screen

Page 42: Computing & Information Sciences Kansas State University CG Basics 5 of 8: OpenGL Primer 2 CIS 636/736: (Introduction to) Computer Graphics CIS 636 Introduction

Computing & Information SciencesKansas State University

CG Basics 5 of 8: OpenGL Primer 2

CIS 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

Page 43: Computing & Information Sciences Kansas State University CG Basics 5 of 8: OpenGL Primer 2 CIS 636/736: (Introduction to) Computer Graphics CIS 636 Introduction

Computing & Information SciencesKansas State University

CG Basics 5 of 8: OpenGL Primer 2

CIS 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

Page 44: Computing & Information Sciences Kansas State University CG Basics 5 of 8: OpenGL Primer 2 CIS 636/736: (Introduction to) Computer Graphics CIS 636 Introduction

Computing & Information SciencesKansas State University

CG Basics 5 of 8: OpenGL Primer 2

CIS 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]

Page 45: Computing & Information Sciences Kansas State University CG Basics 5 of 8: OpenGL Primer 2 CIS 636/736: (Introduction to) Computer Graphics CIS 636 Introduction

Computing & Information SciencesKansas State University

CG Basics 5 of 8: OpenGL Primer 2

CIS 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

Page 46: Computing & Information Sciences Kansas State University CG Basics 5 of 8: OpenGL Primer 2 CIS 636/736: (Introduction to) Computer Graphics CIS 636 Introduction

Computing & Information SciencesKansas State University

CG Basics 5 of 8: OpenGL Primer 2

CIS 636/736: (Introduction to) Computer Graphics

Texture Objects [1]

Like display lists for texture images one image per texture object

may be shared by several graphics contexts Generate texture names

glGenTextures( n, *texIds );

Page 47: Computing & Information Sciences Kansas State University CG Basics 5 of 8: OpenGL Primer 2 CIS 636/736: (Introduction to) Computer Graphics CIS 636 Introduction

Computing & Information SciencesKansas State University

CG Basics 5 of 8: OpenGL Primer 2

CIS 636/736: (Introduction to) Computer Graphics

Create texture objects with texture data and state

glBindTexture( target, id ); Bind textures before using

glBindTexture( target, id );

Texture Objects [2]

Page 48: Computing & Information Sciences Kansas State University CG Basics 5 of 8: OpenGL Primer 2 CIS 636/736: (Introduction to) Computer Graphics CIS 636 Introduction

Computing & Information SciencesKansas State University

CG Basics 5 of 8: OpenGL Primer 2

CIS 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 ImageSpecify Texture Image

CPUCPU

DLDL

Poly.Poly. Per

Vertex

PerVertex

RasterRaster Frag

FragFB

FB

PixelPixel

TextureTexture

Page 49: Computing & Information Sciences Kansas State University CG Basics 5 of 8: OpenGL Primer 2 CIS 636/736: (Introduction to) Computer Graphics CIS 636 Introduction

Computing & Information SciencesKansas State University

CG Basics 5 of 8: OpenGL Primer 2

CIS 636/736: (Introduction to) Computer Graphics

Converting Texture Images

If dimensions of image are not power of 2

gluScaleImage( format, w_in, h_in, type_in, *data_in, w_out, h_out,

type_out, *data_out );

*_in is for source image *_out is for destination image

Image interpolated and filtered during scaling

Page 50: Computing & Information Sciences Kansas State University CG Basics 5 of 8: OpenGL Primer 2 CIS 636/736: (Introduction to) Computer Graphics CIS 636 Introduction

Computing & Information SciencesKansas State University

CG Basics 5 of 8: OpenGL Primer 2

CIS 636/736: (Introduction to) Computer Graphics

Specifying Textures:Other Methods

Use frame buffer as source of texture image uses current buffer as source image

glCopyTexImage2D(...)glCopyTexImage2D(...)

glCopyTexImage1D(...)glCopyTexImage1D(...) Modify part of a defined texture

glTexSubImage2D(...)glTexSubImage2D(...)

glTexSubImage1D(...)glTexSubImage1D(...) Do both with glCopyTexSubImage2D(...), etc.

Page 51: Computing & Information Sciences Kansas State University CG Basics 5 of 8: OpenGL Primer 2 CIS 636/736: (Introduction to) Computer Graphics CIS 636 Introduction

Computing & Information SciencesKansas State University

CG Basics 5 of 8: OpenGL Primer 2

CIS 636/736: (Introduction to) Computer Graphics

Based on parametric texture coordinates glTexCoord*() specified at each vertex

0, 1

s

t1, 1

0, 0 1, 0

(s, t) = (0.2, 0.8)

(0.4, 0.2)

(0.8, 0.4)

A

B C

a

bc

Texture Space Object Space

Mapping aTexture

Mapping aTexture

CPUCPU

DLDL

Poly.Poly. Per

Vertex

PerVertex

RasterRaster

FragFrag

FBFB

PixelPixel

TextureTexture

Page 52: Computing & Information Sciences Kansas State University CG Basics 5 of 8: OpenGL Primer 2 CIS 636/736: (Introduction to) Computer Graphics CIS 636 Introduction

Computing & Information SciencesKansas State University

CG Basics 5 of 8: OpenGL Primer 2

CIS 636/736: (Introduction to) Computer Graphics

Generating Texture Coordinates

Automatically generate texture coordsglTexGen{ifd}[v]()

specify a plane generate texture coordinates based upon distance from plane

generation modes GL_OBJECT_LINEAR GL_EYE_LINEAR GL_SPHERE_MAP

0 DCzByAx

Page 53: Computing & Information Sciences Kansas State University CG Basics 5 of 8: OpenGL Primer 2 CIS 636/736: (Introduction to) Computer Graphics CIS 636 Introduction

Computing & Information SciencesKansas State University

CG Basics 5 of 8: OpenGL Primer 2

CIS 636/736: (Introduction to) Computer Graphics

Tutorial: TextureTutorial: Texture

Page 54: Computing & Information Sciences Kansas State University CG Basics 5 of 8: OpenGL Primer 2 CIS 636/736: (Introduction to) Computer Graphics CIS 636 Introduction

Computing & Information SciencesKansas State University

CG Basics 5 of 8: OpenGL Primer 2

CIS 636/736: (Introduction to) Computer Graphics

Filter Modes minification or magnification special mipmap minification filters

Wrap Modes clamping or repeating

Texture Functions how to mix primitive’s color with texture’s color

blend, modulate or replace texels

Texture Application Methods

Page 55: Computing & Information Sciences Kansas State University CG Basics 5 of 8: OpenGL Primer 2 CIS 636/736: (Introduction to) Computer Graphics CIS 636 Introduction

Computing & Information SciencesKansas State University

CG Basics 5 of 8: OpenGL Primer 2

CIS 636/736: (Introduction to) Computer Graphics

Filter Modes

Texture Polygon

Magnification Minification

PolygonTexture

Example:

glTexParameteri( glTexParameteri( target, type, modetarget, type, mode ); );

Page 56: Computing & Information Sciences Kansas State University CG Basics 5 of 8: OpenGL Primer 2 CIS 636/736: (Introduction to) Computer Graphics CIS 636 Introduction

Computing & Information SciencesKansas State University

CG Basics 5 of 8: OpenGL Primer 2

CIS 636/736: (Introduction to) Computer Graphics

Mipmapped Textures

Mipmap allows for prefiltered texture maps of decreasing resolutions

Lessens interpolation errors for smaller textured objects

Declare mipmap level during texture definition

glTexImage*D( glTexImage*D( GL_TEXTURE_*D, level, …GL_TEXTURE_*D, level, … ) ) GLU mipmap builder routines

gluBuild*DMipmaps( … )gluBuild*DMipmaps( … ) OpenGL 1.2 introduces advanced LOD controls

Page 57: Computing & Information Sciences Kansas State University CG Basics 5 of 8: OpenGL Primer 2 CIS 636/736: (Introduction to) Computer Graphics CIS 636 Introduction

Computing & Information SciencesKansas State University

CG Basics 5 of 8: OpenGL Primer 2

CIS 636/736: (Introduction to) Computer Graphics

Wrapping Mode

Example:

glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP )

glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT )

textureGL_REPEAT

wrappingGL_CLAMPwrapping

s

t

Page 58: Computing & Information Sciences Kansas State University CG Basics 5 of 8: OpenGL Primer 2 CIS 636/736: (Introduction to) Computer Graphics CIS 636 Introduction

Computing & Information SciencesKansas State University

CG Basics 5 of 8: OpenGL Primer 2

CIS 636/736: (Introduction to) Computer Graphics

Texture Functions

Controls how texture is applied

glTexEnv{fi}[v]( GL_TEXTURE_ENV, prop, param ) GL_TEXTURE_ENV_MODE modes

GL_MODULATE GL_BLEND GL_REPLACE

Set blend color with GL_TEXTURE_ENV_COLOR

Page 59: Computing & Information Sciences Kansas State University CG Basics 5 of 8: OpenGL Primer 2 CIS 636/736: (Introduction to) Computer Graphics CIS 636 Introduction

Computing & Information SciencesKansas State University

CG Basics 5 of 8: OpenGL Primer 2

CIS 636/736: (Introduction to) Computer Graphics

Perspective Correction Hint

Texture coordinate and color interpolation either linearly in screen space or using depth/perspective values (slower)

Noticeable for polygons “on edge”

glHint( GL_PERSPECTIVE_CORRECTION_HINT, hint )

where hint is one of GL_DONT_CAREGL_NICESTGL_FASTEST

Page 60: Computing & Information Sciences Kansas State University CG Basics 5 of 8: OpenGL Primer 2 CIS 636/736: (Introduction to) Computer Graphics CIS 636 Introduction

Computing & Information SciencesKansas State University

CG Basics 5 of 8: OpenGL Primer 2

CIS 636/736: (Introduction to) Computer Graphics

Is There Room for a Texture?

Query largest dimension of texture image

typically largest square texture

doesn’t consider internal format size

glGetIntegerv( GL_MAX_TEXTURE_SIZE, &size ) Texture proxy

will memory accommodate requested texture size?

no image specified; placeholder

if texture won’t fit, texture state variables set to 0

doesn’t know about other textures

only considers whether this one texture will fit all of memory

Page 61: Computing & Information Sciences Kansas State University CG Basics 5 of 8: OpenGL Primer 2 CIS 636/736: (Introduction to) Computer Graphics CIS 636 Introduction

Computing & Information SciencesKansas State University

CG Basics 5 of 8: OpenGL Primer 2

CIS 636/736: (Introduction to) Computer Graphics

Texture Residency

Working set of textures high-performance, usually hardware accelerated textures must be in texture objects a texture in the working set is resident for residency of current texture, check GL_TEXTURE_RESIDENT state

If too many textures, not all are resident can set priority to have some kicked out first establish 0.0 to 1.0 priorities for texture objects

Page 62: Computing & Information Sciences Kansas State University CG Basics 5 of 8: OpenGL Primer 2 CIS 636/736: (Introduction to) Computer Graphics CIS 636 Introduction

Computing & Information SciencesKansas State University

CG Basics 5 of 8: OpenGL Primer 2

CIS 636/736: (Introduction to) Computer Graphics

Advanced OpenGL TopicsAdvanced OpenGL Topics

Dave Shreiner

Page 63: Computing & Information Sciences Kansas State University CG Basics 5 of 8: OpenGL Primer 2 CIS 636/736: (Introduction to) Computer Graphics CIS 636 Introduction

Computing & Information SciencesKansas State University

CG Basics 5 of 8: OpenGL Primer 2

CIS 636/736: (Introduction to) Computer Graphics

Advanced OpenGL TopicsAdvanced OpenGL Topics

Display Lists and Vertex Arrays

Alpha Blending and Antialiasing

Using the Accumulation Buffer

Fog

Feedback & Selection

Fragment Tests and Operations

Using the Stencil Buffer

Page 64: Computing & Information Sciences Kansas State University CG Basics 5 of 8: OpenGL Primer 2 CIS 636/736: (Introduction to) Computer Graphics CIS 636 Introduction

Computing & Information SciencesKansas State University

CG Basics 5 of 8: OpenGL Primer 2

CIS 636/736: (Introduction to) Computer Graphics

Rendering: Immediate Mode versus Display

Listed [1]

Immediate Mode Graphics Primitives are sent to pipeline and display right away

No memory of graphical entities

Display Listed Graphics Primitives placed in display lists

Display lists kept on graphics server

Can be redisplayed with different state

Can be shared among OpenGL graphics contexts

Page 65: Computing & Information Sciences Kansas State University CG Basics 5 of 8: OpenGL Primer 2 CIS 636/736: (Introduction to) Computer Graphics CIS 636 Introduction

Computing & Information SciencesKansas State University

CG Basics 5 of 8: OpenGL Primer 2

CIS 636/736: (Introduction to) Computer Graphics

Immediate Mode

Display Listed

DisplayList

PolynomialEvaluator

Per VertexOperations &

PrimitiveAssembly

RasterizationPer Fragment

Operations

TextureMemory

CPU

PixelOperations

FrameBuffer

Rendering: Immediate Mode versus Display

Listed [2]

Page 66: Computing & Information Sciences Kansas State University CG Basics 5 of 8: OpenGL Primer 2 CIS 636/736: (Introduction to) Computer Graphics CIS 636 Introduction

Computing & Information SciencesKansas State University

CG Basics 5 of 8: OpenGL Primer 2

CIS 636/736: (Introduction to) Computer Graphics

Creating a display list

GLuint id;void init( void ){ id = glGenLists( 1 ); glNewList( id, GL_COMPILE ); /* other OpenGL routines */ glEndList();}

Call a created list

void display( void ){ glCallList( id );}

CPUCPU

DLDL

Poly.Poly. Per

Vertex

PerVertex

RasterRaster Frag

FragFB

FB

PixelPixel

TextureTexture

Display Lists [1]

Page 67: Computing & Information Sciences Kansas State University CG Basics 5 of 8: OpenGL Primer 2 CIS 636/736: (Introduction to) Computer Graphics CIS 636 Introduction

Computing & Information SciencesKansas State University

CG Basics 5 of 8: OpenGL Primer 2

CIS 636/736: (Introduction to) Computer Graphics

Display Lists [2]

Not all OpenGL routines can be stored in display lists

State changes persist, even after a display list is finished

Display lists can call other display lists

Display lists are not editable, but you can fake it make a list (A) which calls other lists (B, C, and D)

delete and replace B, C, and D, as needed

Page 68: Computing & Information Sciences Kansas State University CG Basics 5 of 8: OpenGL Primer 2 CIS 636/736: (Introduction to) Computer Graphics CIS 636 Introduction

Computing & Information SciencesKansas State University

CG Basics 5 of 8: OpenGL Primer 2

CIS 636/736: (Introduction to) Computer Graphics

Display Lists and HierarchyDisplay Lists and Hierarchy

Consider model of a car Create display list for chassis Create display list for wheel

glNewList( CAR, GL_COMPILE );glCallList( CHASSIS );glTranslatef( … );glCallList( WHEEL );glTranslatef( … );glCallList( WHEEL );

…glEndList();

Page 69: Computing & Information Sciences Kansas State University CG Basics 5 of 8: OpenGL Primer 2 CIS 636/736: (Introduction to) Computer Graphics CIS 636 Introduction

Computing & Information SciencesKansas State University

CG Basics 5 of 8: OpenGL Primer 2

CIS 636/736: (Introduction to) Computer Graphics

Vertex Arrays

Colordata

Vertexdata

CPUCPU

DLDL

Poly.Poly. Per

Vertex

PerVertex

RasterRaster Frag

FragFB

FB

PixelPixel

TextureTexture

Pass arrays of vertices, colors, etc. to OpenGL in large

chunk glVertexPointer( 3, GL_FLOAT, 0, coords )

glColorPointer( 4, GL_FLOAT, 0, colors )

glEnableClientState( GL_VERTEX_ARRAY )

glEnableClientState( GL_COLOR_ARRAY )

glDrawArrays( GL_TRIANGLE_STRIP, 0, numVerts );

All active arrays are used in rendering

Page 70: Computing & Information Sciences Kansas State University CG Basics 5 of 8: OpenGL Primer 2 CIS 636/736: (Introduction to) Computer Graphics CIS 636 Introduction

Computing & Information SciencesKansas State University

CG Basics 5 of 8: OpenGL Primer 2

CIS 636/736: (Introduction to) Computer Graphics

Why use Display Listsor Vertex Arrays?

Why use Display Listsor Vertex Arrays?

May provide better performance than immediate mode rendering

Display lists can be shared between multiple OpenGL context

reduce memory usage for multi-context applications

Vertex arrays may format data for better memory access

Page 71: Computing & Information Sciences Kansas State University CG Basics 5 of 8: OpenGL Primer 2 CIS 636/736: (Introduction to) Computer Graphics CIS 636 Introduction

Computing & Information SciencesKansas State University

CG Basics 5 of 8: OpenGL Primer 2

CIS 636/736: (Introduction to) Computer Graphics

Multi-pass RenderingMulti-pass Rendering

Blending allows results from multiple drawing passes to be combined together enables more complex rendering algorithms

Example of bump-mappingdone with multi-pass

OpenGL algorithm

Page 72: Computing & Information Sciences Kansas State University CG Basics 5 of 8: OpenGL Primer 2 CIS 636/736: (Introduction to) Computer Graphics CIS 636 Introduction

Computing & Information SciencesKansas State University

CG Basics 5 of 8: OpenGL Primer 2

CIS 636/736: (Introduction to) Computer Graphics

Next Time (OpenGL Part 3 of 3):Accumulation Buffer

Next Time (OpenGL Part 3 of 3):Accumulation Buffer

Problems of compositing into color buffers

Limited color resolutionclamping

loss of accuracy

Accumulation buffer acts as “floating point” color bufferaccumulate into accumulation buffer

transfer results to frame buffer

Page 73: Computing & Information Sciences Kansas State University CG Basics 5 of 8: OpenGL Primer 2 CIS 636/736: (Introduction to) Computer Graphics CIS 636 Introduction

Computing & Information SciencesKansas State University

CG Basics 5 of 8: OpenGL Primer 2

CIS 636/736: (Introduction to) Computer Graphics

Next Time (OpenGL Part 3 of 3):Fog

Next Time (OpenGL Part 3 of 3):Fog

Page 74: Computing & Information Sciences Kansas State University CG Basics 5 of 8: OpenGL Primer 2 CIS 636/736: (Introduction to) Computer Graphics CIS 636 Introduction

Computing & Information SciencesKansas State University

CG Basics 5 of 8: OpenGL Primer 2

CIS 636/736: (Introduction to) Computer Graphics

Getting to FramebufferGetting to Framebuffer

BlendingBlendingDepthTest

DepthTest DitheringDithering Logical

Operations

LogicalOperations

ScissorTest

ScissorTest

StencilTest

StencilTest

AlphaTest

AlphaTest

Fra

gm

en

t

Fra

me

bu

ffer

Page 75: Computing & Information Sciences Kansas State University CG Basics 5 of 8: OpenGL Primer 2 CIS 636/736: (Introduction to) Computer Graphics CIS 636 Introduction

Computing & Information SciencesKansas State University

CG Basics 5 of 8: OpenGL Primer 2

CIS 636/736: (Introduction to) Computer Graphics

Next Time (OpenGL Part 3 of 3):Stencil Buffer

Next Time (OpenGL Part 3 of 3):Stencil Buffer

Used to control drawing based on values in the stencil buffer Fragments that fail the stencil test are not drawn Example: create a mask in stencil buffer and draw only objects not in

mask area

CPUCPU

DLDL

Poly.Poly. Per

Vertex

PerVertex

RasterRaster Frag

FragFB

FB

PixelPixel

TextureTexture

Page 76: Computing & Information Sciences Kansas State University CG Basics 5 of 8: OpenGL Primer 2 CIS 636/736: (Introduction to) Computer Graphics CIS 636 Introduction

Computing & Information SciencesKansas State University

CG Basics 5 of 8: OpenGL Primer 2

CIS 636/736: (Introduction to) Computer Graphics

Next Time (OpenGL Part 3 of 3):Advanced Imaging

Next Time (OpenGL Part 3 of 3):Advanced Imaging

Imaging SubsetOnly available if GL_ARB_imaging defined

Color matrixConvolutionsColor tablesHistogramMinMaxAdvanced Blending

Page 77: Computing & Information Sciences Kansas State University CG Basics 5 of 8: OpenGL Primer 2 CIS 636/736: (Introduction to) Computer Graphics CIS 636 Introduction

Computing & Information SciencesKansas State University

CG Basics 5 of 8: OpenGL Primer 2

CIS 636/736: (Introduction to) Computer Graphics

On-Line ResourcesOn-Line Resources

http://www.opengl.orgstart here; up to date specification and lots of sample code

news:comp.graphics.api.opengl http://www.sgi.com/software/opengl http://www.mesa3d.org/

Brian Paul’s Mesa 3D

http://www.cs.utah.edu/~narobins/opengl.htmlvery special thanks to Nate Robins for the OpenGL Tutorssource code for tutors available here!

http://nehe.gamedev.net

Page 78: Computing & Information Sciences Kansas State University CG Basics 5 of 8: OpenGL Primer 2 CIS 636/736: (Introduction to) Computer Graphics CIS 636 Introduction

Computing & Information SciencesKansas State University

CG Basics 5 of 8: OpenGL Primer 2

CIS 636/736: (Introduction to) Computer Graphics

Books

OpenGL Programming Guide, 5th – 6th Edition

OpenGL Shading Language, 2nd Edition

OpenGL Programming for the X Window System

includes many GLUT examples

Interactive Computer Graphics: A top-down approach with OpenGL, 4th – 5th Edition

Page 79: Computing & Information Sciences Kansas State University CG Basics 5 of 8: OpenGL Primer 2 CIS 636/736: (Introduction to) Computer Graphics CIS 636 Introduction

Computing & Information SciencesKansas State University

CG Basics 5 of 8: OpenGL Primer 2

CIS 636/736: (Introduction to) Computer Graphics

Summary

Four More Short 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

Dave Shreiner: Advanced Topics Display lists and vertex arrays

Fog

Stencil buffering, fragment programs (to be continued)

Page 80: Computing & Information Sciences Kansas State University CG Basics 5 of 8: OpenGL Primer 2 CIS 636/736: (Introduction to) Computer Graphics CIS 636 Introduction

Computing & Information SciencesKansas State University

CG Basics 5 of 8: OpenGL Primer 2

CIS 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

Page 81: Computing & Information Sciences Kansas State University CG Basics 5 of 8: OpenGL Primer 2 CIS 636/736: (Introduction to) Computer Graphics CIS 636 Introduction

Computing & Information SciencesKansas State University

CG Basics 5 of 8: OpenGL Primer 2

CIS 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