1/45 CS148: Introduction to Computer Graphics and Imaging Scanline Rendering Electric Sheep screensaver by Scott Draves Image created collectively by users.

Slides:



Advertisements
Similar presentations
Real-Time Rendering 靜宜大學資工研究所 蔡奇偉副教授 2010©.
Advertisements

COMPUTER GRAPHICS SOFTWARE.
Understanding the graphics pipeline Lecture 2 Original Slides by: Suresh Venkatasubramanian Updates by Joseph Kider.
Graphics Pipeline.
Status – Week 257 Victor Moya. Summary GPU interface. GPU interface. GPU state. GPU state. API/Driver State. API/Driver State. Driver/CPU Proxy. Driver/CPU.
Computer Graphic Creator: Mohsen Asghari Session 2 Fall 2014.
David Luebke5/16/2015 Administrivia l Back on track: canceling OpenGL lecture 2 l Assignment 1 –Greg Yukl found an alternate XForms site:
CGDD 4003 THE MASSIVE FIELD OF COMPUTER GRAPHICS.
Status – Week 277 Victor Moya.
GPU Simulator Victor Moya. Summary Rendering pipeline for 3D graphics. Rendering pipeline for 3D graphics. Graphic Processors. Graphic Processors. GPU.
Status – Week 283 Victor Moya. 3D Graphics Pipeline Akeley & Hanrahan course. Akeley & Hanrahan course. Fixed vs Programmable. Fixed vs Programmable.
1 Angel: Interactive Computer Graphics 4E © Addison-Wesley 2005 Models and Architectures Ed Angel Professor of Computer Science, Electrical and Computer.
OpenGL (II). How to Draw a 3-D object on Screen?
CS 4731: Computer Graphics Lecture 11: 3D Viewing Emmanuel Agu.
GPU Graphics Processing Unit. Graphics Pipeline Scene Transformations Lighting & Shading ViewingTransformations Rasterization GPUs evolved as hardware.
Computer Graphics: Programming, Problem Solving, and Visual Communication Steve Cunningham California State University Stanislaus and Grinnell College.
Shadows Computer Graphics. Shadows Shadows Extended light sources produce penumbras In real-time, we only use point light sources –Extended light sources.
Course Overview, Introduction to CG Glenn G. Chappell U. of Alaska Fairbanks CS 381 Lecture Notes Friday, September 5, 2003.
C O M P U T E R G R A P H I C S Guoying Zhao 1 / 46 C O M P U T E R G R A P H I C S Guoying Zhao 1 / 46 Computer Graphics Introduction II.
REAL-TIME VOLUME GRAPHICS Christof Rezk Salama Computer Graphics and Multimedia Group, University of Siegen, Germany Eurographics 2006 Real-Time Volume.
University of Illinois at Chicago Electronic Visualization Laboratory (EVL) CS 426 Intro to 3D Computer Graphics © 2003, 2004, 2005 Jason Leigh Electronic.
3D coordinate systems X Y Z Right-Hand Coordinate System X Y Z Left-Hand Coordinate System OpenGL uses this! Direct3D uses this!
Technology and Historical Overview. Introduction to 3d Computer Graphics  3D computer graphics is the science, study, and method of projecting a mathematical.
Programmable Pipelines. Objectives Introduce programmable pipelines ­Vertex shaders ­Fragment shaders Introduce shading languages ­Needed to describe.
CSE 381 – Advanced Game Programming Basic 3D Graphics
Chapter 1: Graphics Systems and Models Instructor: Shih-Shinh Huang 1.
Advanced Computer Graphics Three Dimensional Viewing
Image Synthesis Rabie A. Ramadan, PhD 2. 2 Java OpenGL Using JOGL: Using JOGL: Wiki: You can download JOGL from.
CS 450: COMPUTER GRAPHICS REVIEW: INTRODUCTION TO COMPUTER GRAPHICS – PART 2 SPRING 2015 DR. MICHAEL J. REALE.
CSC 461: Lecture 3 1 CSC461 Lecture 3: Models and Architectures  Objectives –Learn the basic design of a graphics system –Introduce pipeline architecture.
CS 480/680 Computer Graphics Image Formation Dr. Frederick C Harris, Jr.
CSE Real Time Rendering Week 2. Graphics Processing 2.
1 Introduction to Computer Graphics with WebGL Ed Angel Professor Emeritus of Computer Science Founding Director, Arts, Research, Technology and Science.
Computer Graphics The Rendering Pipeline - Review CO2409 Computer Graphics Week 15.
1Computer Graphics Lecture 4 - Models and Architectures John Shearer Culture Lab – space 2
COMPUTER GRAPHICS CSCI 375. What do I need to know?  Familiarity with  Trigonometry  Analytic geometry  Linear algebra  Data structures  OOP.
Computer Graphics Chapter 6 Andreas Savva. 2 Interactive Graphics Graphics provides one of the most natural means of communicating with a computer. Interactive.
Review of OpenGL Basics
Intro to OpenGL Transformations CS 445/645 Introduction to Computer Graphics David Luebke, Spring 2003.
Computer Graphics Zhen Jiang West Chester University.
OpenGL The Viewing Pipeline: Definition: a series of operations that are applied to the OpenGL matrices, in order to create a 2D representation from 3D.
Advanced Computer Graphics Spring 2014 K. H. Ko School of Mechatronics Gwangju Institute of Science and Technology.
OpenGL Viewing and Modeling Transformation Geb Thomas Adapted from the OpenGL Programming Guidethe OpenGL Programming Guide.
Basic Perspective Projection Watt Section 5.2, some typos Define a focal distance, d, and shift the origin to be at that distance (note d is negative)
1 Graphics CSCI 343, Fall 2015 Lecture 6 Viewing, Animation, User Interface.
Chapters 5 2 March Classical & Computer Viewing Same elements –objects –viewer –projectors –projection plane.
Projections. Viewports Windows can have separate viewports void glViewport(GLint x, GLint y, GLsizei width, GLsizei height ) x, y - Specify the lower.
1 Angel: Interactive Computer Graphics5E © Addison- Wesley 2009 Image Formation Fundamental imaging notions Fundamental imaging notions Physical basis.
What are shaders? In the field of computer graphics, a shader is a computer program that runs on the graphics processing unit(GPU) and is used to do shading.
The Graphics Pipeline Revisited Real Time Rendering Instructor: David Luebke.
Chapter 1 Graphics Systems and Models Models and Architectures.
1 E. Angel and D. Shreiner: Interactive Computer Graphics 6E © Addison-Wesley 2012 Models and Architectures 靜宜大學 資訊工程系 蔡奇偉 副教授 2012.
GLSL Review Monday, Nov OpenGL pipeline Command Stream Vertex Processing Geometry processing Rasterization Fragment processing Fragment Ops/Blending.
OpenGL LAB III.
Administrivia Back on track: canceling OpenGL lecture 2 Assignment 1
Visible Surface Detection
- Introduction - Graphics Pipeline
Draw a Simple Object.
A Crash Course on Programmable Graphics Hardware
Graphics Processing Unit
CS451Real-time Rendering Pipeline
Models and Architectures
Models and Architectures
Models and Architectures
Introduction to Computer Graphics with WebGL
CSC4820/6820 Computer Graphics Algorithms Ying Zhu Georgia State University View & Projection.
The Graphics Pipeline Lecture 5 Mon, Sep 3, 2007.
Lecture 13 Clipping & Scan Conversion
Models and Architectures
Models and Architectures
Presentation transcript:

1/45 CS148: Introduction to Computer Graphics and Imaging Scanline Rendering Electric Sheep screensaver by Scott Draves Image created collectively by users on the internet

2/45 Human Eye Light comes from light sources, is absorbed and reflected off of objects, and goes through the pupil of the eye.

3/45 Without the pupil light scatters everywhere and does not make a coherent image

4/45 With a pinhole model of the pupil light makes a coherent image inside the eye

5/45 Human Retina: Rods and cones Retina contains rods and cones Rods are responsible for light intensity Cones are responsible for color vision

6/45 Three Types of Cones From

7/45 Rods Capture Intensities

8/45 Color Matching Experiment Adjust brightness of three primaries Lasers: R = 700 nm, G = 546 nm, B = 435 nm until a human mistakenly thinks it matches another color C = x nm Result: all colors can be matched with three colors Therefore: humans have trichromatic color vision C = R “+” G “+” B

9/45 Trichromatic Theory Since the human eye works in this fashion, we work this way with images, printers, and displays. Image formats store values in the R, G, and B channels. The values are between 0 and 255. The relative values give the color, and the overall values give the intensity. This is similar to the cones of the human eye. The monitor can be used to increase or decrease the image intensities (brightness/darkness). This is similar to the rods of the human eye.

10/45 Cameras A camera works similarly to the eye. ■ Light passes through the lens, bends to come to a point of focus, and makes an upside-down image on the film.

11/45 Pinhole Camera  Linear perspective with viewpoint at pinhole

12/45 Laws of Pinhole Cameras  Common assumptions  Light leaving an object travels in straight lines  These lines converge to a point (e.g. pinhole)  Infinite depth of field which means everything is in focus  Perspective image is formed by the intersection of these lines with an image plane  More distant objects subtend smaller visual angles and appear smaller  Objects in front occlude the objects behind them

13/45 OpenGL Camera  OpenGL uses a pinhole camera.  In OpenGL the image plane is in front of the focal point which means the image is right side up.  The frustum is the volume of our view (shown in blue below).  The image plane is the plane of the frustum nearest to the camera.

14/45 Specifying the Camera in OpenGL void gluLookAt(eye.x, eye.y, eye.z, at.x, at.y, at.z, up.x, up.y, up.z); - gluLookAt creates a camera from an eye point, a reference point indicating the center of the scene, and an up vector.

15/45 Specifying the Frustum in OpenGL void gluPerspective(fovy, aspect, near, far); -gluPerspective specifies a viewing frustum for the camera into the world coordinate system. -fovy specifies the field of view angle. -aspect specifies the aspect ratio of the associated image plane. -near/far specify the distance from the camera to the new/far clipping plane.

16/45 Drawing a Triangle in front of your Camera glColor3f(1.f,0.f,0.f); glBegin(GL_TRIANGLES); glVertex3f(0.f,0.f,0.f); glVertex3f(1.f,0.f,0.f); glVertex3f(.5f,.86f,0.f); glEnd(); void glBegin(Glenum mode); glBegin delimits the vertices of a primitive. mode specifies the primitive that will be created from vertices presented between glBegin and glEnd. void glVertex(x,y,z); glVertex specifies a vertex to form the primitive.

17/45 Fundamental Primitive: Triangles Why triangles? Lowest common denominator ■ Easily break convex polygons into triangles ■ Optimize the implementation of one primitive ■ Triangles have unique properties ■ Guaranteed to be planar ■ Guaranteed to have a well-defined interior ■ Well-defined method (barycentric interpolation) for interpolating values in the interior

18/45 Triangle Meshes Stanford Bunny 69,451 triangles David, Digital Michelangelo Project 28,184,526 vertices, 56,230,343 triangles

19/45 OpenGL Drawing Primitives Geometric Shapes Bitmaps Images

20/45 Graphics Rendering Pipeline Per-vertex ops Rasterization Per-fragment ops Texturing Vertices Shaded fragments Fragments Transformed vertices Frame buffer ops Display Commands Processor pixels in the framebuffer triangles, lines, points images Primitive assembly Primitives

21/45 Command queue Command interpretation Unpack and perform format conversion Maintain graphics state Command Processor glBegin(GL_TRIANGLE_STRIP); glColor3f(.0f, 1.f,.0f); glVertex3f(.0f,.0f,.0f ); glVertex3f( 0.f, 1.f,.0f ); glColor3f(1.f,.0f,.0f); glVertex3f( 1.f,.0f,.0f ); glVertex3f( 1.f, 1.f,.0f ); glEnd();

22/45 Vertex transformation Normal transformation Texture coordinate generation Texture coordinate transformation Lighting (light sources and surface reflection) Projection Per-vertex Operations World-space triangles Screen-space shaded triangles

23/45 Primitive Assembly Combine transformed/shaded vertices into primitives ■ 1 vert -> point ■ 2 verts -> line ■ 3 verts -> triangle Clipping Transform to window coordinates (viewport) Determine orientation (CW/CCW) Back-face cull

24/45 Setup (per-triangle) Sampling (triangle = {fragments}) Interpolation (interpolate colors and coordinates) Rasterization Triangles Fragments

25/45 Textures are arrays indexed by floats (Sampler) Texture address calculation Texture bilinear interpolation and filtering Texturing Fragments Texture Fragments

26/45 Per-fragment Operations Combine texture sampler outputs Per-fragment shading Fragments Textured Fragments

27/45 Operation ■ Test window ownership ■ Test scissor and stencil mask ■ Test alpha ■ Test depth Blending or compositing Frame buffer Operations Textured Fragments Framebuffer Pixels

28/45 Testing Depth using Z-Buffer  Initialize z-buffer to z max  Interpolate z across the triangle  Draw fragment if closer if(frag.Z<Z[frag.X][frag.Y]){ Z[frag.X][frag.Y]=frag.Z; C[frag.X][frag.Y]=frag.C; }

29/45 Frame Buffering Frame Buffer ■ Store image in a buffer to separate refresh rate from drawing rate Single-buffer ■ Draw into display buffer directly ■ May see picture being drawn Double-buffer ■ Display “front” buffer ■ Draw into “back” buffer (can’t see drawing) ■ Swap front and back (wait until vertical sync) Triple buffer ■ Avoid waiting for vertical sync

30/45 Framebuffer Example Framebuffer: 1440 x 900 All coordinates are integers; they refer to pixel locations in the framebuffer

31/45 Window Example Framebuffer: 1440 x 900 The window is the portion of the display usable by the application (under control of the “window system”) All coordinates are integers; they refer to pixel locations in the framebuffer Window (512 x 512)

32/45 Viewport Example Framebuffer: 1440 x 900 Viewport (256x256) All coordinates are integers; they refer to pixel locations in the framebuffer The viewport is the portion of the window that can be drawn in, no pixels will appear outside the viewport Window (512 x 512)

33/45 Specifying the Viewport in OpenGL void glViewport(x, y, w, h); -glViewport specifies the location and the size of the viewport in the screen coordinate system. Here x, y, w, and h are all integers. -x and y specify the lower left corner of the viewport rectangle. -w and h specify the width and height of the viewport. w/h should agree with the aspect ratio you set in gluPerspective.

34/45 Windows = Virtual Framebuffers Like virtual memory enables us to share the physical memory, virtual framebuffers allows us to share the physical framebuffer Abstract properties ■ Location and size on the screen ■ Stacking order

35/45 Window Coordinate Systems Window (512 x 512) Each window has a user coordinate system A 2D coordinate system is specified by assigning coordinates to the edges of the window left need not be less than right... right = 1.0left = -1.0 bottom = -1.0 top = 1.0

36/45 Exposure Parts of the window that are not visible can become visible ■ When opening ■ When unhiding ■ When brought to front How do you update the visible parts of the window? ■ Redraw entire window (or a part of it) ■ Save the drawn window in a “backing store”, and copy onto screen when needed

37/45 Display Gamma correction Analog to digital conversion Display LightFramebuffer Pixels

38/45 glBegin(GL_TRIANGLES) glVertex3fv(v1); glVertex3fv(v2); glVertex3fv(v3); glEnd() - 90 OpenGL GPU CPU

39/45 Graphics processing unit A graphics processing unit (GPU), also occasionally called visual processing unit (VPU), is a specialized electronic circuit designed to rapidly manipulate and alter memory to accelerate the building of images in a frame buffer intended for output to a display. NVIDIA’s GeForce GTX 690VisionTek Radeon 7970

40/45 What’s in a GPU? Shader Core Tex Rasterizer Framebuffer Ops Work Distributor Primitive Assembly Shader Core Shader Core Shader Core Shader Core Shader Core Shader Core Shader Core Tex

41/45 Modern PC 3.0 Ghz Intel Core2 Duo NVIDIA GeForce 8800 GTX (575 MHz) (16 cores) 512MB video Memory (GDDR3) 4MB L2 Cache 2GB main memory (DDR2) Core 1Core 2 NVIDIA 8800GTX PCIe Bus (v1 = 4 GB/sec) 84 GB/sec System board ( Intel D975 ) 12.8 GB/sec

42/45 Game Machines – Xbox Ghz PowerPC CPU Core 1Core 2Core Mhz ATI GPU 512 MB memory L2 Cache IO Chip 48 3D Cores Video out Frame buffer Display (TV) controllers/ethernet/ audio/DVD/etc.

43/45 Game Machines – PS3 3.2 Ghz Cell PPC Core SPU0 550 Mhz NVIDIA RSX GPU 256 MB video Memory (GDDR3) L2 Cache IO Chip Multiple 3D cores Video out Display (TV) controllers/ethernet/ audio/DVD/etc. SPU1SPU2SPU3SPU4SPU5SPU6SPU7 256 MB Memory (XDR)

44/45 Hybrid CPU-GPUs Intel Sandybridge Apple A5

45/45 NVIDIA GPU Performance YearProductTriangle/sFragment/s 1998Riva ZX 3m 100m 1999Riva TNT2 9m 350m 2000GeForce2 GTS 25m 664m 2001GeForce3 30m 800m 2002GeForce Ti m 1200m 2003GeForce FX 167m 2000m 2004GeForce 6800 Ultra 170m 6800m 2005GeForce 7800 GTX 940m 10300m 2006GeForce 7900 GTX 1400m 15600m 2007GeForce 8800 GTX 1800m 36800m 2008GeForce GTX m 2010GeForce GTX m 2011GeForce GTX m