Intro to lighting (Chapter 11)

Slides:



Advertisements
Similar presentations
Saito, T. and Takahashi, T. Comprehensible Rendering of 3-D Shapes Proc. of SIGGRAPH '90 Genesis of Image Space NPR.
Advertisements

Better Interactive Programs
Week 8 - Monday.  What did we talk about last time?  StdAudio.
Polygon Rendering Flat Rendering Goraud Rendering Uses Phong Reflectance Phong Rendering.
Graphics Pipeline.
2 COEN Computer Graphics I Evening’s Goals n Discuss the fundamentals of lighting in computer graphics n Analyze OpenGL’s lighting model n Show.
Computer Graphics(Fall 2003) COMS 4160, Lecture 7: OpenGL 3 Ravi Ramamoorthi Many slides courtesy Greg Humphreys.
Inventor Or How to build things.
Chapter 10 Creating 3D Objects. Objectives Extrude objects Revolve objects Manipulate surface shading and lighting Map artwork to 3D objects Work with.
Surface Rendering With OpenGL CS460 Project by Rui Yu 11/30/03.
Informationsteknologi Tuesday, November 6, 2007Computer Graphics - Class 41 Today’s class Input and interaction.
Introduction to 3D Graphics John E. Laird. Basic Issues u Given a internal model of a 3D world, with textures and light sources how do you project it.
Picking. What is picking? Selecting an object on the screen What does this require? –Get Mouse Location –Compute what objects are rendered at the position.
19/4/ :32 Graphics II Syllabus Selection and Picking Session 1.
Polygon Scan Conversion and Z-Buffering
University of Illinois at Chicago Electronic Visualization Laboratory (EVL) CS 426 Intro to 3D Computer Graphics © 2003, 2004, 2005 Jason Leigh Electronic.
CS324e - Elements of Graphics and Visualization Checkerboard World.
Chapter 10 Creating 3D Objects. Extruding Objects The Extrude & Bevel effect makes two- dimensional objects three-dimensional. A two-dimensional object.
GLWidget Description Jason Goffeney 3/8/2006. GLWidget The GLWidget class extends the Qt QGLWidget. The QGLWidget is a Qt Widget that happens to have.
Korea University Korea University Computer Graphics Laboratory Computer Graphics Laboratory Jung Lee, Chapter 13.
CSE 470: Computer Graphics. 10/15/ Defining a Vertex A 2D vertex: glVertex2f(GLfloat x, GLfloat y); 2D vertexfloating pointopenGL parameter type.
Graphics Concepts CS 2302, Fall /3/20142 Drawing Paths.
1 10/24/ :01 UML Graphics II Shadows Session 4.
Computer Graphics Chapter 6 Andreas Savva. 2 Interactive Graphics Graphics provides one of the most natural means of communicating with a computer. Interactive.
OpenGL Selection. Three Selection Methods Color coding (OpenGL) Selection mode (OpenGL) Selection ray (generic)
1 Perception and VR MONT 104S, Fall 2008 Lecture 21 More Graphics for VR.
Computer Graphics: Programming, Problem Solving, and Visual Communication Steve Cunningham California State University Stanislaus and Grinnell College.
Chapters 5 2 March Classical & Computer Viewing Same elements –objects –viewer –projectors –projection plane.
1 CSCE 441: Computer Graphics Hidden Surface Removal Jinxiang Chai.
© 2011 Delmar, Cengage Learning Chapter 10 Creating 3D Objects.
Selection Mode, Introduction to Widgets Glenn G. Chappell U. of Alaska Fairbanks CS 381 Lecture Notes Monday, October 6, 2003.
Illumination and Shading. Illumination (Lighting) Model the interaction of light with surface points to determine their final color and brightness OpenGL.
Computer Graphics Overview
MOM! Phineas and Ferb are … Aims:
Scratch for Interactivity
Week 7 - Monday CS361.
Photorealistic Rendering vs. Interactive 3D Graphics
EEC-693/793 Applied Computer Vision with Depth Cameras
Computer Graphics Chapter 9 Rendering.
The Graphic PipeLine
Introduction to the Mouse
Better Interactive Programs
Modeling 101 For the moment assume that all geometry consists of points, lines and faces Line: A segment between two endpoints Face: A planar area bounded.
Deferred Lighting.
Week 8 - Monday CS 121.
Class 11 timers Iron Maiden example Double Buffering BallAndTorus
CSCE 441: Computer Graphics Hidden Surface Removal
Starting to draw dealing with Windows which libraries? clipping
Advanced Menuing, Introduction to Picking
Chapters 5/4 part2 understanding transformations working with matrices
Lighting.
Class 26 more textures environmental textures Color ramps
Class 12 Complex object with moving parts
Chapter 10 Algorithms.
Chapter 3 arrays of vertices vertex arrays display lists drawing text
Better Interactive Programs
Lighting Phong's Lighting Model normals
Texture and Shadow Mapping
Lecture 7: Introduction to Processing
Simple Graphics Package
2D Graphics Lecture 4 Fri, Aug 31, 2007.
Chapter 3 arrays of vertices vertex arrays display lists drawing text
Starting to draw dealing with Windows which libraries? clipping
Chapter 10 Algorithms.
Class 27 more textures environmental textures Color ramps
Picking in OpenGL Yingcai Xiao.
Class 12 idle function timers Iron Maiden example Double Buffering
Frame Buffer Applications
Collision Detection.
More on Picking and Selecting
Presentation transcript:

Intro to lighting (Chapter 11) Class 13 Selection and Picking dragging with picking Collision Detection articulated Figure Intro to lighting (Chapter 11)

Picking and Selection Run BallAndTorusPicking.cpp to understand the problem. How computer knows which shape or color to use for drawing. How can the computer "know" which shape belongs to a pixel to modify?

glRenderMode(GL_SELECT) Selection Tell computer you will be selecting glRenderMode(GL_SELECT) Specify a (new, small) viewing volume selection volume Redraw the scene, invisibly, recoding which items hit the viewing volume hit list

when hit records are written A hit record is written into the hit buffer when both a name stack manipulation or a glRenderMode() command is encountered a hit has occured - a primitive has been drawn that intersects the selection volume

what hit records contain the number of names in the name stack at the time of writing the record the min z-value‡ of primitives that hit selection volume since last hit record was written the max z-value‡ of primitives that hit selection volume since last hit record was written the sequence of names in the name stack at time of writing, bottom one first, may be none.

How to PICK the right selection volume?

gluPickMatrix(pickX, pickY, width, height, viewport[4]) glLoadIdentity(); gluPickMatrix(pickX, pickY,width,height, viewport[4]); glFrustrum(); or gluPerspective; or glOrtho; (same as resize function, or what the program is using.)

gluPickMatrix(pickX, pickY, width, height, viewport[4]) pickX and pickY are in gl screen coords. front face of selection volume is centered at (pickX, pickY) with given width and height. In pixels. viewport array supplies current viewport boundaries. Can use glGetIntegerv(GL_VIEWPORT,viewport)

min and max values ‡ min and max are "normalized" by dividing by depth of selection volume, so value is in range [0,1]. Then multiplied by 232-1 and stored as an unsigned int.

ballAndTorusPicking.cpp void drawBallAndTorus(void) void drawScene(void) // The mouse callback routine. void pickFunction(int button, int state, int x, int y) void findClosestHit(int hits, unsigned int buffer[]) void animate(int value)

ballAndTorusPicking Make these changes for better model In function drawBallAndTorus remove glutSwapBuffers(); In function drawScene add glutSwapBuffers();

In Ortho, dragging using selection BoxAndCubesPickingAndDragging.cpp (MJB) use selection to know you have clicked on object while button stays down, use mouseMotion. end motion when button released On board, discuss change of coordinates

In Ortho, dragging using selection BoxAndCubesPickingAndDragging.cpp (MJB) Don't call glutPostRedisplay in drawScene. Do swap buffers (or flush) in drawScene Do call glutPostRedisplay in mouseMotion Don't swap buffers in drawBoxAndCubes Don't glutPostRedisplay in drawBoxAndCubes

other ways to pick we won't cover Color each object a different colors, and check the color of the pixel using glReadPixels Using a pick ray and gluUnProject

collision detection Run spaceTravel.cpp Go through code - non-collision parts Notice class, constructors Notice viewports. Notice display list. Notice rand. In setup I added srand(time(0)); Need to include ctime I also changed FILL_PROBABILITY

collision detection Run spaceTravel.cpp Go through code - non-collision parts Notice class, constructors Notice viewports. Notice display list. Notice rand. In setup I added srand(time(0)); Need to include ctime I also changed FILL_PROBABILITY

geometry of the spacecraft radius 5 height 10 red center to edge of circle =sqrt(50) = 7.072

geometry of collisions Got to Here!!!!!!!!

collision detection spaceTravel.cpp static int isCollision = 0; // Is there collision between the spacecraft and an asteroid? functions: int checkSpheresIntersection(...) int asteroidCraftCollision(...) see specialKeyInput function

Articulated Figure On your own, run animateMan.cpp. Do the experiments in the book. Come back with questions.

Phong's Lighting Model Ambient light - even light all around. Direction of light and viewer don't matter. Diffuse - fine scale graininess of surface. Direction of light source matters, direction of viewer doesn't matter. Specular - shininess of surface. Direction of light source and viewer both matter.

Run sphereInBox1.cpp Observe box and ball materials and lighting. Look at code later.

Lots of thing to specify for each light and material of objects Ambient R, G, B Diffuse R, G, B Specular R, G, B For material, also emissive - looks like light coming from object. Specular also has a shininess component.

Normals To get proper reflection, we need to know "surface direction".

BoxAndSquaresPickingAndViews.cpp Cookie cutter approach – take advantage of it!