CSE-423 Computer Graphics & Visualization Lec 1 : Introduction PDF

Document Details

Uploaded by Deleted User

Egypt-Japan University of Science and Technology

2024

Dr. Reda Elbasiony

Tags

computer graphics computer science visualization lecture notes

Summary

These notes cover the introduction to computer graphics, with topics ranging from hardware to applications, in Fall 2024.

Full Transcript

Department of Computer Science & Information Technology CSE-423 Computer Graphics & Visualization Lec 1 : Introduction Instructor : Dr. Reda Elbasiony Fall, 2024 What is Computer Graphics? Computer graphics deals with all aspects...

Department of Computer Science & Information Technology CSE-423 Computer Graphics & Visualization Lec 1 : Introduction Instructor : Dr. Reda Elbasiony Fall, 2024 What is Computer Graphics? Computer graphics deals with all aspects of creating images with a computer Hardware Software Applications What is Computer Graphics? Where did this image come from? What hardware/software did we use to produce it? 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 Basic Graphics System Input devices Output device Image formed in frame buffer Computer Graphics: 1950-1960 Computer graphics goes back to the earliest days of computing – Strip charts – Pen plotters – Simple displays using A/D converters to go from computer to calligraphic CRT Cost of refresh for CRT too high – Computers slow, expensive, unreliable 6 Cathode Ray Tube (CRT) 7 Shadow Mask CRT 8 Cathode Ray Tube (CRT) 9 Computer Graphics: 1960-1970 Wireframe graphics – Draw only lines Sketchpad Display Processors Storage tube wireframe representation of sun object 10 Sketchpad Ivan Sutherland’s PhD thesis at MIT – Recognized the potential of man-machine interaction – Loop Display something User moves light pen Computer generates new display – Sutherland also created many of the now common algorithms for computer graphics 11 Display Processor Rather than have the host computer try to refresh display use a special purpose computer called a display processor (DPU) Graphics stored in display list (display file) on display processor Host compiles display list and sends to DPU 12 Computer Graphics: 1970-1980 Raster Graphics Beginning of graphics standards – IFIPS GKS: European effort – Becomes ISO 2D standard Core: North American effort – 3D but fails to become ISO standard Workstations and PCs 13 Raster Graphics Image produced as an array (the raster) of picture elements (pixels) in the frame buffer 14 Raster Graphics Allows us to go from lines and wire frame images to filled polygons 15 Computer Graphics: 1980-1990 Realism comes to computer graphics smooth shading environment bump mapping mapping 16 Computer Graphics: 1980-1990 Special purpose hardware – Silicon Graphics geometry engine VLSI implementation of graphics pipeline Industry-based standards – PHIGS – RenderMan Networked graphics: X Window System Human-Computer Interface (HCI) 17 Computer Graphics: 1990-2000 OpenGL API Completely computer-generated feature-length movies (Toy Story) are successful New hardware capabilities – Texture mapping – Blending – Accumulation, stencil buffers 18 Computer Graphics: 2000-2010 Photorealism Graphics cards for PCs dominate market – Nvidia, ATI Game boxes and game players determine direction of market Computer graphics routine in movie industry: Maya, Lightwave Programmable pipelines New display technologies 19 Generic Flat Panel Display 20 Computer Graphics 2011- Graphics is now ubiquitous – Cell phones – Embedded OpenGL ES and WebGL Alternate and Enhanced Reality 3D Movies and TV 21 Image Formation In computer graphics, we form images which are generally two dimensional using a process analogous to how images are formed by physical imaging systems – Cameras – Microscopes – Telescopes – Human visual system 22 Elements of Image Formation Objects Viewer Light source(s) Attributes that govern how light interacts with the materials in the scene Note the independence of the objects, the viewer, and the light source(s) 23 Light Light is the part of the electromagnetic spectrum that causes a reaction in our visual systems Generally these are wavelengths in the range of about 350-750 nm (nanometers) Long wavelengths appear as reds and short wavelengths as blues 24 Ray Tracing and Geometric Optics One way to form an image is to follow rays of light from a point source finding which rays enter the lens of the camera. However, each ray of light may have multiple interactions with objects before being absorbed or going to infinity. 25 Luminance and Color Images Luminance Image – Monochromatic – Values are gray levels – Analogous to working with black and white film or television Color Image – Has perceptional attributes of hue, saturation, and lightness – Do we have to match every frequency in visible spectrum? No! 26 Three-Color Theory Human visual system has two types of sensors – Rods: monochromatic, night vision – Cones Color sensitive Three types of cones Only three values (the tristimulus values) are sent to the brain Need only match these three values – Need only three primary colors 27 Shadow Mask CRT 28 Additive and Subtractive Color Additive color – Form a color by adding amounts of three primaries CRTs, projection systems, positive film – Primaries are Red (R), Green (G), Blue (B) Subtractive color – Form a color by filtering white light with cyan (C), Magenta (M), and Yellow (Y) filters Light-material interactions Printing Negative film 29 Pinhole Camera Use trigonometry to find projection of point at (x,y,z) xp= -x/z/d yp= -y/z/d zp= d These are equations of simple perspective 30 Coding in WebGL Can run WebGL on any recent browser – Chrome – Firefox – Safari – IE Code written in JavaScript JS runs within browser – Use local resources 31 Example: triangle.html 32 Example Code attribute vec4 vPosition; void main(){ gl_Position = vPosition; } precision mediump float; void main(){ gl_FragColor = vec4( 1.0, 0.0, 0.0, 1.0 ); } 33 HTML File (cont) Oops... your browser doesn't support the HTML5 canvas element 34 JS File var gl; var points; window.onload = function init(){ var canvas = document.getElementById( "gl-canvas" ); gl = WebGLUtils.setupWebGL( canvas ); if ( !gl ) { alert( "WebGL isn't available" ); } // Three Vertices var vertices = [ vec2( -1, -1 ), vec2( 0, 1 ), vec2( 1, -1 ) ]; 35 JS File (cont) // Configure WebGL // gl.viewport( 0, 0, canvas.width, canvas.height ); gl.clearColor( 1.0, 1.0, 1.0, 1.0 ); // Load shaders and initialize attribute buffers var program = initShaders( gl, "vertex-shader", "fragment-shader" ); gl.useProgram( program ); // Load the data into the GPU var bufferId = gl.createBuffer(); gl.bindBuffer( gl.ARRAY_BUFFER, bufferId ); gl.bufferData( gl.ARRAY_BUFFER, flatten(vertices), gl.STATIC_DRAW ); 36 JS File (cont) // Associate out shader variables with our data buffer var vPosition = gl.getAttribLocation( program, "vPosition" ); gl.vertexAttribPointer( vPosition, 2, gl.FLOAT, false, 0, 0 ); gl.enableVertexAttribArray( vPosition ); render(); }; function render() { gl.clear( gl.COLOR_BUFFER_BIT ); gl.drawArrays( gl.TRIANGLES, 0, 3 ); } 37 Exercise Run triangle.html from the class website Load the triangle.html and triangle.js to your computer and run them from there Edit the two files to change the color and display more than one triangle 38 JavaScript Notes JavaScript (JS) is the language of the Web – All browsers will execute JS code – JavaScript is an interpreted object-oriented language References – Flanagan, JavaScript: The Definitive Guide, O’Reilly – Crockford, JavaScript, The Good Parts, O’Reilly – Many Web tutorials 39 JS Notes Is JS slow? – JS engines in browsers are getting much faster – Not a key issues for graphics since once we get the data to the GPU it doesn’t matter how we got the data there JS is a (too) big language – We don’t need to use it all – Choose parts we want to use – Don’t try to make your code look like C or Java 40 JS Notes Very few native types: – numbers – strings – booleans Only one numerical type: 32 bit float – var x = 1; – var x = 1.0; // same – potential issue in loops – two operators for equality == and === Dynamic typing 41 JS Arrays JS arrays are objects – inherit methods – var a = [1, 2, 3]; is not the same as in C++ or Java – a.length // 3 – a.push(4); // length now 4 – a.pop(); // 4 – avoids use of many loops and indexing – Problem for WebGL which expects C-style arrays 42 Typed Arrays JS has typed arrays that are like C arrays var a = new Float32Array(3) var b = new Uint8Array(3) Generally, we prefer to work with standard JS arrays and convert to typed arrays only when we need to send data to the GPU with the flatten function in MV.js 43 A Minimalist Approach We will use only core JS and HTML – no extras or variants No additional packages – CSS – JQuery Focus on graphics – examples may lack beauty 44

Use Quizgecko on...
Browser
Browser