University of British Columbia CPSC 314 Computer Graphics Jan-Apr 2010 Tamara Munzner Viewing/Projection V,

Slides:



Advertisements
Similar presentations
Today Composing transformations 3D Transformations
Advertisements

Graphics Pipeline.
University of British Columbia CPSC 314 Computer Graphics Jan-Apr 2005 Tamara Munzner Color Week 5, Fri Feb.
University of British Columbia CPSC 314 Computer Graphics Jan-Apr 2005 Tamara Munzner Picking Week 10, Mon Mar.
University of British Columbia CPSC 314 Computer Graphics Jan-Apr 2007 Tamara Munzner Viewing/Projections I.
University of British Columbia CPSC 314 Computer Graphics Jan-Apr 2008 Tamara Munzner Viewing/Projections IV.
Transformations II Week 2, Wed Jan 17
University of British Columbia CPSC 314 Computer Graphics Jan-Apr 2005 Tamara Munzner Projections II Week 4,
University of British Columbia CPSC 314 Computer Graphics Jan-Apr 2008 Tamara Munzner Viewing/Projections III.
University of British Columbia CPSC 314 Computer Graphics Jan-Apr 2007 Tamara Munzner Viewing/Projections III.
University of British Columbia CPSC 314 Computer Graphics Jan-Apr 2007 Tamara Munzner Vision/Color II, Virtual.
University of British Columbia CPSC 314 Computer Graphics Jan-Apr 2007 Tamara Munzner Vision/Color Week 5, Mon.
1 Angel: Interactive Computer Graphics 4E © Addison-Wesley 2005 Better Interactive Programs Ed Angel Professor of Computer Science, Electrical and Computer.
Projections and Picking Wed 24 Sep 2003
1 Project 2: Navigation five ways to navigate Absolute Rotate/Translate Keyboard Absolute Lookat Keyboard move wrt global coordinate system Relative Rolling.
IAT 3551 Computer Graphics Overview Color Displays Drawing Pipeline.
University of British Columbia CPSC 314 Computer Graphics Jan-Apr 2008 Tamara Munzner Viewing/Projections I.
University of British Columbia CPSC 414 Computer Graphics © Tamara Munzner 1 Viewing and Projections Mon 22 Sep 2003 project 1 solution demo recap: projections.
OpenGL (II). How to Draw a 3-D object on Screen?
University of British Columbia CPSC 414 Computer Graphics © Tamara Munzner 1 Picking and Lighting Week 4, Fri 26 Sep 2003 recap: viewports and picking.
3D Rendering with JOGL Introduction to Java OpenGL Graphic Library By Ricardo Veguilla
Picking. What is picking? Selecting an object on the screen What does this require? –Get Mouse Location –Compute what objects are rendered at the position.
CS 376 Introduction to Computer Graphics 01 / 26 / 2007 Instructor: Michael Eckmann.
19/4/ :32 Graphics II Syllabus Selection and Picking Session 1.
COMP 175: Computer Graphics March 24, 2015
Viewing and Projections
CSC461 Lecture 11: Interactive Programs Contents and Objectives Picking Writing modes – XOR/Copy Rubberbanding Display list.
OpenGL Matrices and Transformations Angel, Chapter 3 slides from AW, Red Book, etc. CSCI 6360.
Image Synthesis Rabie A. Ramadan, PhD 2. 2 Java OpenGL Using JOGL: Using JOGL: Wiki: You can download JOGL from.
MIT EECS 6.837, Durand and Cutler Graphics Pipeline: Projective Transformations.
Korea University Korea University Computer Graphics Laboratory Computer Graphics Laboratory Jung Lee, Chapter 13.
CSE 470: Computer Graphics. 10/15/ Defining a Vertex A 2D vertex: glVertex2f(GLfloat x, GLfloat y); 2D vertexfloating pointopenGL parameter type.
OpenGL Conclusions OpenGL Programming and Reference Guides, other sources CSCI 6360/4360.
Computing & Information Sciences Kansas State University Lecture 20 of 42CIS 636/736: (Introduction to) Computer Graphics Lecture 21 of 42 William H. Hsu.
Lecture 6: 3D graphics Concepts 1  Principles of Interactive Graphics  CMSCD2012  Dr David England, Room 718,  ex 2271 
1 Better Interactive Programs. 2 Objectives Learn to build more sophisticated interactive programs using ­Picking Select objects from the display Three.
OpenGL: Introduction Yanci Zhang Game Programming Practice.
OpenGL Selection. Three Selection Methods Color coding (OpenGL) Selection mode (OpenGL) Selection ray (generic)
University of British Columbia CPSC 314 Computer Graphics Jan-Apr 2007 Tamara Munzner Procedural Approaches.
CS 450: COMPUTER GRAPHICS PROJECTIONS SPRING 2015 DR. MICHAEL J. REALE.
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.
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)
University of British Columbia CPSC 314 Computer Graphics Jan-Apr 2010 Tamara Munzner Viewing/Projection VI,
Introduction to Computer Graphics
2 COEN Computer Graphics I Evening’s Goals n Discuss viewing and modeling transformations n Describe matrix stacks and their uses n Show basic geometric.
Review on Graphics Basics. Outline Polygon rendering pipeline Affine transformations Projective transformations Lighting and shading From vertices to.
Chapters 5 2 March Classical & Computer Viewing Same elements –objects –viewer –projectors –projection plane.
Viewing
University of British Columbia CPSC 314 Computer Graphics Jan-Apr 2007 Tamara Munzner Viewing/Projections IV.
David Luebke2/23/2016 CS 551 / 645: Introductory Computer Graphics Color Continued Clipping in 3D.
David Luebke3/11/2016 CS 551 / 645: Introductory Computer Graphics Geometric transforms: perspective projection Color.
CS5500 Computer Graphics March 20, Computer Viewing Ed Angel Professor of Computer Science, Electrical and Computer Engineering, and Media Arts.
Color University of British Columbia CPSC 314 Computer Graphics Jan-Apr 2016 Tamara Munzner.
OpenGL LAB III.
Viewing. Classical Viewing Viewing requires three basic elements - One or more objects - A viewer with a projection surface - Projectors that go from.
1 of 32 Computer Graphics Color. 2 of 32 Basics Of Color elements of color:
3D Ojbects: Transformations and Modeling. Matrix Operations Matrices have dimensions: Vectors can be thought of as matrices: v=[2,3,4,1] is a 1x4 matrix.
University of British Columbia CPSC 314 Computer Graphics Jan-Apr 2008 Tamara Munzner Viewing/Projections I.
Half Toning Dithering RGB CMYK Models
CS 551 / 645: Introductory Computer Graphics
- Introduction - Graphics Pipeline
University of British Columbia CPSC 314 Computer Graphics Jan-Apr 2016
Better Interactive Programs
CS451Real-time Rendering Pipeline
Computer Vision Lecture 4: Color
CSC4820/6820 Computer Graphics Algorithms Ying Zhu Georgia State University View & Projection.
Better Interactive Programs
Color Model By : Mustafa Salam.
Viewing/Projections I Week 3, Fri Jan 25
University of British Columbia CPSC 314 Computer Graphics Jan-Apr 2016
Presentation transcript:

University of British Columbia CPSC 314 Computer Graphics Jan-Apr 2010 Tamara Munzner Viewing/Projection V, Vision/Color Week 5, Mon Feb 1

2 Department of Computer Science Undergraduate Events Events this week Resume Editing Drop-In Session Date: Mon., Feb 1 Time: 11 am – 2 pm Location: Rm 255, ICICS/CS EADS Info Session Date: Mon., Feb 1 Time: 3:30 – 5:30 pm Location: CEME 1202 Job Interview Practice Session (for non-coop students) Date: Tues., Feb 2 Time: 11 am – 1 pm Location: Rm 206, ICICS/CS RIM Info Session Date: Thurs., Feb 4 Time: 5:30 – 7 pm Location: DMP 110 Events next week Finding a Summer Job or Internship Info Session Date: Wed., Feb 10 Time: 12 pm Location: X836 Masters of Digital Media Program Info Session Date: Thurs., Feb 11 Time: 12:30 – 1:30 pm Location: DMP 201

3 Project 1 Grading News don’t forget to show up 5 min before your slot see news item on top of course page for signup sheet scan if you have not signed up or need to change your time, contact shailen AT cs.ubc.ca you will lose marks if we have to hunt you down!

4 Review: Perspective Warp/Predistortion perspective viewing frustum predistorted to cube orthographic rendering of warped objects in cube produces same image as perspective rendering of original frustum x x

5 Review: Separate Warp and Homogenize warp requires only standard matrix multiply distort such that orthographic projection of distorted objects shows desired perspective projection w is changed clip after warp, before divide division by w: homogenization CCS NDCS alter w / w VCS projectiontransformation viewing normalized device clipping perspectivedivision V2CC2N

6 x z NDCS y (-1,-1,-1) (1,1,1) x=left x=right y=top y=bottom z=-near z=-far x VCS y z Review: Perspective to NDCS Derivation shear scale projection-normalization

7 Review: N2D Transformation x y viewport NDC height width x y NDCSDCS

8 Review: Projective Rendering Pipeline OCS - object coordinate system WCS - world coordinate system VCS - viewing coordinate system CCS - clipping coordinate system NDCS - normalized device coordinate system DCS - device coordinate system OCS WCS VCS CCS NDCS DCSmodelingtransformationviewingtransformationprojectiontransformationviewporttransformation alter w / w objectworld viewing device normalized device clipping perspectivedivision glVertex3f(x,y,z) glTranslatef(x,y,z)glRotatef(a,x,y,z)....gluLookAt(...) glFrustum(...) glutInitWindowSize(w,h)glViewport(x,y,a,b) O2WW2VV2C N2D C2N

9 Perspective Example view volume left = -1, right = 1 bot = -1, top = 1 near = 1, far = 4

10 Perspective Example tracks in VCS: left x=-1, y=-1 right x=1, y=-1 view volume left = -1, right = 1 bot = -1, top = 1 near = 1, far = 4 z=-1 z=-4 x z VCS top view 1 1 NDCS (z not shown) real midpoint 0 xmax-1 0 DCS (z not shown) ymax-1 x=-1 x=1

11 Perspective Example / w

12 OpenGL Example glMatrixMode( GL_PROJECTION ); glLoadIdentity(); gluPerspective( 45, 1.0, 0.1, ); glMatrixMode( GL_MODELVIEW ); glLoadIdentity(); glTranslatef( 0.0, 0.0, -5.0 ); glPushMatrix() glTranslate( 4, 4, 0 ); glutSolidTeapot(1); glPopMatrix(); glTranslate( 2, 2, 0); glutSolidTeapot(1); OCS2 O2W VCSmodelingtransformationviewingtransformation projectiontransformation objectworld viewing W2VV2C WCS transformations that are applied to object first are specified last OCS1 WCS VCS W2O W2O CCS clipping CCS OCS

13 Viewing: More Camera Motion

14 Fly "Through The Lens": Roll/Pitch/Yaw

15 Viewing: Incremental Relative Motion how to move relative to current camera coordinate system? what you see in the window computation in coordinate system used to draw previous frame is simple: incremental change I to current C at time k, want p' = I k I k-1 I k-2 I k-3... I 5 I 4 I 3 I 2 I 1 Cp each time we just want to premultiply by new matrix p’=ICp but we know that OpenGL only supports postmultiply by new matrix p’=CIp

16 Viewing: Incremental Relative Motion sneaky trick: OpenGL modelview matrix has the info we want! dump out modelview matrix with glGetDoublev() C = current camera coordinate matrix wipe the matrix stack with glIdentity() apply incremental update matrix I apply current camera coord matrix C must leave the modelview matrix unchanged by object transformations after your display call use push/pop using OpenGL for storage and calculation querying pipeline is expensive but safe to do just once per frame

17 Caution: OpenGL Matrix Storage OpenGL internal matrix storage is columnwise, not rowwise a e i m b f j n c g k o d h l p opposite of standard C/C++/Java convention possibly confusing if you look at the matrix from glGetDoublev()!

18 Viewing: Virtual Trackball interface for spinning objects around drag mouse to control rotation of view volume orbit/spin metaphor vs. flying/driving rolling glass trackball center at screen origin, surrounds world hemisphere “sticks up” in z, out of screen rotate ball = spin world

19 Virtual Trackball know screen click: (x, 0, z) want to infer point on trackball: (x,y,z) ball is unit sphere, so ||x, y, z|| = 1.0 solve for y eye image plane

20 Trackball Rotation correspondence: moving point on plane from (x, 0, z) to (a, 0, c) moving point on ball from p 1 =(x, y, z) to p 2 =(a, b, c) correspondence: translating mouse from p 1 (mouse down) to p 2 (mouse up) rotating about the axis n = p 1 x p 2

21 Trackball Computation user defines two points place where first clicked p 1 = (x, y, z) place where released p 2 = (a, b, c) create plane from vectors between points, origin axis of rotation is plane normal: cross product ( p 1 - o ) x ( p 2 - o ): p 1 x p 2 if origin = (0,0,0) amount of rotation depends on angle between lines p 1 p 2 = |p 1 | |p 2 | cos  |p 1 x p 2 | = |p 1 | |p 2 | sin  compute rotation matrix, use to rotate world

22 Picking

23 Reading Red Book Selection and Feedback Chapter all Now That You Know Chapter only Object Selection Using the Back Buffer

24 Interactive Object Selection move cursor over object, click how to decide what is below? inverse of rendering pipeline flow from pixel back up to object ambiguity many 3D world objects map to same 2D point four common approaches manual ray intersection bounding extents backbuffer color coding selection region with hit list

25 Manual Ray Intersection do all computation at application level map selection point to a ray intersect ray with all objects in scene. advantages no library dependence disadvantages difficult to program slow: work to do depends on total number and complexity of objects in scene x VCS y

26 Bounding Extents keep track of axis-aligned bounding rectangles advantages conceptually simple easy to keep track of boxes in world space

27 Bounding Extents disadvantages low precision must keep track of object-rectangle relationship extensions do more sophisticated bound bookkeeping first level: box check. second level: object check

28 Backbuffer Color Coding use backbuffer for picking create image as computational entity never displayed to user redraw all objects in backbuffer turn off shading calculations set unique color for each pickable object store in table read back pixel at cursor location check against table

29 advantages conceptually simple variable precision disadvantages introduce 2x redraw delay backbuffer readback very slow Backbuffer Color Coding

30 for(int i = 0; i < 2; i++) for(int j = 0; j < 2; j++) { glPushMatrix(); switch (i*2+j) { case 0: glColor3ub(255,0,0);break; case 1: glColor3ub(0,255,0);break; case 2: glColor3ub(0,0,255);break; case 3: glColor3ub(250,0,250);break; } glTranslatef(i*3.0,0,-j * 3.0) glCallList(snowman_display_list); glPopMatrix(); } glColor3f(1.0, 1.0, 1.0); for(int i = 0; i < 2; i++) for(int j = 0; j < 2; j++) { glPushMatrix(); glTranslatef(i*3.0,0,-j * 3.0); glColor3f(1.0, 1.0, 1.0); glCallList(snowman_display_list); glPopMatrix(); } Backbuffer Example

31 Select/Hit use small region around cursor for viewport assign per-object integer keys (names) redraw in special mode store hit list of objects in region examine hit list OpenGL support

32 Viewport small rectangle around cursor change coord sys so fills viewport why rectangle instead of point? people aren’t great at positioning mouse Fitts’ Law: time to acquire a target is function of the distance to and size of the target allow several pixels of slop

33 nontrivial to compute invert viewport matrix, set up new orthogonal projection simple utility command gluPickMatrix(x,y,w,h,viewport) x,y: cursor point w,h: sensitivity/slop (in pixels) push old setup first, so can pop it later Viewport

34 Render Modes glRenderMode(mode) GL_RENDER: normal color buffer default GL_SELECT: selection mode for picking (GL_FEEDBACK: report objects drawn)

35 Name Stack again, "names" are just integers glInitNames() flat list glLoadName(name) or hierarchy supported by stack glPushName(name), glPopName can have multiple names per object

36 for(int i = 0; i < 2; i++) { glPushName(i); for(int j = 0; j < 2; j++) { glPushMatrix(); glPushName(j); glTranslatef(i*10.0,0,j * 10.0); glPushName(HEAD); glCallList(snowManHeadDL); glLoadName(BODY); glCallList(snowManBodyDL); glPopName(); glPopName(); glPopMatrix(); } glPopName(); } Hierarchical Names Example

37 Hit List glSelectBuffer(buffersize, *buffer) where to store hit list data on hit, copy entire contents of name stack to output buffer. hit record number of names on stack minimum and minimum depth of object vertices depth lies in the NDC z range [0,1] format: multiplied by 2^32 -1 then rounded to nearest int

38 Integrated vs. Separate Pick Function integrate: use same function to draw and pick simpler to code name stack commands ignored in render mode separate: customize functions for each potentially more efficient can avoid drawing unpickable objects

39 Select/Hit advantages faster OpenGL support means hardware acceleration avoid shading overhead flexible precision size of region controllable flexible architecture custom code possible, e.g. guaranteed frame rate disadvantages more complex

40 Hybrid Picking select/hit approach: fast, coarse object-level granularity manual ray intersection: slow, precise exact intersection point hybrid: both speed and precision use select/hit to find object then intersect ray with that object

41 OpenGL Precision Picking Hints gluUnproject transform window coordinates to object coordinates given current projection and modelview matrices use to create ray into scene from cursor location call gluUnProject twice with same (x,y) mouse location z = near: (x,y,0) z = far: (x,y,1) subtract near result from far result to get direction vector for ray use this ray for line/polygon intersection

42 Vision/Color

43 Reading for Color RB Chap Color FCG Sections FCG Chap 20 Color FCG Chap Visual Perception (Color)

44 RGB Color triple (r, g, b) represents colors with amount of red, green, and blue hardware-centric used by OpenGL

45 Alpha fourth component for transparency (r,g,b,  ) fraction we can see through c =  c f + (1-  )c b more on compositing later

46 Additive vs. Subtractive Colors additive: light monitors, LCDs RGB model subtractive: pigment printers CMY model dyes absorb light additive subtractive

47 Component Color component-wise multiplication of colors (a0,a1,a2) * (b0,b1,b2) = (a0*b0, a1*b1, a2*b2) why does this work? must dive into light, human vision, color spaces

48 Basics Of Color elements of color:

49 Basics of Color physics illumination electromagnetic spectra reflection material properties surface geometry and microgeometry polished versus matte versus brushed perception physiology and neurophysiology perceptual psychology

50 Light Sources common light sources differ in kind of spectrum they emit: continuous spectrum energy is emitted at all wavelengths blackbody radiation tungsten light bulbs certain fluorescent lights sunlight electrical arcs line spectrum energy is emitted at certain discrete frequencies

51 Blackbody Radiation black body dark material, so that reflection can be neglected spectrum of emitted light changes with temperature this is the origin of the term “color temperature” e.g. when setting a white point for your monitor cold: mostly infrared hot: reddish very hot: bluish demo:

52 Electromagnetic Spectrum

53 Electromagnetic Spectrum

54 White Light sun or light bulbs emit all frequencies within visible range to produce what we perceive as "white light"

55 Sunlight Spectrum spectral distribution: power vs. wavelength

56 Continuous Spectrum sunlight various “daylight” lamps

57 Line Spectrum ionized gases lasers some fluorescent lamps

58 White Light and Color when white light is incident upon an object, some frequencies are reflected and some are absorbed by the object combination of frequencies present in the reflected light that determines what we perceive as the color of the object

59 Hue hue (or simply, "color") is dominant wavelength/frequency integration of energy for all visible wavelengths is proportional to intensity of color

60 Saturation or Purity of Light how washed out or how pure the color of the light appears contribution of dominant light vs. other frequencies producing white light saturation: how far is color from grey pink is less saturated than red sky blue is less saturated than royal blue

61 Intensity vs. Brightness intensity : physical term measured radiant energy emitted per unit of time, per unit solid angle, and per unit projected area of the source (related to the luminance of the source) lightness/brightness: perceived intensity of light nonlinear

62 Perceptual vs. Colorimetric Terms Perceptual Hue Saturation Lightness reflecting objects Brightness light sources Colorimetric Dominant wavelength Excitation purity Luminance