Lecture 2 5 Aug 2004

Similar documents
Programming with OpenGL Part 1: Background

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

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

CS450/550. Pipeline Architecture. Adapted From: Angel and Shreiner: Interactive Computer Graphics6E Addison-Wesley 2012

Introduction to OpenGL Week 1

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

Computer Graphics. Bing-Yu Chen National Taiwan University

Computer Graphics - Chapter 1 Graphics Systems and Models

Drawing Primitives. OpenGL basics

CIS 441/541: Introduction to Computer Graphics Lecture 14: OpenGL Basics

Programming with OpenGL Part 1: Background

LECTURE 02 OPENGL API

API Background. Prof. George Wolberg Dept. of Computer Science City College of New York

The Display pipeline. The fast forward version. The Display Pipeline The order may vary somewhat. The Graphics Pipeline. To draw images.

Lecture 1. Computer Graphics and Systems. Tuesday, January 15, 13

Today s Agenda. Basic design of a graphics system. Introduction to OpenGL

Programming using OpenGL: A first Introduction

CSC Graphics Programming. Budditha Hettige Department of Statistics and Computer Science

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

Introduction to OpenGL

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

Computer Graphics. Bing-Yu Chen National Taiwan University The University of Tokyo

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

The Elements of Colour

Lectures OpenGL Introduction

CS 4204 Computer Graphics

Graphics Programming

Exercise 1 Introduction to OpenGL

Lecture 4 of 41. Lab 1a: OpenGL Basics

Computer Graphics (Basic OpenGL)

Image Formation. Ed Angel Professor of Computer Science, Electrical and Computer Engineering, and Media Arts University of New Mexico

Reading. 2. Color. Emission spectra. The radiant energy spectrum. Watt, Chapter 15.

Computer Graphics. OpenGL

CS 543 Lecture 1 (Part II): Intro to OpenGL and GLUT (Part I) Emmanuel Agu

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

Lecture 1 Image Formation.

GL_COLOR_BUFFER_BIT, GL_PROJECTION, GL_MODELVIEW

Comp 410/510 Computer Graphics Spring Programming with OpenGL Part 2: First Program

CSE528 Computer Graphics: Theory, Algorithms, and Applications

CS635 Spring Department of Computer Science Purdue University

Computer Graphics. Bing-Yu Chen National Taiwan University

Computer Graphics, Chapt 08

Introduction to Computer Graphics with WebGL

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

CSC 8470 Computer Graphics. What is Computer Graphics?

Lecture 2 2D transformations Introduction to OpenGL

(0, 1, 1) (0, 1, 1) (0, 1, 0) What is light? What is color? Terminology

Introduction to color science

INTRODUCTION. Slides modified from Angel book 6e

Basic Graphics Programming

Illumination and Shading

CS 432 Interactive Computer Graphics

Image Formation. Camera trial #1. Pinhole camera. What is an Image? Light and the EM spectrum The H.V.S. and Color Perception

Game Programming. Bing-Yu Chen National Taiwan University

3D graphics, raster and colors CS312 Fall 2010

SNC 2PI Optics Unit Review /95 Name:

CS Computer Graphics: Intro to OpenGL

CS Computer Graphics: Intro to OpenGL

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

Pick up Light Packet & Light WS

CGT521 Introduction to

Computer Graphics Lecture 2

CSE 167: Lecture #6: Color. Jürgen P. Schulze, Ph.D. University of California, San Diego Fall Quarter 2011

Introduction to Computer Graphics with OpenGL/GLUT

OpenGL Introduction Computer Graphics and Visualization

Survey in Computer Graphics Computer Graphics and Visualization

National Chiao Tung Univ, Taiwan By: I-Chen Lin, Assistant Professor

Computer Graphics. Chapter 3 Computer Graphics Software

CS4670: Computer Vision

CS452/552; EE465/505. Color Display Issues

Light Transport Baoquan Chen 2017

CSE4030 Introduction to Computer Graphics

Computer Graphics. Making Pictures. Computer Graphics CSC470 1

What is it? How does it work? How do we use it?

Computer Graphics and Visualization. Graphics Systems and Models

OpenGL/GLUT Intro. Week 1, Fri Jan 12

CS130 : Computer Graphics Lecture 2: Graphics Pipeline. Tamar Shinar Computer Science & Engineering UC Riverside

COMP 371/4 Computer Graphics Week 1

Announcements OpenGL. Computer Graphics. Autumn 2009 CS4815

Computer Graphics 1 Computer Graphics 1

Computer Graphics (CS 4731) OpenGL/GLUT(Part 1)

Rendering. Part 1 An introduction to OpenGL

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

Basic Graphics Programming

Computer Graphics Course 2005

1.2 Basic Graphics Programming

Image Formation. CS418 Computer Graphics Eric Shaffer.

Graphics Pipeline & APIs

Light. Properties of light. What is light? Today What is light? How do we measure it? How does light propagate? How does light interact with matter?

Lecture 11. Color. UW CSE vision faculty

GLUT. What is OpenGL? Introduction to OpenGL and GLUT

CSE 167: Lecture #6: Color. Jürgen P. Schulze, Ph.D. University of California, San Diego Fall Quarter 2012

Information Coding / Computer Graphics, ISY, LiTH. OpenGL! ! where it fits!! what it contains!! how you work with it 11(40)

OpenGL. Jimmy Johansson Norrköping Visualization and Interaction Studio Linköping University

Reading. 4. Color. Outline. The radiant energy spectrum. Suggested: w Watt (2 nd ed.), Chapter 14. Further reading:

OPEN GL BACKGROUND. Objectives. Early History of APIs. SGI and GL. PHIGS and X. Modified from Angel 6e book slides

Announcements OpenGL. Computer Graphics. Spring CS4815

CSE 167: Introduction to Computer Graphics Lecture #6: Colors. Jürgen P. Schulze, Ph.D. University of California, San Diego Fall Quarter 2013

RECITATION - 1. Ceng477 Fall

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

Transcription:

TOPICS in IT: ADVANCED GRAPHICS (CS & SE 233.420) Lecture 2 5 Aug 2004 1

Topics Image Formation Electromagnetic spectrum Light Human Visual Image processing Color Programming in OpenGL Background Programming Structure and naming conventions 2

Electromagnetic Spectrum The surface of Earth bathed in electromagnetic radiation from sun Electromagnetic energy is created by a vibration that produces wave that carry the energy Waves are ordered in the electromagnetic spectrum according to their wave length (λ) Longest (radio) Shortest (gamma) Frequency (f) refers to the number of waves a vibration creates during a period of time Wavelength and frequency are inversely related f = 1/ λ 3

Electromagnetic Spectrum Wavelength vs Frequency Increasing in Wavelength (λ) Increasing in Frequency (f) 4

(Human) Visible Light Spectrum 5

Light Detection Advantages Travels rapidly (300,000 km/sec) and in straight lines Surfaces reflect and absorb various wavelengths of light depending on physical and chemical properties Light therefore contains a great deal of information about environment Useful for many survival needs Allows detection of predators, prey at a distance without direct physical contact 6

Photosensitivity Ability to detect different intensities of diffuse illumination Present in many plants and most animals, Found in single celled animals, skin of many simple organisms, and in specialized visual organs, Light sensitivity underlies daily rhythm of activities 7

Vision Sensing changes in illumination that are rapid in time and localized in space Image forming eyes found in annelids (segmented worms) mollusks (snails, scallops, squid etc.) arthropods (spiders, crabs, insects etc.) and vertebrates 8

Visual Acuity and Sensitivity Acuity Expressed as angular resolving power Humans can resolve 1' (one minute) of arc, full moon 30' arc diameter, Some birds of prey, such as eagles can resolve 20" of arc Sensitivity how an eye responds to light In complete darkness, human eye can respond to single photon of light, stimulation of only 10-15 cells by single photons in a small patch of retina is sufficient to produce a conscious percept in a human observer 9

Human (Vertebrate) Vision Retina The photosensitive part of the eye Specialized layer of photoreceptor cells and neurons at back of eye Image formed on retina by refraction of light by cornea and lens Efferent control systems Ciliary muscles stretch lens to alter focus setting Iris controls amount of light admitted to eye (f-stop) 10

Rods and Cones The retina is largely composed of two types of cells, called rods and cones Rods Specialised for night vision can be activated by a single photon but they produce lower acuity vision, however. Cones Specialised for day vision, are concentrated at the fovea and provide high acuity vision Confer color vision to primates, birds, reptiles, and most fish 11

Human Color Wavelength Humans have 3 types of cone pigment that are maximally sensitive to either red, green or blue Color perception results from the simultaneous stimulation of the 3 cone types Colorblindness results from a deficiency of one cone type Sensitivities 12

Additive and Subtractive Color Additive color Form a color by adding amounts of three primaries Used by 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 Used in Printing and Negative film 13

Color Matching In order to define the perceptual 3D space in a "standard" way A set of experiments can (and have been) carried by having observers try and match color of a given wavelength, lambda, Done by mixing three other pure wavelengths, such as R=700nm, G=546nm, and B=436nm A problem exists, because sometimes the red light needs to be added to the target before a match can be achieved. This is shown on the graph by having its intensity, R, take on a negative value. 14

Commission Internationale Defined three new hypothetical light sources, x, y, and z, which yield positive matching curves Given a spectrum and wish to find the corresponding X, Y, and Z quantities Done by integrating the product of the spectral power and each of the three matching curves over all wavelengths. The weights X,Y,Z form the three-dimensional CIE XYZ space d'eclairage (CIE) 15

CIE Chromaticity Diagram Defines 3 color index in 2 dimensions done by projecting the 3D color space onto the plane X+Y+Z=1 16

Color Gamuts The chromaticity diagram can be used to compare the "gamuts" of various possible output devices Such as monitors and printers Note that a color printer cannot reproduce all the colors visible on a color monitor 17

RGB Color Cube The additive color model used for computer graphics is represented by the RGB color cube, R, G, and B represent the colors produced by red, green and blue phosphours, respectively. 18

CIE XYZ Color Space 19

CMYK color model Used by printers Green paper is green because it reflects green and absorbs other wavelengths To produce blue, one would mix cyan and magenta inks both reflect blue while each absorbing one of green and red Black ink is used to ensure that a high quality black can always be printed, and is often referred to as to K dye color absorbs reflects Cyan Red Blue and Green Magenta Green Blue and Red Yellow Blue Red and Green Black (K) All None 20

Other Color Models HSV Hue, Saturation, Value HLS Hue, Luminosity, Saturation Color conversion formula exist to convert colors between respective color models 21

Programming with OpenGL Background Programming Structure and naming conventions Primitives Attributes and States Programming in three dimensions Inputs and Interaction Working with Callbacks 22

SGI and GL Silicon Graphics (SGI) revolutionized the graphics workstation by implementing the pipeline in hardware (1982) To access the system, application programmers used a library called IRIS GL With GL, it was relatively simple to program three dimensional interactive applications 23

OpenGL The success of GL lead to OpenGL (1992) a platform-independent API that was Easy to use Close enough to the hardware to get excellent performance Available in a number of languages OS-independent and hardware-independent Focus on rendering Aimed at 2-D/3-D scenes made of polygons (and lines and points). Omitted windowing and input to avoid window system dependencies Not as good for 2-D windows/text/gui-style graphics 24

OpenGL Evolution Controlled by an Architectural Review Board (ARB) Members include SGI, Microsoft, NVidia, HP, 3DLabs, IBM, Apple, Dell, Intel, Matrox, Sun, HP,. Relatively stable Evolution reflects new hardware capabilities 3D texture mapping and texture objects Vertex programs Allows for platform specific features through extensions 25

OpenGL Design The interface with the graphics hardware. Designed for efficient implementation in hardware. Particular OpenGL implementations may be partially or totally software. We deal with OpenGL via function calls (or commands). No global variables. Most OpenGL functions have few parameters. C/C++ header: <GL/gl.h> But you make lots of function calls. No complex data types. OpenGL is function-call intensive. Think: advantages/disadvantages. 26

Software Organization Application Program OpenGL Motif widget or similar GLUT GLX, AGL, or WGL X, Windows, Apple O/S GLU GL Software and/or Hardware 27

OpenGL is Procedural OpenGL is a procedural rather than descriptive interface. In order to get a rendering of a red sphere the programmer must specify the appropriate sequence of commands Set up the camera view and modelling transformations Draw the geometry for a sphere with a red color. etc. Disadvantage of using a procedural interface The application must specify all of the operations in exacting detail and in the correct sequence to get the desired result. Advantage of this approach It allows great flexibility in the process of generating the image Application is free to trade-off rendering speed and image quality by changing the steps through which the image is drawn. 28

OpenGL is Not Pixel Exact This means that two different OpenGL implementations are very unlikely to render exactly the same image. This allows OpenGL to be implemented across a range of hardware platforms. If the specification were too exact, it would limit the kinds of hardware acceleration that could be used; limiting its usefulness as a standard. In practice, the lack of exactness need not be a burden -- unless you plan to build a rendering farm from a diverse set of machines. 29

OpenGL State OpenGL is a state machine OpenGL functions are of two types Primitive generating (drawing) Can cause output if primitive is visible How vertices are processed and appearance of primitive are controlled by the state Set and return state values Transformation functions Attribute functions So: all drawn objects are composed of primitives. The properties of these are attributes, which are determined by OpenGL states. 30

OpenGL Libraries OpenGL Core Library OpenGL32 on Windows GL on most unix/linux systems OpenGL Utility Library (GLU) Provides functionality in OpenGL core but avoids having to rewrite code Additional functions & types for various graphics operations. Designed to be implemented in software; calls GL. C/C++ header: <GL/glu.h>. Links with window system GLX or X window systems WGL or Windows AGL for Macintosh 31

GLUT Provides functionality common to all window systems Open a window Get input from mouse and keyboard Menus Event-driven Code is portable but GLUT lacks the functionality of a good toolkit for a specific platform 32

GLUT Functions glutinit allows application to get command line arguments and initializes system gluinitdisplaymode requests properties for the window (the rendering context) RGB color Single buffering Properties logically ORed together glutwindowsize in pixels glutwindowposition from top-left corner of display glutcreatewindow create window glutdisplayfunc display callback glutmainloop enter infinite event loop 33

OpenGL Extensions Functionality that anyone can add to OpenGL. OpenGL specifies rules that extensions are to follow. May be system-dependent. We will not use any extensions. 34

OpenGL Naming Conventions Functions Begin with gl, words capitalized & run together Example: glclearcolor Can include type information. For example, the 2d in glvertex2d indicates two parameters of type GLdouble. Constants Begin with GL, all upper-case, _ between words Example: GL_TRIANGLE_STRIP Types Begin with GL, next word not capitalized, all words run together Example: GLdouble 35

Related Package Naming Conventions Related packages use similar conventions. GLU Function: gluscaleimage Constant: GLU_TESS_ERROR Type: GLUtesselatorObj GLUT Function: glutinitdisplaymode Constant: GLUT_MIDDLE_BUTTON 36

OpenGL Types OpenGL defines its own types, which have the same (minimum) precision on all systems. Some of these: GLint: at least 32-bit integer GLfloat: at least 32-bit floating-point GLdouble: at least 64-bit floating-point and others So, for example, GLdouble is probably the same as double, but may not be. Converting (say) a GLdouble to a double is fine. But be careful when tossing around GLdouble * and double *. (Why?) 37

Lack of Object Orientation OpenGL is not object oriented so that there are multiple functions for a given logical function As a result, some OpenGL commands have several forms allowing for different types. For example, glvertex* can take 2, 3, or 4 parameters of many different types. Function glvertex2d takes 2 parameters of type GLdouble. Function glvertex3f takes 3 parameters of type GLfloat. Function glvertex3fv ( v for vector ) takes a single parameter of type GLfloat * (should be a pointer to an array of 3 GLfloat s). Underlying storage mode is the same 38

OpenGL Function Format belongs to GL library glvertex3f(x,y,z) 3 float inputs are required function glvertex3fv(p) p is a pointer to a 3 Dimensional array of floats 39

OpenGL #defines Most constants are defined in the include files gl.h, glu.h and glut.h #include <glut.h> should automatically include the others Examples glbegin(gl_polygon) glclear(gl_color_buffer_bit) include files also define OpenGL datatypes: GLfloat, GLdouble,. 40

glflush() It is important to note that OpenGL commands are not necessarily executed as soon as they are issued. It is necessary to call the command glflush() to ensure that all previously issued commands are executed. glflush() is generally called at the end of a sequence of drawing commands to ensure all objects in the scene are drawn. 41

Program Structure Most OpenGL programs have a similar structure that consists of the following functions main(): defines the callback functions opens one or more windows with the required properties enters event loop (last executable statement) init(): sets the state variables Viewing Attributes callbacks Display function Input and window functions 42

Event Loop Every glut program must have a display callback The display callback is executed whenever OpenGL decides the display must be refreshed, for example when the window is opened The main function ends with the program entering an event loop 43

References The Electro Magnetic Spectrum Tutorial, http://www.emk.gazi.edu.tr/ems.htm What is RF Radiation?, http://www.rfsafe.com/research/rf_radiation/what_is_rf/emf_spectrum.ht m The Physics Classroom, The Electromagnetic and Visible Spectra, http://www.glenbrook.k12.il.us/gbssci/phys/class/light/u12l2a.html Light Sources, http://graphics.lcs.mit.edu/~mcmillan/comp136/lecture23/lights.html The Visual System, http://www.geocities.com/medinotes/visual_system.htm The Visual System I & II, Dr. Paul Patton, http://soma.npa.uiuc.edu/courses/bio303. Computer Graphics Color Models, CSC 418: Colour Representation, Michiel van de Panne, University of Toronto, http://www.dgp.toronto.edu/people/van/courses/csc418/colour.html 44

References http://www.eecs.tulane.edu/ www/terry/opengl/changing_state.html www.inf.pucrs.br/~flash/tcg/aulas/oglfaq/viewing.htm - www.cs.uaf.edu/~cs381/slides/20030910ogl.ppt http://www.dgp.toronto.edu/~ah/csc418/fall_2001/tut/ogl_draw.html http://isg.cs.tcd.ie/dingliaj/3d4/lab2_p2.html http://www.opengl.org/about/overview.html http://www.winnetmag.com/article/articleid/3581/3581.html http://www.csee.umbc.edu/~ebert/691/au00/notes/c1_viewing.html www.inf.ufrgs.br/~comba/gh-files/talk1.pdf http://www.dgp.toronto.edu/~hertzman/courses/csc418/winter_2004/not es/lecture/pipeline.html Ed Angel Lecture notes (Lectures 4, 5, 6, 7, 8 and 9) Open GL web page www.opengl.org 45