CPCS 391 Computer Graphics 1 Instructor: Dr. Sahar Shabanah Graphics Applications Course description • First course in computer graphics covering fundamental concepts and techniques related to 2-D and 3-D graphics. – Rasterization – Geometry – Shading – Hidden surface elimination – Texture mapping – Modeling – Animation – Ray tracing – Global illumination – Animation from M. Woo et al., 1997 Course Outline – Rasterization – Geometry Advanced Topics How to to apply set individual image pixels corresponding to How to specify model efficiently light therasterize 3-D interaction onlywith the ofscene the visible 3-Dcamera “layers” ofpositions detail to objects projected geometric objects asvarious points, lines, and surfaces parts the of features, scene with varying objects material and such theirproperties parts, in to show simulate bumps and polygons, and more complicated shapes. Antihow order totoproject calculate these theprecomputed to proper 2-D image colorslocations, perceived reflections, or other shading aliasing reduces artifacts (“jaggies”) caused bythese finite andthe by how eyetoatrepresent differenttrans-formations image locations of image resolution effects. positions – Shading – Hidden surface elimination – Texture mapping – Modeling – Ray tracing from M. Woo et al., 1997 – Global illumination Learning objectives of this course • Basic understanding of graphics hardware/software technology and algorithms • Learn how to use OpenGL to write 2D/3D drawing programs Lectures • ST, 11:00 pm-12:30 pm • Lecture slides will be posted on the course page before each lecture. • Read thru the lecture notes and the assigned readings before class. • Be prepared to ask questions. • Class website: http://groups.yahoo.com/group/CPCS391_F10/ Textbooks Any one of these: 1. Fundamentals of Computer Graphics, Peter Shirley, 3rd Revised edition edition (July 21, 2009), ISBN-10: 1568814690, ISBN-13: 9781568814698 2. Computer Graphics, C Version (2nd Edition), Donald Hearn, M. Pauline Baker, ISBN-10: 0135309247, ISBN-13: 978-0135309247 (course website) 3. Computer Graphics in C#: Principles and Practice, 3Rev Ed edition, 2008, Authors: James D. Foley, Andries van Dam, Steven K. Feiner, John F. Hughes, ISBN-10: 0321399528, ISBN-13: 978-0321399526 (old copy in CS dept.) Grading • • • • • 20% Lab & Assignments 15% Exam 1: Tuesday 27/4-20/3 15% Exam2: sunday 8/6-29/4 30% Final Project 20% Final exam Computer Graphics Computer-generated images and models or sequences of such models and images (i.e., animations, movies) The scientific study of techniques and methods for generating such images: creation, storage and manipulation. Computer Graphics Systems Interactive User controls contents, structure, and appearance of objects and their displayed images via rapid visual feedback Non-interactive batch mode Basic components used for: • Input: mouse, tablet and stylus, multi_touch • processing (and storage) • display/output :screen, printer, video recorder • final production-quality video • film (special effects – FX) First interactive graphics system, Sketchpad, 3-D Computer Graphics Applications Manufacturing design (CAD) Movies, TV, commercials • Animations • Special effects mixed with live footage Visual arts Video games Scientific visualization Simulation of natural phenomena Enabling Modern Computer Graphics Hardware revolution Every 12-18 months, computer power improves by factor of 2 in price / performance as size shrinks Newest processors are 64bit, 2, 4, 6, 8, or 12 core • Intel Core i7 – consumer, 4 cores hyper-threaded to provide 8 threads Graphic subsystems GPU: - chip designed for doing graphics operations fast - Offloads graphics processing from CPU •nVidia GeForce™, ATI Radeon™ •Advanced Per-pixel lighting •Millions of triangles per second •special purpose computation, • ganged together to make supercomputers nVidia GeForceTM chip Significant advances in GPUs every 6 months vs. several years for CPUs Enabling Modern Computer Graphics Input Devices • • • • • Mouse, tablet & stylus, multi-touch, force feedback, game controllers (e.g., Wii), • scanner, • digital camera • Whole body as interaction device: • http://www.xbox.co m/kinect Enabling Modern Computer Graphics Cell Phones/PDAs (smartphones), Laptop/Desktops, Jeff Han’s Perceptive Pixel, Microsoft Surface Micro soft Surfa ce 3D immersive virtual reality systems such as Brown’s Cave™ Enabling Modern Computer Graphics Software Improvements Algorithms and data structures Parallelization Distributed and Cloud computing • Modeling of materials • Rendering of natural phenomena • Acceleration data structures for ray tracing • Most operations are embarrassingly parallel: changing value of one pixel is often independent of other pixels • Send operations into ‘cloud’, get back results, don’t care how • Rendering even available as internet service! Graphics Display Hardware Vector Raster • Calligraphic, stroke, random-scan • Draw driven by display commands (Draw List): – move (x, y), – char(“A”) , – line(x, y) Ideal Drawing Vector Drawing • (TV, bitmap, pixmap) used in displays and laser printers • Draw driven by array of pixels (frame buffer): no semantics, lowest form of representation • “Jaggies” (aliasing errors) due to sampling continuous primitives Raste r Conceptual Framework for Interactive Graphics • • • • Graphics library is intermediary between application and display hardware (Graphics System) Application program maps application objects to views (images) of those objects by calling on graphics library. Application model contains non-graphical data (e.g., nongeometric object properties) User interaction results in modification of model and/or image Unlike with FX, images are often means to an end: synthesis, design, manufacturing, visualization,… Software Application Model/data base Application program Hardware Graphics Library Graphics System/GP U Graphics Libraries • • • • • • Examples: OpenGL™, DirectX™, Windows Presentation Foundation™ (WPF), RenderMan™ Primitives (characters, lines, polygons, meshes,…) Attributes: color- line style- material properties for 3D Lights Transformations Immediate mode vs. retained mode – immediate mode: no stored representation, package holds only attribute state, and application must completely draw each frame – retained mode: library compiles and displays from scenegraph that it maintains, a complex DAG. It is a display-centered extract of the Application Model Graphics Application Distinctions Sample-based graphics: • discrete samples to describe visual information • pixels can be created by digitizing images, using a sample-based “painting” program, etc. • example programs: Adobe Photoshop™, GIMP™ Geometry-based graphics: • geometrical model, appearance attributes, sampled for visualization (rendering) • aspects of physical world is visually simulated • Examples: • 2D apps: Adobe Illustrator™, Adobe Freehand™, Corel CorelDRAW™ • 3D apps: Autodesk’s AutoCAD2010™, Maya™, 3D Studio Max™ 18 Sample-based Graphics Images are made up of grid of discrete pixels, for 2D “picture elements” Pixels are point locations with associated sample values, usually of light intensities/colors, transparency, and other control information An image is sampled using points locations along the continuous signal and we cannot treat the pixels as little circles or squares light intensity CRT beam illumination pattern 1 pixel Mathematical pixel grid LCD display NB: Can’t resolve adjacent pixels on CRT 19 Sample-based Graphics Samples creation • directly in paint-type program, • as a sampling of continuous (analog) visual materials. E.g., photograph can be sampled (light intensity/color measured at regular intervals) with scanners, cameras • Sample values can also be input numerically (e.g., with numbers from computed dataset) image manipulation • Image editing: changes made by user, such as cutting and pasting sections, brush-type tools, and processing selected areas • Image processing: algorithmic operations that are performed on image without user intervention. Includes blurring, sharpening, edge-detection, color balancing, rotating, and warping. Preprocessing step in computer vision 20 Sampling an Image 3D scene • A color value is measured at every grid point and used to color corresponding grid square • Note: this poor sampling and image reconstruction method creates blocky image 0 = white, 5 = gray, 10 = black 21 What’s the Advantage? Image alteration • image defined in terms of colors at (x, y) on grid, • change image by altering location or color values • E.g. reverse mapping above and make 10 = white and 0 = black, Image combining • Pixel information from one image can be copied and pasted into another, replacing or combining with previously stored pixels 22 What’s the Disadvantage? WYSIAYG (What You See Is All You Get): • No additional information, no depth information • can’t examine scene from different point of view • at most can play with the individual pixels or groups of pixels to change colors, enhance contrast, find edges, etc. Image-based rendering to fake 3D scenes and arbitrary camera positions. Images constructed by interpolation, composition, warping and other operations. Photo Tourism: Exploring photo collections in 3D (Siggraph 2006) 23 Geometry-Based Graphics Geometry-based graphics applications • store mathematical descriptions, or “models,” of geometric elements (lines, polygons, polyhedrons…) and associated attributes (e.g., color, material properties). • Elements are primitive geometric shapes, primitives for short • Images created as pixel arrays (via sampling of geometry) for viewing, but not stored as part of model. Images of many different views are generated from same model • Users cannot usually work directly with individual pixels in geometry-based programs; as user manipulates geometric elements, program resamples and redisplays elements • Increasingly rendering combines geometric and samplebased graphics, both as performance hack and to increase quality of final product 24 What is Geometric Modeling? What is a model? •Captures salient features (data, behavior) of thing/phenomenon being modeled •data includes geometry, appearance attributes… •Modeling is coping with complexity Geometry Types • Real: some geometry inherent • physical (e.g., actual object such as a pump) • non-physical (e.g., mathematical function, weather data) • Abstract: no inherent geometry, but for visualization • organizational (e.g., company org. chart) • quantitative (e.g., graph of stock market) 25 Decomposition of a Geometric Model • Divide and Conquer • Hierarchy of geometrical components • Reduction to primitives (e.g., spheres, cubes, etc.) • Simple vs. not-so-simple elements (nail vs. screw) Head Shaft Point composition decomposition 26 Hierarchical (Tree) Diagram of Nail • • Object to be modeled is (visually) analyzed, and then decomposed into collections of primitive shapes. Tree diagram provides visual method of expressing “composed of” relationships of model Nail Head Body (cylinder) Shaft Point (cylinder) (cone) tree diagram • • root node leaf nodes Such diagrams are part of 3D program interfaces (e.g., 3D Studio MAX, Maya) As pointer data structure to be rendered, it is called a scenegraph 27 Composition of a Geometric Model Translate Translate and Scale Translate and Rotate Primitives in their own modeling coordinate system Composition in world (root) coordinate system • Primitives created in decomposition process must be assembled to create final object. Done with affine transformations, T, R, S (as in above example). 28 Modeling vs. Rendering Modeling • • • • • Rendering Create models Apply materials to models Place models around scene Place lights in scene Place the camera Take “picture” with camera Both can be done by modern commercial software: Autodesk MayaTM ,3D Studio MaxTM, BlenderTM, etc. Point Light Spot Light Directional Light Ambient Light lighting assignment by Patrick Doran, Spring 2009 29