Introduction To Computer Graphics Techniques And Applications

Transcription

Introduction to Computer GraphicsTechniques and ApplicationsHong QinCenter for Visual Computing (CVC)Stony Brook University

Presentation Outline What is computer graphics? 3D graphics pipeline Programming basics2

What is Computer Graphics? The creation of, manipulation of, analysis of, and interactionwith pictorial representations of objects and data usingcomputers.- Dictionary of Computing A picture is worth a thousand words.- Chinese Proverb1000 words (or just 94 words), many letters though It looks like a swirl. There are smaller swirls at theedges. It has different shades of red at the outside, andis mostly green at the inside. The smaller swirls havepurple highlights. The green has also different shades.Each small swirl is composed of even smaller ones. Theswirls go clockwise. Inside the object, there are also redhighlights. Those have different shades of red also. Thegreen shades vary in a fan, while the purple ones aremore uni-color. The green shades get darker towards3the outside of the fan

Graphics Definition What is Computer Graphics?– Pictorial synthesis of real and/or imaginary objects from theircomputer-based models (or datasets) Fundamental, core elements of computer graphics––––Modeling: representation choices, geometric processingRendering: geometric transformation, visibility, simulation of lightInteraction: input/output devices, toolsAnimation: lifelike characters, natural phenomena, their interactions,surrounding environments4

Why Computer Graphics? About 50% of the brain neurons are associatedwith vision Dominant form of computer output Enable scientists (also engineers, physicians,and general users) to observe their simulationand computation Enable them to describe, explore, andsummarize their datasets (models) and gaininsights Enrich the discovery process and facilitate newinventions5

Why Computer Graphics? Applications (In essence, computer graphics �Entertainment: Movies, Video gamesGraphical user interface (GUI)Computer aided design and manufacturing (CAD/CAM)Engineering analysis and businessMedical applicationsComputer ArtEngineering AnalysisScientific visualization / simulationVirtual Realityothers6

Movies If you can image it, it can be done with computer graphics!More than one billion dollars on special effects.No end in sight for this trend!7

Movies“The Day After Tomorrow”8

Movies“Geri’s Game”, Academy Award Winner, Best Animated Short Film, 19979

Video Games Important driving force Focus on interactivity Try to avoid computation and use various tricks10

GamesQuake IIIHaloMetroid PrideDoom11

Computer-Aided Design Significant impact on the design process Mechanical, electronic design– entirely on computer Architectural and product design– Migrate to the computerUGS: towards virtual manufacturing12

Engineering Design Engineering & ArchitectureSoftwareBuildings, aircraft,automobile, computers,appliances, etc.Interactive design (meshediting, wire-frame display,etc.)Standard shape databaseDesign of structuralcomponent through numericalsimulation of the physicaloperating environmentTesting: real-time animationsCourtesy of Lana Rushing, Engineering Animation, Inc.13

Architectural Design Architecture, Engineering,ConstructionFinal product appearance:surface rendering, realisticlightingConstruction planning:architects, clients can studyappearance before actualconstructionCourtesy of Craig Mosher & Ron Burdock, Peripheral Vision Animations14

Textile Industry Fashion designReal-time cloth animationWeb-based virtual try-onapplicationsCourtesy of Thalmann, Switzerland15

Computer-Aided Design (CAD)Courtesy of Michael Guthe et al.16

Graphical User Interface: GUI Integral part of everyday computingGraphical elements everywhere– Windows, cursors, menus, icons, etc Nearly all professional programmers must have an understanding ofgraphics in order to accept input and present output to users.17

Medical Applications Significant role in saving lives Training, education, diagnosis, treatmentThe Visible Human ProjectCreation of complete,anatomically detailed 3Drepresentation of human bodies.18

Scientific Visualization Scientific datarepresentationPicture vs. stream ofnumbersTechniques: contourplots, color coding,constant value surfacerendering, custom shapesDisplay of a 2D slice through the total electrondensity of C-60; Created by Cary Sandvig of SGI19

Scientific Visualization Life SciencesProviding quantitative,three dimensional electronmicroscopy.Scientists can seestructures as they werebefore being sectioned forviewing in the electronmicroscope.Courtesy of H. Lloyd Mogensen, Northern Arizona University20

Scientific Visualization Medical imaging & visualizationCourtesy of Kaufman et al.21

Scientific Visualization / SimulationElectromagnetic potential fieldComputational Fluid Dynamics (CFD)Courtesy of Mark Toscinski and Paul Tallon22

Scientific Visualization / Simulation Urban securityCourtesy of Kaufman et al.23

Virtual Reality User interacts with objects ina 3D sceneSpecial devices (input,output)Virtual walkthroughsEquipment training (pilots,surgeons, etc.)Force reflecting gripperHaptic devicesForce feedback exoskeletonHaptic workstation24

Virtual Reality Education using computergenerated system &processmodelsVisual simulation:–––––– Aircraft simulatorSpacecraft simulatorNaval craft simulatorAutomobile simulatorHeavy machinery simulatorSurgery simulatorSpecial hardware required25

Virtual Reality Virtual tour of historicalremainsVirtual tour of Ancient Olympia, Courtesy of SGI26

Virtual Reality Virtual colonoscopy27Courtesy of Kaufman et al.

Image Processing, Analysis, and Synthesis28

Computer Art Escher Drawing– Combine interlocking shapes with tessellation toconvey the beauty in structure and infinityImage courtesy of Escher29

Computer Art Fine arts, commercial artArtistic tools for digitalart:– Mathematical software(Matlab, Mathematica)– CAD software– Sculpting, painting,calligraphy systems Graphical user interfacesSpecial input devices(pressure-sensitive stylus,graphical tablet, etc.)Baxter and Scheib demonstate their haptic art kit, at UNC30

Computer Art Digital Sculpting31

Computer Art Digital PaintingCourtesy of Kim et al.32

Computer Art Digital CalligraphyCourtesy of Tai et al.33

Prerequisites: Basic Requirements Computer science– Programming language: C/C , Java, – Data structure: array, list, queue, Mathematics– Linear algebra: scalar, vector, matrix, dot product,cross product, – Calculus: derivatives, function plot, curves,surfaces, – Geometry: Euclidean geometry, analytic geometry Computer graphics has a strong 2D/3D geometrycomponent!34

Mathematical Background Computer graphics has a strong 2D/3D geometry component Basic linear algebra is also helpful – matrices, vectors, dotproducts, cross products, etc. More continuous math (vs. discrete math) than in typicalcomputer science courses Advanced math/physics for research:––––Modeling: Differential Geometry – curves, surfaces, solidsAnimation: Computational Solid Mechanics, Fluid DynamicsRendering: Optics 35

Different Perspectives Application-oriented– Motivation, driven by real problems– E.g. scientific visualization, simulation, animation, virtual reality,computer-aided design, Mathematics-oriented– Mathematical elements– E.g. computational geometry, differential geometry, PDEs, Programming-oriented– Modeling and rendering primitives: triangle mesh, point clouds, splines, – Basic procedural routines: edge flip, edge collapse, subdivision routines, System-oriented– Architecture, hardware, and software components– E.g. workstation, cluster, GPU, 36

What’s computer graphics course all about?Not!Paint and Imaging packages (Adobe Photoshop)Cad packages (AutoCAD)Rendering packages (Lightscape)Modelling packages (3D Studio MAX)Animation packages (Digimation)37

What’s computer graphics all about? Graphics programming and algorithms OpenGL, Glut, rendering Graphics data structures polygonal mesh, half-edge structure Applied geometry, modeling Curve, surfaces, transformation, projection Well, it is a Computer Science course!38

Presentation Outline What is computer graphics? 3D graphics pipeline Programming basics39

Two Approaches Don’t care the time/costs, want results– Special effects, Movie Don’t care results, want real-time cheap– Games, Virtual Reality Recently: a lot of convergence– Movie quality games40

Two Basic Questions What to render?––––Scene representationModeling techniquesAnimation, simulation. How to put it on the n and shading 41

Basic Topics – Undergraduate Hardware, system architecture– Basic display devices– Raster-scan system (rasterization)– Input / output devices: keyboard, mouse, haptics,data glove, scanner, – Software packages: standards, APIs, specialpurpose software42

Basic Topics – Undergraduate 2D / 3D transformationand viewing– 3D viewing pipeline– Multiple coordinate systemand their transformation– Projection: parallel,perspective– Mathematical (matrix)representations43

Basic Topics – Undergraduate Ray-casting and ray-tracing– Creating photorealistic rendering images44

Basic Topics – Undergraduate Geometric models––––––Curves, surfaces, solidsPolygonal modelsParametric representationsImplicit representationsBoundary representationsBoolean operations (union,subtraction, )– Editing, Deformation45

Basic Topics – Undergraduate Illumination andShading– Light properties, lightsimulation– Local illumination(ambient, diffuse,specular)– Global illumination (raytracing)ambientdiffuse & ambientSpecular & diffuse & ambient46

3D Graphics Pipeline3D ModelAcquisitionPoint cloudsGeometricModelingCurves & surfacesDigital geometry processingMulti-resolution modeling Animation &RenderingRay tracingTexture synthesisAppearance modelingPhysics-based simulation 47

Graphics Rendering Conversion of a 3D scene into a 2D image48

Rendering Pipeline Build a pipeline Process 3D information in a series of steps Each step generates results for the next oneGeometricmodelingCreate 3DobjectsGeometricprocessingDeterminewhich objectsappear and howRasterizationDisplayConvert floating Adjust pixelspoint geometryfor specialto integer pixelresults49

The Camera Modeling:positionmodelpositionmodelProjection: chooselensViewport:choosev.v. shapechoosechoosephoto size portionof screen50

3D Models Arbitrary shapes can be triangulated!Polygonal approximation of surfacesAny 2D shape (or 3D surface) can be approximated with locallylinear polygons. To improve, we only need to increase thenumber of tionDisplay51

How Do We Represent Triangles?V5Face tableV1Vertex ,V1,V2Display52

How Do We Represent Triangles? Examplemesh with 10k rizationDisplay53

Modeling Transformation 3D scene– Many 3D models– Each one has its own coordinate system – object/modelcoordinates Modeling transformation– Place the objects in the world coordinate system– Translation, scaling, shearing, and rotation Result:– Object/model coordinates (local) Î world coordinates (global)– All vertices of scene in shared 3-D “world” coordinate ationDisplay54

Modeling Transformation: 2D Example Translation55

Modeling Transformation: 2D Example Rotation56

Modeling Transformation: 2D Example Scaling57

Modeling Transformation: 2D Example Shearing58

Modeling Transformation: 2D Example Translation Rotation Scaling Shearing Can we represent the above transformations in aunified format?59

Homogeneous Coordinates Each point (x, y) is represented as (x, y, 1)– Append a 1 at the end of vector! All transformations can be represented as matrixmultiplication! Composite transformation becomes much easierConventional coordinatehomogeneous coordinate60

Homogeneous Coordinates All transformations can be represented as matrixmultiplication! Composite transformation becomes much easier!61

Homogeneous Coordinates Composite transformation Matrix multiplication62

Homogeneous Coordinates Transformation in homogeneous coordinates63

Homogeneous Coordinates Rotation in homogeneous coordinates64

Homogeneous Coordinates Scaling in homogeneous coordinates65

Homogeneous Coordinates Shearing in homogeneous coordinates66

Viewing Transformation Rotate & translate the world to lie directly infront of the camera– Typically place camera at origin– Typically looking down -Z axis Result:– World coordinates Î view coordinates– Scene vertices in 3-D “view” or “camera”coordinate ationDisplay67

Projection Projection transform– Perspective projection– Orthographic projection Results– View coordinates Î screen coordinates– 2-D screen coordinates of clipped izationDisplay68

Rasterization & Display Convert a vertex representation in the viewcoordinate system to a pixel representation oncomputer ationDisplay69

Basic Topics – Undergraduate Hardware, system architecture, raster-scan graphics(rasterization) 2D / 3D transformation and viewing Ray-casting and ray-tracing Interface Geometric models Color representations Hidden object removal Illumination models70

Illumination and Shading Now we’ll look at how to shade surfaces to make them look 3DWe’ll see different shading models, or frameworks that determine a surface’s color at aparticular pointThese shading models can be easily modifiedto incorporate illumination and shading intothe volume rendering pipelineA shading model checks what the lightingconditions are and then figures out what thesurface should look like based on the lightingconditions and the surface parameters:Amount of light reflected(and which color(s))Amount of light absorbedAmount of light transmitted(passed through)Thus, we can characterize a surface’s shadingparameters by how much incoming light thatstrikes a surface is reflected to the eye, absorbed by the object, and transmitted71

Ambient Reflection Ambient reflection refers to reflected light thatoriginally came from the “background” and hasno clear sourceModels general level of brightness in the sceneAccounts for light effects that are difficult tocompute (secondary diffuse reflections, etc)Constant for all surfaces of a particular objectand the directions it is viewed fromDirectionless lightOne of many hacks or kludges used in computerAmbient-lit spheregraphics since every ray of light or photon hasto come from somewhere!Imagine yourself standing in a room with the curtains drawn and the lights offSome sunlight will still get through, but it will have bounced off many objects beforeentering the roomWhen an object reflect this kind of light, we call it ambient reflectionIA ambient lightka material’s ambient reflection coefficientIa ka · IA72

Diffuse Reflection Models dullness, roughness of a surfaceEqual light scattering in all directionsFor example, chalk is a diffuse reflectorUnlike ambient reflection, diffuse reflection isdependent on the location of the light relative to theobjectSo, if we were to move the light from the front of thesphere to the back, there would be little or no diffusereflection visible on the near side of the sphereCompare with ambient light, which has no directionWith ambient, it doesn’t matter where we position thecamera since the light source has no true positionComputer graphics purists don’t use ambient lights andinstead rely on diffuse light sources to give someminimal light to a sceneAmbient & diffuseDiffuse only73

Specular Reflection Models reflections on shiny surfaces(polished metal, chrome, plastics, etc.)Specular reflection is view-dependent – thespecular highlight will change as thecamera’s position changesThis implies we need to take into accountnot only the angle the light source makeswith the surface, but the angle the viewingray makes with the surfaceExample: the image you perceive in amirror changes as you move aroundExample: the chrome on your car shines indifferent ways depending on where youstand to look at it74

Specular ReflectionSpecular & diffuse & ambientSpecular & diffuseSpecular & ambientSpecular only75

Specular Reflection Ideal specular reflector (perfect mirror)reflects light only along reflection vector RNon-ideal reflectors reflect light in a lobecentered about RPhong specular reflection model:Is ks IL (cos α)ns ks IL (E·R)nscos(α) models this lobe effectThe width of the lobe is modeled by Phongexponent ns, it scales cos(α)IL: intensity of light sourceL: light vectorR: reflection vector 2 N (N·L) - LE: eye vector (Eye-P) / Eye-P α: angle between E and Rns: Phong exponentks: specular reflection coefficientincreasing ns value76

Presentation Outline What is computer graphics? 3D graphics pipeline Programming basics77

Programming in Graphics Programming languages– C/C , JAVA Graphics library -- a software interface to graphicshardware– Easy to use– Programs run efficiently– Hardware-independent Examples:– OpenGL– DirectX (Microsoft)– Java3D78

OpenGL Contains a library of over 200 functions Portable– Implementations available for nearly all hardware and operating systems Portability Æ input or windowing are not included––––Options for Windows: GLUT or MFCGLUT OpenGL Utility ToolkitImplementations of GLUT exist for most computing environmentsGLUT is portable Controlled by the OpenGL Architectural Review Board– SGI, IBM, NVIDIA, ATI, -- some major players in CG www.opengl.org79

Major Elements in OpenGL Programming Let us recall the rendering pipeline (which is shown earlier)GeometricmodelingCreate 3DobjectsGeometricprocessingDeterminewhich objectsappear and howOur taskRasterizationDisplayConvert floating Adjust pixelspoint geometryfor specialto integer pixelresultsOpenGL’s task Our focus now becomes: geometric modeling and processing Rasterization & display operations are mostly done for us byOpenGL (it also supports certain special rendering effects suchas texture mapping and anti-aliasing)80

Major Elements in OpenGL Progamming Geometric primitives– Points, lines, polygons– Smooth curves and surfaces rendered in a discrete form Appearance– Color and material– Definition of geometric objects is separate from definition ofappearance81

OpenGL Commands: A Quick Look Just function calls:glColor3f(1.0, 1.0, 1.0);GL prefixtype suffix (if variable),can also end with “v”command nameNumber of arguments (if variable) Same command, different arguments:glColor3b(255,255,255); -- same result82

Draw Geometric Primitives ExampleglBegin(mode);Specify geometric primitiviesglColor3f(1,0,0);Specify ; Specify verticesglEnd(void);End OpenGL drawing83

Geometric Primitives Names GL POINTS: individual pointsGL LINES: pairs of vertices interpreted as individual line segmentsGL LINE STRIP: series of connected line segmentsGL LINE LOOP: similar to above, with a segment added between last and first verticesGL TRIANGLES: triples of vertices interpreted as triangles.GL TRIANGLE STRIP: linked strip of triangles.GL TRIANGLE FAN: linked fan of triangles.GL QUADS: quadruples of vertices interpreted as four-sided polygonsGL QUAD STRIP: linked strip of quadrilateralsGL POLYGON: boundary of simple, convex polygon84

OpenGL Primitives ExampleglBegin(GL TRIANGLE STRIP);glColor3f(1,1,1); // colorglVertex2f(0,0); // v1glVertex2f(0,1); // v2glVertex2f(1,0); // v3glVertex2f(1,1); // v4glVertex2f(2,0); // v5glEnd();V2V1V4V3V585

OpenGL Primitives Demo86

OpenGL Geometric Processing Viewing: specify the view point (camera)– gluLookAt Modeling: place the models– glTranslate, glRotate Projection: set the lens– gluPerspective, gluOrtho2D Viewport: set the size of the photos– gluViewport87

OpenGL Geometric Processing Place the camera– gluLookAt(eye x, eye y, eye z, // view pointcen x, cen y, cen z, // center pointup x, up y, up z);// up vectorUp vectorCenter pointEye point88

OpenGL Geometric Processing Set the lens– gluPerspective (fovy, // view angle in degreesaspect, // aspect ratio of x (width) to y (height)zNear, zFar); // near and far clipping plane89

OpenGL Geometric Processing Demo90

OpenGL Geometric Processing Demo91

Advanced Topics Geometric Modeling & Processing– Editing & deformation Interactive Intuitive Natural– Variety of tools Boolean– User interface 2D sketch– Other topics Reconstruction Parameterization Courtesy of Microsoft Research Asia92

Advanced Topics Computer Animation & Simulation– Solving PDEs– Speed vs. accuracy– Physics/semi-physics– Numerical stability– Solid Linear: fast,distortion Nonlinear: slow,accurate– Fracture Connectivity Topology– FluidCourtesy of Muller, O’brien, Fedkiw et al.93

Advanced Topics Human-Computer Interaction, Virtual Reality– Dynamic manipulation– Computational power– Low-end devicesCourtesy of James, Igarashi et al.94

Other Advanced Topics Programmable graphics hardwareVisualizationMedical ImagingNon-photorealistic renderingImage-based rendering Each topic can be a course of its own!!!95

Graphics Textbooks If you want to study computer graphics seriously: Computer Graphics with OpenGL, 3rd Edition, Donald Hearnand M. Pauline Baker, Prentice Hall, 2004. Computer Graphics: Principles and Practice, 2nd edition,Foley, van Dam, Feiner, and Hughes, Addison-WesleyProfessional, 1995 Many other textbooks and/or reference books are available inbookstores 96

Conclusions Bigger picture about Computer Graphics– Animation, computer-aided design, medical application,entertainment, and other applications relevant to ComputerGraphics– Key components for undergraduates– Advanced topics for senior undergraduates, and graduateresearch Graphics rendering pipeline– Geometric modeling– Modeling/viewing transformation– Rasterization & Display Programming basics– OpenGL97

Conclusion98

Questions?99

Questions?100

Fashion design Real-time cloth animation Web-based virtual try-on applications Courtesy of Thalmann, Switzerland. 16 . – Spacecraft simulator – Naval craft simulator – Automobile simulator – Heavy machinery simulator – Surgery