CSC 470 Introduction to Computer Graphics Course basics: · Instructor – Dr. Natacha Gueorguieva ·Office 1N 205, Ext. 3288 Materials will be available at www.cs.csi.cuny.edu/~natacha · 1 midterm, 2 projects, 1 presentation, homeworks, final · Syllabus – read it as it is your contract
Some Resources • Computer Graphics using OpenGL, Hill, Prentice Hall, 2001 • OpenGL Programming Guide, Second Edition, Mason Woo, Jackie Neider, and Tom Davis, Addison-Wesley Developers Press, 1997 • OpenGL Reference Manual, Second Edition, OpenGL Architecture Review Board Editors: Renate Kempf and Chris Frazier, Addison-Wesley Developers Press, 1997 • Angel, Edward, Interactive Computer Graphics, Addison-Wesley, Reading, MA, 1997
What will I learn? Fundamentals of Computer Graphics • Uses of Computer Graphics • Programming for Computer Graphics • Computer Graphics Algorithms • Applied Linear Algebra • Modelling • Rendering • Animation
The OpenGL Graphics APIs
What won’t I learn? Painting and Imaging Software (Paintshop Pro, Adobe Photoshop) CAD Packages (AutoCAD) Animation Software (Maya) Rendering Software (Renderman) 3D Modelling (3D Studio Max)
Topics Introduction to Computer Graphics Drawing Figures Drawing Algorithms Vectors for Graphics Transformations Modelling with Polygons 3D Viewing Rendering Fractals Raster Display Tools Curves and Surface Design Colour Theory
What skills should I already have? Programming Programming Programming C++
Outline and approach
Computer graphics is concerned with all aspects of producing pictures or images using a computer. •Hardware •Software •Applications
Computer Graphics Tools • Tools are both software and hardware. – Hardware tools include video monitors, graphics cards, and printers that display graphics. – They also include input devices such as a mouse, trackball that let users point to items and draw figures.
Computer Graphics Tools cont’d • Software tools: the operating system, editor, compiler, and debugger you commonly use. – Graphics routines: e.g., functions to draw a simple line or circle (or characters such as G). – Functions to manage windows with pull-down menus, input, and dialog boxes. – Functions to allow the programmer to set up a camera in 3D coordinate system and take snapshots of objects.
Device Independent Graphics • Device independent graphics libraries that allow the programmer to use a common set of functions within an application, and to run the same application on a variety of systems and displays are available. • OpenGL is such a library, and is the tool we shall use in this course. The OpenGL way of creating graphics is used widely in both academia and industry.
So, what is computer graphics? “Computer Graphics is concerned with producing images using a computer.” Modelling
The representation of the form of objects
Rendering
The appearance of objects
Animation
The movement of objects
So, what is computer graphics? Modelling
Taking the real and turning it into the virtual. Explaining real world or fantastic objects using mathematics. If the image does not exist in real life, a blueprint is drawn by an artist. A wire frame is the simplest form of model.
So, what is computer graphics? Rendering
Drawing the Image Colour Lighting Shading Surface Texture Shadows Reflection and Transparency Intersection
So, what is computer graphics? Animation
Controlling the movement of objects. Laws of Physics Biomechanics/ Kinesiology Lip Sink Special Effects
Presentation Options Frame-by-frame: A single frame can be drawn while the user waits. (very boring) Frame-by-frame under control of the user: A sequence of frames can be drawn, as in a PowerPoint® presentation; the user presses a key to move onto the next slide, but otherwise has no way of interacting with the slides. (much less boring)
Presentation Options Animation: A sequence of frames proceeds at a particular rate while the user watches. Interactive Program: In an interactive graphics experience, the user controls the flow from one frame to another using an input device such as a mouse or keyboard in a manner that was unpredictable at the time the program was written. A computer game is a familiar case of an interactive graphics presentation.
Where Computer Graphics is Used? • Computer graphics are widely used in the production of movies, television programs, books, games, and magazines.
CSC 470 Computer Graphics, Dr..Natacha Georgieva, College of Staten Island/CUNY
17
Progression of a CG Character
Wireframe Model
Skin
Skeletal Model
Hair
Muscle Model
Final Render
Example • Where did this image come from?
• What software and/or hardware was necessary?
Preliminary answer • Application: The object is an artist’s rendition of the sun for an animation to be shown in a domed environment (planetarium) • Software: Maya for modeling and rendering but Maya is built on top of OpenGL • Hardware: PC with graphics card for modeling and rendering
Main tasks in CG • Main tasks: – modeling: creating and representing the geometry of objects in the 3D world – rendering: generating 2D images of the objects – animation: describing how objects change in time
Why study CG? • Graphics is cool – I like to see what I’m doing – I like to show people what I’m doing
• Graphics is interesting – Involves simulation, algorithms, architecture…
• I’ll never get an Oscar for my acting – But maybe I’ll get one for my CG special effects
• Graphics is fun
Graphics applications • Art, publicity
• Scientific visualization
• Education and training
• User interfaces
• CAD
• Geographical info
• Terrain modeling
• Medical
• Entertainment: Cinema
Square: Final Fantasy
Pixar: Monster’s Inc.
• Entertainment: Games
GT Racer 3
Polyphony Digital: Gran Turismo 3, A Spec
• Video Games
• Medical Visualization
The Visible Human Project
MIT: Image-Guided Surgery Project
• Computer Aided Design (CAD)
• Scientific Visualization
More Cool Pictures
Video!
Computer Graphics is Everywhere
• Pictures generated by a computer – Example: a ray-traced picture with shadows.
Graphics Programming
OpenGL API
Graphic functions: D primitive (points, lines, polygons, pixels, text, curves, surfaces) D attribute (colors, fills, type face for titles of graphs) D viewing (types of views) D transformation (rotation, translation, scaling) D input D control (communicate with window system, initialize programs, deal with errors)
Introduction to OpenGL • What is an application programmer’s interface? – Software library – Layer between programmer and graphics hardware and software
• Where does OpenGL fit in? – Between application and graphics system – Between high level API and system software
Why OpenGL? • • • • • •
Fast Simple Well-defined architecture Window system independent Supports high-end features Both geometric and pixel processing Standard, available on many platforms
Why OpenGL • • • • • • • •
industry standard stable reliable and portable evolving scalable easy to use well-documented AP provides a full set of 3D graphics routines
The Graphics Rendering Pipeline Rendering: The conversion of a scene into an image: Scene: Composed of models placed in 3D space. Models: Composed of collections of primitives. Primitives: Graphic components supported by a Render. Output Image: May be drawn on a monitor or printed on a laser printer or written to a raster in memory or to a file or ... ...Must consider device independence. The Graphics Pipeline: The “model” to “image” conversion broken into stages. Some version of the pipeline is implemented in graphics hardware to get interactive speeds.
The Graphics Rendering Pipeline
The viewing pipeline is a group of processes common from wireframe display through to near photo-realistic image generation, and is basically concerned with transforming objects to be displayed from specific viewpoint and removing surfaces that cannot be seen from this viewpoint. The input to the viewing pipeline is a list of objects with their points defined in their own local coordinate system, and the position and orientation of the viewpoint. The output is the same list of objects with their points defined in a two dimensional screen coordinate system.
Computer Graphics and Image Processing
Computer Graphics
Image Processing
• Input: objects’ model
• Input: a real image
• Output: realistic image
• Output: objects’ model
Pictures that move
Computer Animation
A sequence of images (frames)
Video Processing
The Graphics Rendering Pipeline
Coordinate Systems in the Graphics Pipeline
OCS - object coordinate system WCS - world coordinate system VCS - viewing coordinate system CCS - clipping coordinate system NDCS - normalized device coordinate system DCS - device coordinate system
Event driven programming • Almost all window based programs follow the event driven paradigm – program waits for events to occur – takes appropriate action
• Events are typically stored in an event queue • Application programs specify the types of events that are of interest • The window system passes events to apps.
Event driven programming • Appropriate action is implemented by the application calling a unique, user defined function for each event of interest • these functions are referred to as callback functions • Associating callback functions with events is not a rendering issue, OpenGL does not provide for this • GLUT (OpenGL Utility Toolkit) does
Registering Events • The function call: glutMouseFunc(mouse) – associates the callback function mouse with all mouse events • button press/release
• When a mouse button is pressed or released in the graphics application window, the user defined function mouse is called • Application ignores all mouse events without this function call
OpenGL Buffers • OpenGL supports a variety of buffers that can be used for advanced rendering – – – –
Color buffers (front, back, right, left) Depth (z) buffer Accumulation Stencil
• Window system interactions must be handled outside of OpenGL
OpenGL Related Libraries • • • • •
OpenGL Utility Library (GLU) GLX (X Window extension), glX... WGL (MS Windows extension), wgl… GLUT (OpenGL Utility Toolkit), glut… OpenInventor – C++ – high level three-dimensional applications
Clearing • Clearing color has to be set – glClearColor(r,g,b,alpha)
• Buffers can be cleared all at once – glClear(bitfield) • • • •
Color buffer Depth buffer Accumulation buffer Stencil buffer
OpenGL Interface