Cameras (and eye) Ideal Pinhole. Real Pinhole. Real + lens. Depth of field

Similar documents
CS 4204 Computer Graphics

Graphics Programming. August 31, Programming of the Sierpinski gasket. Programming with OpenGL and C/C++

CS559: Computer Graphics. Lecture 12: OpenGL Li Zhang Spring 2008

Introduction to Computer Graphics with OpenGL/GLUT

Computer Graphics (Basic OpenGL)

// double buffering and RGB glutinitdisplaymode(glut_double GLUT_RGBA); // your own initializations

Precept 2 Aleksey Boyko February 18, 2011

GL_COLOR_BUFFER_BIT, GL_PROJECTION, GL_MODELVIEW

Lectures OpenGL Introduction

Computer Graphics. Bing-Yu Chen National Taiwan University

To Do. Computer Graphics (Fall 2008) Course Outline. Course Outline. Methodology for Lecture. Demo: Surreal (HW 3)

C++ is Fun Part 13 at Turbine/Warner Bros.! Russell Hanson

Computer Graphics Course 2005

1.2 Basic Graphics Programming

Using OpenGL with CUDA

OpenGL refresher. Advanced Computer Graphics 2012

RECITATION - 1. Ceng477 Fall

Lecture 3. Understanding of OPenGL programming


Graphics Programming

Programming using OpenGL: A first Introduction

Basic Graphics Programming

Abel J. P. Gomes LAB. 1. INTRODUCTION TO OpenGL

Teacher Assistant : Tamir Grossinger Reception hours: by - Building 37 / office -102 Assignments: 4 programing using

Basic Graphics Programming

Drawing Primitives. OpenGL basics

Graphics Programming. 1. The Sierpinski Gasket. Chapter 2. Introduction:

11/1/13. Basic Graphics Programming. Teaching Assistant. What is OpenGL. Course Producer. Where is OpenGL used. Graphics library (API)

C OMPUTER G RAPHICS Thursday

Computer Graphics. OpenGL

CSE4030 Introduction to Computer Graphics

Announcements OpenGL. Computer Graphics. Autumn 2009 CS4815

Books, OpenGL, GLUT, GLUI, CUDA, OpenCL, OpenCV, PointClouds, and G3D

Computer Graphics 1 Computer Graphics 1

Ulf Assarsson Department of Computer Engineering Chalmers University of Technology

Programming with OpenGL Part 3: Three Dimensions

Computer Graphics. Making Pictures. Computer Graphics CSC470 1

Lecture 2 CISC440/640 Spring Department of Computer and Information Science

Interaction. CSCI 480 Computer Graphics Lecture 3

OpenGL Tutorial. Ceng 477 Introduction to Computer Graphics

Interaction Computer Graphics I Lecture 3

CS 4731 Lecture 3: Introduction to OpenGL and GLUT: Part II. Emmanuel Agu

UNIT 7 LIGHTING AND SHADING. 1. Explain phong lighting model. Indicate the advantages and disadvantages. (Jun2012) 10M

Computer Graphics Introduction to OpenGL

Lecture 3 Advanced Computer Graphics (CS & SE )

Assignment 1. Simple Graphics program using OpenGL

Announcements OpenGL. Computer Graphics. Spring CS4815

CS559: Computer Graphics. Lecture 12: OpenGL Transformation Li Zhang Spring 2008

CMSC 425: Lecture 4 More about OpenGL and GLUT Tuesday, Feb 5, 2013

COS340A Assignment 1 I Pillemer Student# March 25 th 2007 p1/15

Books, OpenGL, GLUT, CUDA, OpenCL, OpenCV, PointClouds, G3D, and Qt

Programming with OpenGL Part 1: Background

OpenGL/GLUT Intro. Week 1, Fri Jan 12

Introduction to OpenGL: Part 2

Exercise 1 Introduction to OpenGL

(21) OpenGL GUI. OpenGL GUI 1 UNIX MAGAZINE UNIX. SGI (Silicon Graphics Inc.) Windows PC GUI. UNIX Windows GUI. Java. 1 prefposition() X X

COMPUTER GRAPHICS LAB # 3

Computer Graphics Primitive Attributes

ERKELEY DAVIS IRVINE LOS ANGELES RIVERSIDE SAN DIEGO SAN FRANCISCO EECS 104. Fundamentals of Computer Graphics. OpenGL

Introduction to MS Visual C/C++

2. OpenGL -I. 2.1 What is OpenGL? Things OpenGL can do: -23-

CS Computer Graphics: OpenGL, Continued

CS Computer Graphics: OpenGL, Continued

VR-programming tools (procedural) More VRML later in this course! (declarative)

20 GLuint objects; 36 Scale += 0.1; 37 break; 38 case GLUT_KEY_DOWN:

Hierarchical Modeling: Tree of Transformations, Display Lists and Functions, Matrix and Attribute Stacks,

Early History of APIs. PHIGS and X. SGI and GL. Programming with OpenGL Part 1: Background. Objectives

Lecture 4 of 41. Lab 1a: OpenGL Basics

Transformation, Input and Interaction. Hanyang University

Introduction to OpenGL

CS418 OpenGL & GLUT Programming Tutorial (I) Presented by : Wei-Wen Feng 1/30/2008

COMP 371/4 Computer Graphics Week 1

QUESTION 1 [10] 2 COS340-A October/November 2009

Introduction to OpenGL Week 1

Objectives. Image Formation Revisited. Physical Approaches. The Programmer s Interface. Practical Approach. Introduction to OpenGL Week 1

Introduction to OpenGL

Programming with OpenGL Part 1: Background

CS380: Computer Graphics Basic OpenGL Structure. Sung-Eui Yoon ( 윤성의 ) Course URL:

Project Sketchpad. Ivan Sutherland (MIT 1963) established the basic interactive paradigm that characterizes interactive computer graphics:

Fourier Series. Given a periodic function, x(t), (-T <t <T): + b n sin n t T. a n cos n t T. 2 a 0 + Z T. a n = 1 T. x(t) cos n t T. b n = 1 T.

Modeling Transform. Chapter 4 Geometric Transformations. Overview. Instancing. Specify transformation for objects 李同益

PART-I: Lab for MCS-051 (Advanced Internet Technologies)

Computer graphics MN1

Overview of Graphics Systems Hearn & Baker Chapter 2. Some slides are taken from Robert Thomsons notes.

Computer graphics MN1

Introduction to OpenGL

Ulf Assarsson Department of Computer Engineering Chalmers University of Technology

CS Computer Graphics: Intro to OpenGL

CS Computer Graphics: Intro to OpenGL

Display Lists in OpenGL

Introduction to OpenGL. CSCI 4229/5229 Computer Graphics Fall 2012

Duc Nguyen CSE 420 Computer Graphics 10/10/2018 Homework 1

Computer Graphics: Line Drawing Algorithms

Programming with OpenGL Part 2: Complete Programs Computer Graphics I, Fall

CS 543 Lecture 1 (Part 3) Prof Emmanuel Agu. Computer Science Dept. Worcester Polytechnic Institute (WPI)

Rendering Pipeline/ OpenGL

3D computer graphics: geometric modeling of objects in the computer and rendering them

Rendering. Part 1 An introduction to OpenGL

GLUT Tutorial. John Tsiombikas (Nuclear / The Lab Demos) May 6, Introduction to GLUT (OpenGL Utility Toolkit)

Image Processing. Geometry Processing. Reading: (Not really covered in our text. See Sects 18.1, 18.2.) Overview: Display

Transcription:

Cameras (and eye) Ideal Pinhole Real Pinhole Real + lens Depth of field 1

Z-buffer How do we draw objects? Polygon Based Fast Raytracing Ray/Object intersections Slow Copyright Pixar 2

Raytracing for each pixel on screen determine ray from eye through pixel find closest intersection of ray with an object cast off reflected and refracted ray, recursively calculate pixel colour, draw pixel end 3

Z-buffer algorithm for each polygon in model project vertices of polygon onto viewing plane for each pixel inside the projected polygon calculate pixel colour calculate pixel z-value compare pixel z-value to value stored for pixel in z-buffer if pixel is closer, draw it in frame-buffer and z-buffer end end 4

Z-buffer Graphics Pipeline OCS WCS VCS CCS Modeling transformation Viewing transformation Projection transformation Rasterization DCS Viewport transformation NDCS Perspective division 5

6

What is Open GL Open Graphics Standard Specification for INTERACTIVE 3D Graphics Specification governed by a consortium of companies Implementation is up to the manufacturer of graphics boards 7

What is it for us? Open Graphics Standard API Library State Machine Pipeline GL: Core GLU: Higher level utilities GLUT: Windowing and interaction 8

Example Headers: #include <GL/gl.h> #include <GL/glu.h> #include "GL/glut.h Libraries: glut32.lib, opengl32.lib, glu32.lib Dynamic libraries glut32.dll 9

Setting up a GLUT Window int main(int argc, char** argv) { glutinit(&argc,argv) ; glutinitdisplaymode (GLUT_DOUBLE GLUT_RGB GLUT_DEPTH); glutinitwindowposition (0, 0); glutinitwindowsize(800,800); glutcreatewindow(argv[0]); // register callbacks glutreshapefunc (myreshapecb); glutkeyboardfunc(mykeyboardcb ); glutmousefunc(mymousecb) ; glutmotionfunc(mymotioncb) ; glutdisplayfunc(display); myinit() ; glutmainloop(); return 0; } // initialize // start the main loop // never reached 10

Mouse callbacks void mymousecb(int button, int state, int x, int y) { // start or end interaction if( button == GLUT_LEFT_BUTTON && state == GLUT_DOWN ) { printf("left button down\n") ; } } if( button == GLUT_LEFT_BUTTON && state == GLUT_UP ) { printf("left button up\n") ; } glutpostredisplay() ; void mymotioncb(int x, int y) { printf("moving the mouse\n") ; glutpostredisplay() ; } // Tell the system to redraw the window // interaction (mouse motion) 11

Keyboard callback void mykeyboardcb(unsigned char key, int x, int y) { switch (key) { case 'q': case 27: exit(0); break; } } 12

Display function void display(void) { glmatrixmode(gl_projection) ; glloadidentity() ; glmatrixmode(gl_modelview) ; glloadidentity(); } glclearcolor(1.0f,1.0f,1.0f,1.0f); // set the background colour // OK, now clear the screen with the background colour glclear(gl_color_buffer_bit GL_DEPTH_BUFFER_BIT); glcolor3f(0.5,0,0) ; // set the current color drawsphere() ; glutswapbuffers(); // draw a sphere // swap the buffers (show the image) 13

Elements of a scene in OpenGL Geometric Primitives Material properties Light sources Copyright Pixar 14

Primitives in OpenGL Points Lines Curves (piece-wise linear approximation) Polygons Surfaces ( polygonal approximation) 15

Types GLint GLfloat GLdouble 16

Points glbegin(gl_points) glvertex3f(glfloat x, GLfloat y, GLfloat z) ; glvertex2i(glint x, GLint y) ; glvertex3dv(gldouble p[3] ) ; glend() ; 17

Point details glpointsize(float size) ; glcolor3f(glfloat r, GLfloat g, Glfloat b) ; 18

glbegin(gl_lines) glvertex2i(x1,y1) ; glvertex2i(x2,y2) ; glvertex2i(x3,y3) ; glvertex2i(x4,y4) ; glend() Lines 19

Line strip glbegin(gl_line_strip) glvertex2i(x1,y1) ; glvertex2i(x2,y2) ; glvertex2i(x3,y3) ; glvertex2i(x4,y4) ; glend() 20

Line loop glbegin(gl_line_loop) glvertex2i(x1,y1) ; glvertex2i(x2,y2) ; glvertex2i(x3,y3) ; glvertex2i(x4,y4) ; glend() 21

Line details gllinewidth(glfloat w) ; glcolor3f(glfloat r,glfloat g,glfloat b) ; gllinestipple(glint factor, GLushort pattern) ; glenable(gl_line_stipple) ; 22

Polygons in OpenGL glpolygonmode(gl_front,gl_fill) ; glpolygonmode(gl_back,gl_line) ; glcolor3f(red,green,blue) ; glbegin(gl_polygon) glnormal3f(v1,v2,v3) ; glvertex3f(x1,y1,z1) ; glnormal3f(v1n,v2n,v3n) ; glvertex3f(xn,yn,zn) ; glend() ; 23

Higher Primitives in GLUT glutsolidshere() ; glutsolidcube(); glutsolidcone() ; glutsolidteapot() ; 24