Intro. Computer Graphics
Total Page:16
File Type:pdf, Size:1020Kb
An Introduction to Computer Graphics Joaquim Madeira Beatriz Sousa Santos Universidade de Aveiro 1 Topics What is CG Brief history Main applications CG Main Tasks Simple Graphics system CG APIs 2D and 3D Visualization Illumination and shading Computer Graphics The technology with which pictures, in the broadest sense of the word, are Captured or generated, and presented Manipulated and / or processed Merged with other, non-graphical application data It includes: Integration with other kinds of data – Multimedia Advanced dialogue and interactive technologies 3 Computer Graphics Computer Graphics deals with all aspects of creating images with a computer Hardware Software Applications [Angel] 4 Computer Graphics: 1950 – 1960 Earliest days of computing Pen plotters Simple calligraphic displays Issues Cost of display refresh Slow, unreliable, expensive computers 5 Computer Graphics: 1960 – 1970 Wireframe graphics Draw only lines ! [Angel] 6 Computer Graphics: 1960 – 1970 Ivan Sutherland’s Sketchpad PhD thesis at MIT (1963) Man-machine interaction Processing loop Display something Wait for user input Generate new display [http://history-computer.com] 7 Sketchpad (Ivan Sutherland, 1963) http://www.youtube.com/watch?feature=endscreen&NR=1&v=USyoT_Ha_bA 8 Computer Graphics: 1970 – 1980 Raster graphics Allows drawing polygons First graphics standards Workstations and PCs 9 Raster graphics Image produced as an array (the raster) of picture elements (pixels) in the frame buffer [Angel] 10 Raster graphics Drawing polygons Illumination models Shading methods [Angel] 11 Gouraud shading – 1971 [Wikipedia] 12 Gouraud shading Poor highlight Very high polygon count http://en.wikipedia.org/wiki/Gouraud_shading 13 Phong shading– 1973 [Wikipedia] 14 Phong reflection model – 1973 [Wikipedia] 15 Can you see the differences ? [Foley , Van Dam] 16 Computer Graphics: 1980 – 1990 The quest for realism Smooth shading Environment mapping Bump mapping [Angel] 17 Ray-Tracing example http://radsite.lbl.gov/radiance/book/img/plate10.jpg 19 https://en.wikipedia.org/wiki/Ray_tracing_(graphics) “Vermeer’s Studio” Wallace & Cohen, 1987: Radiosity and Ray-Tracing 22 Radiosity Radiosity https://en.wikipedia.org/wiki/Radiosity_(computer_graphics) Radiosity Without radiosity With radiosity [Burdea] 24 Texture mapping Smooth shading Environment mapping Bump mapping [Angel] 25 Computer Graphics: 1980 – 1990 Special purpose hardware Industry-based standards PHIGS RenderMan (https://renderman.pixar.com/) Human-Computer Interaction 27 Computer Graphics: 1990 – 2000 OpenGL API First successful computer-generated feature- length animation film: Toy Story New hardware capabilities 28 Oscar winner 2017- Piper https://renderman.pixar.com/stories https://www.youtube.com/watch?v=lkQTe0Wdo2k http://oscar.go.com/news/winners/piper-is-the-2017-oscar-winner-for-short-film-animated Computer Graphics: 2000 – … Photorealism Graphics cards for PCs dominate the market Nvidia ATI Game boxes / players determine the market CG is routine in the film industry 30 The first “two waves” of CG research Product design and manufacturing improvements drove research from the 1960s through the 1980s Arts and entertainment became the dominant driver in the mid-1980s, but has been decreasing And now? Kasik, D. J. (2011). The third wave in Computer Graphics and Interactive Techniques. IEEE Computer Graphics And Applications, 31(4), 89–93. CG – Application areas Entertainment Computer games Animation films Special effects Engineering / Architecture Computer-Aided Design (CAD) Data Visualization Medicine Visualization … 32 Games – Lara Croft 1996 2007 2013 [Wikipedia] 33 Animation films – Pixar Toy Story – 1995 Ratatouille – 2007 Toy Story – 2014 [www.pixar.com] 34 Special effects – ILM 1991 1994 1999 [Wikipedia] 36 Special effects – ILM 2005 2009 2015 [Wikipedia] 37 Computer-Aided Design CAD mockup [Wikipedia] 38 CAD – Simulation [Wikipedia] 39 Virtual and Augmented Reality Virtual Reality – examples Industry Jaguar/ Land Rover http://www.youtube.com/watch?v=j3qcnvgVlNk 41 Medicine http://www.youtube.com/ watch?v=zJmrcEM-uvA 43 Entertainment Oculus Rift 2014; ~300 USD http://www.oculusvr.com/ http://www.youtube.com/watch?v=N8uuDT5AYts44 CG is not alone… Visualization Core areas: IP CG HCI CG, IP, CV and HCI CV Satellite areas: Geometric Geometric Modeling Modeling Data and Information Visualization What is common? CG, IP : image file formats, color models, … CG, CV : 3D model representations, … IP, CV : noise removal, filters, … 45 Example – Medical Imaging Processing pipeline Noise removal Segmentation Generating 2D / 3D models Data visualization User interaction … [www.mevislab.de] RVA - 2014/2015 47 CG Main Tasks Modeling Construct individual models / objects Assemble them into a 2D or 3D scene Animation Static vs. dynamic scenes Movement and / or deformation Rendering Generate final images Where is the observer? How is he / she looking at the scene? 48 Basic Graphics System [Angel] Image formed in the frame buffer 49 Computer Graphics APIs Create 2D / 3D scenes from simple primitives OpenGL Rendering No modeling or interaction facilities Direct 3D – Microsoft VTK 3D CG + Image processing + Visualization Three.js … 50 API contents Functions for specifying / instantiating Geometric primitives Materials Light sources Viewer / Camera … Functions for simple user interaction Input from devices: mouse, keyboard, etc. 51 Geometric Primitives Simple primitives Points Line segments Polygons Geometric primitives Parametric curves / surfaces Cubes, spheres, cylinders, etc. 52 Lights and materials Types of light sources Point vs distributed light sources Spot lights Near and far sources Color properties Material properties Absorption: color properties Scattering: diffuse and specular Transparency 53 Camera specification Position and orientation Lens image size Orientation of image plane [Angel] 54 OpenGL Multi-platform API for rendering 2D and 3D computer graphics Interaction with the GPU to achieve hardware-accelerated rendering Application areas CAD Virtual reality Scientific and Information Visualization … 55 OpenGL OpenGL ES Subset for use in embedded systems and portable devices WebGL JavaScript API based on OpenGL ES 2.0 Rendering interactive 2D and 3D graphics on any compatible browser, without the use of plug-ins 56 Three.js Cross-browser JavaScript library/API used to create and display animated 3D computer graphics in a web browser. Uses WebGL https://threejs.org/ Thee.js first example 1. Defining the scene, the camera and where the scene is rendered var scene = new THREE.Scene(); var camera = new THREE.PerspectiveCamera( 75, window.innerWidth / window.innerHeight, 0.1, 1000 ); var renderer = new THREE.WebGLRenderer(); renderer.setSize( window.innerWidth, window.innerHeight ); document.body.appendChild( renderer.domElement ); 58 2.Creating an object and camera position var geometry = new THREE.BoxGeometry(1,1,1); var material = new THREE.MeshBasicMaterial( { color: 0x00ff00 } ); var cube = new THREE.Mesh( geometry, material ); scene.add( cube ); camera.position.z = 5; 59 3. Scene rendering function render() { requestAnimationFrame(render); renderer.render(scene, camera); } render(); 4. Scene animation cube.rotation.x += 0.1; cube.rotation.y += 0.1; 60 Adding lights and shading var material = new THREE.MeshPhongMaterial({ ambient: '#006063', color: '#00abb1', specular: '#a9fcff', shininess: 100 }); 61 2D Visualization Define a 2D scene in the world coordinate system Select a clipping window in the XOY plane The window contents will be displayed Select a viewport in the display The viewport displays the contents of the clipping window 62 World -> display y y Display Coordinates x World Coordinates x Coordinate mapping World Coordinates Screen coordinates 64 Coordinate mapping If the aspect ration is not the same in both situations the result is distortion 65 World -> screen y y Screen Coordinates x The aspect ration is not the same in both situations: distortion! World Coordinates x 3D Viewing 68 3D Viewing Where is the observer / the camera ? Position ? Close to the 3D scene ? Far away ? How is the observer looking at the scene ? Orientation ? How to represent as a 2D image ? Projection ? 69 Obtaining an image of the scene using perspective View frustum image [Interactive 3D Graphics, Udacity] Light and Rendering In the real world the light emits rays that are reflected by objects and seen by the eye Computing this is too time consuming {Interactive 3D Graphics, Udacity] Reversing the process in CG In CG simplifying assumptions may be made Start from the camera No shadows Only the rays that matter are processed 3D visualization pipeline Instantiate models of the scene Position, orientation, size Establish viewing parameters Camera position and orientation Compute illumination and shade polygons Perform clipping Project into 2D Rasterize 73 3D visualization pipeline Each object is processed separately Typically 3D triangles (e.g. a cube or a sphere are made of triangles) Triangles are modified by the camera view of the world Is the object inside the view frustum? (No -> next object!) Yes -> compute the location on the screen of each triangle (rasterization) Compute the color of each pixel 74 3D scene Geometry Material Light (animation) + Camera {Interactive 3D Graphics, Udacity] Projection Parallel Projection Perspective