viewing/projection v, vision/color week 5, mon feb 1tmm/courses/314/vjan2010/... ·...
TRANSCRIPT
![Page 1: Viewing/Projection V, Vision/Color Week 5, Mon Feb 1tmm/courses/314/Vjan2010/... · Viewing/Projection V, Vision/Color Week 5, Mon Feb 1. 2 Department of Computer Science ... •projection-normalization](https://reader034.vdocuments.site/reader034/viewer/2022042201/5ea0dd7fc0d74f13c56eee3e/html5/thumbnails/1.jpg)
University of British ColumbiaCPSC 314 Computer Graphics
Jan-Apr 2010
Tamara Munzner
http://www.ugrad.cs.ubc.ca/~cs314/Vjan2010
Viewing/Projection V, Vision/Color
Week 5, Mon Feb 1
![Page 2: Viewing/Projection V, Vision/Color Week 5, Mon Feb 1tmm/courses/314/Vjan2010/... · Viewing/Projection V, Vision/Color Week 5, Mon Feb 1. 2 Department of Computer Science ... •projection-normalization](https://reader034.vdocuments.site/reader034/viewer/2022042201/5ea0dd7fc0d74f13c56eee3e/html5/thumbnails/2.jpg)
2
Department of Computer ScienceUndergraduate Events
Events this weekResume Editing Drop-In SessionDate: Mon., Feb 1Time: 11 am – 2 pmLocation: Rm 255, ICICS/CSEADS Info SessionDate: Mon., Feb 1Time: 3:30 – 5:30 pmLocation: CEME 1202Job Interview Practice Session
(for non-coop students)Date: Tues., Feb 2Time: 11 am – 1 pmLocation: Rm 206, ICICS/CS
RIM Info SessionDate: Thurs., Feb 4Time: 5:30 – 7 pmLocation: DMP 110Events next weekFinding a Summer Job or
Internship Info SessionDate: Wed., Feb 10Time: 12 pmLocation: X836Masters of Digital Media
Program Info SessionDate: Thurs., Feb 11Time: 12:30 – 1:30 pmLocation: DMP 201
![Page 3: Viewing/Projection V, Vision/Color Week 5, Mon Feb 1tmm/courses/314/Vjan2010/... · Viewing/Projection V, Vision/Color Week 5, Mon Feb 1. 2 Department of Computer Science ... •projection-normalization](https://reader034.vdocuments.site/reader034/viewer/2022042201/5ea0dd7fc0d74f13c56eee3e/html5/thumbnails/3.jpg)
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 signupsheet scan
• if you have not signed up or need to change yourtime, contact shailen AT cs.ubc.ca• you will lose marks if we have to hunt you down!
![Page 4: Viewing/Projection V, Vision/Color Week 5, Mon Feb 1tmm/courses/314/Vjan2010/... · Viewing/Projection V, Vision/Color Week 5, Mon Feb 1. 2 Department of Computer Science ... •projection-normalization](https://reader034.vdocuments.site/reader034/viewer/2022042201/5ea0dd7fc0d74f13c56eee3e/html5/thumbnails/4.jpg)
4
Review: Perspective Warp/Predistortion• perspective viewing frustum predistorted to cube• orthographic rendering of warped objects in cube
produces same image as perspective renderingof original frustum x
x
![Page 5: Viewing/Projection V, Vision/Color Week 5, Mon Feb 1tmm/courses/314/Vjan2010/... · Viewing/Projection V, Vision/Color Week 5, Mon Feb 1. 2 Department of Computer Science ... •projection-normalization](https://reader034.vdocuments.site/reader034/viewer/2022042201/5ea0dd7fc0d74f13c56eee3e/html5/thumbnails/5.jpg)
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
CCSCCSNDCSNDCS
alter walter w / w/ w
VCSVCSprojectionprojection
transformationtransformation
viewing normalizeddevice
clipping
perspectiveperspectivedivisiondivision
V2CV2C C2NC2N
![Page 6: Viewing/Projection V, Vision/Color Week 5, Mon Feb 1tmm/courses/314/Vjan2010/... · Viewing/Projection V, Vision/Color Week 5, Mon Feb 1. 2 Department of Computer Science ... •projection-normalization](https://reader034.vdocuments.site/reader034/viewer/2022042201/5ea0dd7fc0d74f13c56eee3e/html5/thumbnails/6.jpg)
6
x
z
NDCS
y
(-1,-1,-1)
(1,1,1)x=left
x=right
y=top
y=bottom z=-near z=-farx
VCS
y
z
Review: Perspective to NDCS Derivation
• shear• scale• projection-normalization
![Page 7: Viewing/Projection V, Vision/Color Week 5, Mon Feb 1tmm/courses/314/Vjan2010/... · Viewing/Projection V, Vision/Color Week 5, Mon Feb 1. 2 Department of Computer Science ... •projection-normalization](https://reader034.vdocuments.site/reader034/viewer/2022042201/5ea0dd7fc0d74f13c56eee3e/html5/thumbnails/7.jpg)
7
Review: N2D Transformation
xxyy
viewportviewportNDCNDC
0 500
300
0
-11
1
-1height
width
xx
yy
NDCS DCS
![Page 8: Viewing/Projection V, Vision/Color Week 5, Mon Feb 1tmm/courses/314/Vjan2010/... · Viewing/Projection V, Vision/Color Week 5, Mon Feb 1. 2 Department of Computer Science ... •projection-normalization](https://reader034.vdocuments.site/reader034/viewer/2022042201/5ea0dd7fc0d74f13c56eee3e/html5/thumbnails/8.jpg)
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
OCSOCS WCSWCS VCSVCS
CCSCCS
NDCSNDCS
DCSDCS
modelingmodelingtransformationtransformation
viewingviewingtransformationtransformation
projectionprojectiontransformationtransformation
viewportviewporttransformationtransformation
alter walter w
/ w/ w
object world viewing
device
normalizeddevice
clipping
perspectiveperspectivedivisiondivision
glVertex3f(x,y,z)glVertex3f(x,y,z)
glTranslatefglTranslatef(x,y,z)(x,y,z)glRotatef(a,x,y,zglRotatef(a,x,y,z))........
gluLookAtgluLookAt(...)(...)
glFrustumglFrustum(...)(...)
glutInitWindowSizeglutInitWindowSize(w,h)(w,h)glViewportglViewport(x,y,a,b)(x,y,a,b)
O2WO2W W2VW2V V2CV2C
N2DN2D
C2NC2N
![Page 9: Viewing/Projection V, Vision/Color Week 5, Mon Feb 1tmm/courses/314/Vjan2010/... · Viewing/Projection V, Vision/Color Week 5, Mon Feb 1. 2 Department of Computer Science ... •projection-normalization](https://reader034.vdocuments.site/reader034/viewer/2022042201/5ea0dd7fc0d74f13c56eee3e/html5/thumbnails/9.jpg)
9
Perspective Example
view volume• left = -1, right = 1• bot = -1, top = 1• near = 1, far = 4
!
2n
r " l0
r + l
r " l0
02n
t " b
t + b
t " b0
0 0"( f + n)
f " n
"2 fn
f " n0 0 "1 0
#
$
% % % % % % %
&
'
( ( ( ( ( ( (
!
1 0 0 0
0 1 0 0
0 0 "5 /3 "8 /3
0 0 "1 0
#
$
% % % %
&
'
( ( ( (
![Page 10: Viewing/Projection V, Vision/Color Week 5, Mon Feb 1tmm/courses/314/Vjan2010/... · Viewing/Projection V, Vision/Color Week 5, Mon Feb 1. 2 Department of Computer Science ... •projection-normalization](https://reader034.vdocuments.site/reader034/viewer/2022042201/5ea0dd7fc0d74f13c56eee3e/html5/thumbnails/10.jpg)
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
zVCS
top view
-1-1 1
1
-1NDCS
(z not shown)
realmidpoint
0 xmax-10DCS
(z not shown)
ymax-1
x=-1 x=1
![Page 11: Viewing/Projection V, Vision/Color Week 5, Mon Feb 1tmm/courses/314/Vjan2010/... · Viewing/Projection V, Vision/Color Week 5, Mon Feb 1. 2 Department of Computer Science ... •projection-normalization](https://reader034.vdocuments.site/reader034/viewer/2022042201/5ea0dd7fc0d74f13c56eee3e/html5/thumbnails/11.jpg)
11
Perspective Example
/ w/ w
!
xNDCS = "1/zVCS
yNDCS =1/zVCS
zNDCS =5
3+
8
3zVCS
!
1
"1
"5zVCS/3" 8 /3
"zVCS
#
$
% % % %
&
'
( ( ( (
=
1
1
"5 /3 "8 /3
"1
#
$
% % % %
&
'
( ( ( (
1
"1
zVCS
1
#
$
% % % %
&
'
( ( ( (
![Page 12: Viewing/Projection V, Vision/Color Week 5, Mon Feb 1tmm/courses/314/Vjan2010/... · Viewing/Projection V, Vision/Color Week 5, Mon Feb 1. 2 Department of Computer Science ... •projection-normalization](https://reader034.vdocuments.site/reader034/viewer/2022042201/5ea0dd7fc0d74f13c56eee3e/html5/thumbnails/12.jpg)
12
OpenGL Example
glMatrixMode( GL_PROJECTION ); glLoadIdentity(); gluPerspective( 45, 1.0, 0.1, 200.0 ); 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);OCS2OCS2
O2WO2W VCSVCSmodelingmodeling
transformationtransformationviewingviewing
transformationtransformationprojectionprojection
transformationtransformation
object world viewingW2VW2V V2CV2CWCSWCS
• transformations thatare applied to objectfirst are specifiedlastOCS1OCS1
WCSWCS
VCSVCS
W2OW2O
W2OW2O
CCSCCSclipping
CCSCCS
OCSOCS
![Page 13: Viewing/Projection V, Vision/Color Week 5, Mon Feb 1tmm/courses/314/Vjan2010/... · Viewing/Projection V, Vision/Color Week 5, Mon Feb 1. 2 Department of Computer Science ... •projection-normalization](https://reader034.vdocuments.site/reader034/viewer/2022042201/5ea0dd7fc0d74f13c56eee3e/html5/thumbnails/13.jpg)
13
Viewing: More Camera Motion
![Page 14: Viewing/Projection V, Vision/Color Week 5, Mon Feb 1tmm/courses/314/Vjan2010/... · Viewing/Projection V, Vision/Color Week 5, Mon Feb 1. 2 Department of Computer Science ... •projection-normalization](https://reader034.vdocuments.site/reader034/viewer/2022042201/5ea0dd7fc0d74f13c56eee3e/html5/thumbnails/14.jpg)
14
Fly "Through The Lens": Roll/Pitch/Yaw
![Page 15: Viewing/Projection V, Vision/Color Week 5, Mon Feb 1tmm/courses/314/Vjan2010/... · Viewing/Projection V, Vision/Color Week 5, Mon Feb 1. 2 Department of Computer Science ... •projection-normalization](https://reader034.vdocuments.site/reader034/viewer/2022042201/5ea0dd7fc0d74f13c56eee3e/html5/thumbnails/15.jpg)
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' = IkIk-1Ik-2Ik-3 ... I5I4I3I2I1Cp
• each time we just want to premultiply by new matrix• p’=ICp
• but we know that OpenGL only supports postmultiply by newmatrix
• p’=CIp
![Page 16: Viewing/Projection V, Vision/Color Week 5, Mon Feb 1tmm/courses/314/Vjan2010/... · Viewing/Projection V, Vision/Color Week 5, Mon Feb 1. 2 Department of Computer Science ... •projection-normalization](https://reader034.vdocuments.site/reader034/viewer/2022042201/5ea0dd7fc0d74f13c56eee3e/html5/thumbnails/16.jpg)
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 objecttransformations 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
![Page 17: Viewing/Projection V, Vision/Color Week 5, Mon Feb 1tmm/courses/314/Vjan2010/... · Viewing/Projection V, Vision/Color Week 5, Mon Feb 1. 2 Department of Computer Science ... •projection-normalization](https://reader034.vdocuments.site/reader034/viewer/2022042201/5ea0dd7fc0d74f13c56eee3e/html5/thumbnails/17.jpg)
17
Caution: OpenGL Matrix Storage
• OpenGL internal matrix storage iscolumnwise, not rowwisea e i mb f j nc g k od h l p
• opposite of standard C/C++/Java convention• possibly confusing if you look at the matrix
from glGetDoublev()!
![Page 18: Viewing/Projection V, Vision/Color Week 5, Mon Feb 1tmm/courses/314/Vjan2010/... · Viewing/Projection V, Vision/Color Week 5, Mon Feb 1. 2 Department of Computer Science ... •projection-normalization](https://reader034.vdocuments.site/reader034/viewer/2022042201/5ea0dd7fc0d74f13c56eee3e/html5/thumbnails/18.jpg)
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
![Page 19: Viewing/Projection V, Vision/Color Week 5, Mon Feb 1tmm/courses/314/Vjan2010/... · Viewing/Projection V, Vision/Color Week 5, Mon Feb 1. 2 Department of Computer Science ... •projection-normalization](https://reader034.vdocuments.site/reader034/viewer/2022042201/5ea0dd7fc0d74f13c56eee3e/html5/thumbnails/19.jpg)
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
![Page 20: Viewing/Projection V, Vision/Color Week 5, Mon Feb 1tmm/courses/314/Vjan2010/... · Viewing/Projection V, Vision/Color Week 5, Mon Feb 1. 2 Department of Computer Science ... •projection-normalization](https://reader034.vdocuments.site/reader034/viewer/2022042201/5ea0dd7fc0d74f13c56eee3e/html5/thumbnails/20.jpg)
20
Trackball Rotation• correspondence:
• moving point on plane from (x, 0, z) to (a, 0, c)• moving point on ball from p1 =(x, y, z) to p2 =(a, b, c)
• correspondence:• translating mouse from p1 (mouse down) to p2 (mouse up)• rotating about the axis n = p1 x p2
![Page 21: Viewing/Projection V, Vision/Color Week 5, Mon Feb 1tmm/courses/314/Vjan2010/... · Viewing/Projection V, Vision/Color Week 5, Mon Feb 1. 2 Department of Computer Science ... •projection-normalization](https://reader034.vdocuments.site/reader034/viewer/2022042201/5ea0dd7fc0d74f13c56eee3e/html5/thumbnails/21.jpg)
21
Trackball Computation• user defines two points
• place where first clicked p1 = (x, y, z)• place where released p2 = (a, b, c)
• create plane from vectors between points, origin• axis of rotation is plane normal: cross product
• (p1 - o) x (p2 - o): p1 x p2 if origin = (0,0,0)• amount of rotation depends on angle between
lines• p1 • p2 = |p1| |p2| cos θ• |p1 x p2 | = |p1| |p2| sin θ
• compute rotation matrix, use to rotate world
![Page 22: Viewing/Projection V, Vision/Color Week 5, Mon Feb 1tmm/courses/314/Vjan2010/... · Viewing/Projection V, Vision/Color Week 5, Mon Feb 1. 2 Department of Computer Science ... •projection-normalization](https://reader034.vdocuments.site/reader034/viewer/2022042201/5ea0dd7fc0d74f13c56eee3e/html5/thumbnails/22.jpg)
22
Picking
![Page 23: Viewing/Projection V, Vision/Color Week 5, Mon Feb 1tmm/courses/314/Vjan2010/... · Viewing/Projection V, Vision/Color Week 5, Mon Feb 1. 2 Department of Computer Science ... •projection-normalization](https://reader034.vdocuments.site/reader034/viewer/2022042201/5ea0dd7fc0d74f13c56eee3e/html5/thumbnails/23.jpg)
23
Reading
• Red Book• Selection and Feedback Chapter
• all• Now That You Know Chapter
• only Object Selection Using the Back Buffer
![Page 24: Viewing/Projection V, Vision/Color Week 5, Mon Feb 1tmm/courses/314/Vjan2010/... · Viewing/Projection V, Vision/Color Week 5, Mon Feb 1. 2 Department of Computer Science ... •projection-normalization](https://reader034.vdocuments.site/reader034/viewer/2022042201/5ea0dd7fc0d74f13c56eee3e/html5/thumbnails/24.jpg)
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
![Page 25: Viewing/Projection V, Vision/Color Week 5, Mon Feb 1tmm/courses/314/Vjan2010/... · Viewing/Projection V, Vision/Color Week 5, Mon Feb 1. 2 Department of Computer Science ... •projection-normalization](https://reader034.vdocuments.site/reader034/viewer/2022042201/5ea0dd7fc0d74f13c56eee3e/html5/thumbnails/25.jpg)
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
xVCS
y
![Page 26: Viewing/Projection V, Vision/Color Week 5, Mon Feb 1tmm/courses/314/Vjan2010/... · Viewing/Projection V, Vision/Color Week 5, Mon Feb 1. 2 Department of Computer Science ... •projection-normalization](https://reader034.vdocuments.site/reader034/viewer/2022042201/5ea0dd7fc0d74f13c56eee3e/html5/thumbnails/26.jpg)
26
Bounding Extents• keep track of axis-aligned bounding
rectangles
• advantages• conceptually simple• easy to keep track of boxes in world space
![Page 27: Viewing/Projection V, Vision/Color Week 5, Mon Feb 1tmm/courses/314/Vjan2010/... · Viewing/Projection V, Vision/Color Week 5, Mon Feb 1. 2 Department of Computer Science ... •projection-normalization](https://reader034.vdocuments.site/reader034/viewer/2022042201/5ea0dd7fc0d74f13c56eee3e/html5/thumbnails/27.jpg)
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
![Page 28: Viewing/Projection V, Vision/Color Week 5, Mon Feb 1tmm/courses/314/Vjan2010/... · Viewing/Projection V, Vision/Color Week 5, Mon Feb 1. 2 Department of Computer Science ... •projection-normalization](https://reader034.vdocuments.site/reader034/viewer/2022042201/5ea0dd7fc0d74f13c56eee3e/html5/thumbnails/28.jpg)
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
![Page 29: Viewing/Projection V, Vision/Color Week 5, Mon Feb 1tmm/courses/314/Vjan2010/... · Viewing/Projection V, Vision/Color Week 5, Mon Feb 1. 2 Department of Computer Science ... •projection-normalization](https://reader034.vdocuments.site/reader034/viewer/2022042201/5ea0dd7fc0d74f13c56eee3e/html5/thumbnails/29.jpg)
29
• advantages• conceptually simple• variable precision
• disadvantages• introduce 2x redraw delay• backbuffer readback very slow
Backbuffer Color Coding
![Page 30: Viewing/Projection V, Vision/Color Week 5, Mon Feb 1tmm/courses/314/Vjan2010/... · Viewing/Projection V, Vision/Color Week 5, Mon Feb 1. 2 Department of Computer Science ... •projection-normalization](https://reader034.vdocuments.site/reader034/viewer/2022042201/5ea0dd7fc0d74f13c56eee3e/html5/thumbnails/30.jpg)
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
http://www.lighthouse3d.com/opengl/picking/
![Page 31: Viewing/Projection V, Vision/Color Week 5, Mon Feb 1tmm/courses/314/Vjan2010/... · Viewing/Projection V, Vision/Color Week 5, Mon Feb 1. 2 Department of Computer Science ... •projection-normalization](https://reader034.vdocuments.site/reader034/viewer/2022042201/5ea0dd7fc0d74f13c56eee3e/html5/thumbnails/31.jpg)
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
![Page 32: Viewing/Projection V, Vision/Color Week 5, Mon Feb 1tmm/courses/314/Vjan2010/... · Viewing/Projection V, Vision/Color Week 5, Mon Feb 1. 2 Department of Computer Science ... •projection-normalization](https://reader034.vdocuments.site/reader034/viewer/2022042201/5ea0dd7fc0d74f13c56eee3e/html5/thumbnails/32.jpg)
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 isfunction of the distance to and size of thetarget
• allow several pixels of slop
![Page 33: Viewing/Projection V, Vision/Color Week 5, Mon Feb 1tmm/courses/314/Vjan2010/... · Viewing/Projection V, Vision/Color Week 5, Mon Feb 1. 2 Department of Computer Science ... •projection-normalization](https://reader034.vdocuments.site/reader034/viewer/2022042201/5ea0dd7fc0d74f13c56eee3e/html5/thumbnails/33.jpg)
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
![Page 34: Viewing/Projection V, Vision/Color Week 5, Mon Feb 1tmm/courses/314/Vjan2010/... · Viewing/Projection V, Vision/Color Week 5, Mon Feb 1. 2 Department of Computer Science ... •projection-normalization](https://reader034.vdocuments.site/reader034/viewer/2022042201/5ea0dd7fc0d74f13c56eee3e/html5/thumbnails/34.jpg)
34
Render Modes
• glRenderMode(mode)
• GL_RENDER: normal color buffer• default
• GL_SELECT: selection mode for picking
• (GL_FEEDBACK: report objects drawn)
![Page 35: Viewing/Projection V, Vision/Color Week 5, Mon Feb 1tmm/courses/314/Vjan2010/... · Viewing/Projection V, Vision/Color Week 5, Mon Feb 1. 2 Department of Computer Science ... •projection-normalization](https://reader034.vdocuments.site/reader034/viewer/2022042201/5ea0dd7fc0d74f13c56eee3e/html5/thumbnails/35.jpg)
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
![Page 36: Viewing/Projection V, Vision/Color Week 5, Mon Feb 1tmm/courses/314/Vjan2010/... · Viewing/Projection V, Vision/Color Week 5, Mon Feb 1. 2 Department of Computer Science ... •projection-normalization](https://reader034.vdocuments.site/reader034/viewer/2022042201/5ea0dd7fc0d74f13c56eee3e/html5/thumbnails/36.jpg)
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
http://www.lighthouse3d.com/opengl/picking/
![Page 37: Viewing/Projection V, Vision/Color Week 5, Mon Feb 1tmm/courses/314/Vjan2010/... · Viewing/Projection V, Vision/Color Week 5, Mon Feb 1. 2 Department of Computer Science ... •projection-normalization](https://reader034.vdocuments.site/reader034/viewer/2022042201/5ea0dd7fc0d74f13c56eee3e/html5/thumbnails/37.jpg)
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
![Page 38: Viewing/Projection V, Vision/Color Week 5, Mon Feb 1tmm/courses/314/Vjan2010/... · Viewing/Projection V, Vision/Color Week 5, Mon Feb 1. 2 Department of Computer Science ... •projection-normalization](https://reader034.vdocuments.site/reader034/viewer/2022042201/5ea0dd7fc0d74f13c56eee3e/html5/thumbnails/38.jpg)
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
![Page 39: Viewing/Projection V, Vision/Color Week 5, Mon Feb 1tmm/courses/314/Vjan2010/... · Viewing/Projection V, Vision/Color Week 5, Mon Feb 1. 2 Department of Computer Science ... •projection-normalization](https://reader034.vdocuments.site/reader034/viewer/2022042201/5ea0dd7fc0d74f13c56eee3e/html5/thumbnails/39.jpg)
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
![Page 40: Viewing/Projection V, Vision/Color Week 5, Mon Feb 1tmm/courses/314/Vjan2010/... · Viewing/Projection V, Vision/Color Week 5, Mon Feb 1. 2 Department of Computer Science ... •projection-normalization](https://reader034.vdocuments.site/reader034/viewer/2022042201/5ea0dd7fc0d74f13c56eee3e/html5/thumbnails/40.jpg)
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
![Page 41: Viewing/Projection V, Vision/Color Week 5, Mon Feb 1tmm/courses/314/Vjan2010/... · Viewing/Projection V, Vision/Color Week 5, Mon Feb 1. 2 Department of Computer Science ... •projection-normalization](https://reader034.vdocuments.site/reader034/viewer/2022042201/5ea0dd7fc0d74f13c56eee3e/html5/thumbnails/41.jpg)
41
OpenGL Precision Picking Hints• gluUnproject
• transform window coordinates to object coordinatesgiven 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
![Page 42: Viewing/Projection V, Vision/Color Week 5, Mon Feb 1tmm/courses/314/Vjan2010/... · Viewing/Projection V, Vision/Color Week 5, Mon Feb 1. 2 Department of Computer Science ... •projection-normalization](https://reader034.vdocuments.site/reader034/viewer/2022042201/5ea0dd7fc0d74f13c56eee3e/html5/thumbnails/42.jpg)
42
Vision/Color
![Page 43: Viewing/Projection V, Vision/Color Week 5, Mon Feb 1tmm/courses/314/Vjan2010/... · Viewing/Projection V, Vision/Color Week 5, Mon Feb 1. 2 Department of Computer Science ... •projection-normalization](https://reader034.vdocuments.site/reader034/viewer/2022042201/5ea0dd7fc0d74f13c56eee3e/html5/thumbnails/43.jpg)
43
Reading for Color
• RB Chap Color
• FCG Sections 3.2-3.3• FCG Chap 20 Color• FCG Chap 21.2.2 Visual Perception (Color)
![Page 44: Viewing/Projection V, Vision/Color Week 5, Mon Feb 1tmm/courses/314/Vjan2010/... · Viewing/Projection V, Vision/Color Week 5, Mon Feb 1. 2 Department of Computer Science ... •projection-normalization](https://reader034.vdocuments.site/reader034/viewer/2022042201/5ea0dd7fc0d74f13c56eee3e/html5/thumbnails/44.jpg)
44
RGB Color
• triple (r, g, b) represents colors with amountof red, green, and blue• hardware-centric• used by OpenGL
![Page 45: Viewing/Projection V, Vision/Color Week 5, Mon Feb 1tmm/courses/314/Vjan2010/... · Viewing/Projection V, Vision/Color Week 5, Mon Feb 1. 2 Department of Computer Science ... •projection-normalization](https://reader034.vdocuments.site/reader034/viewer/2022042201/5ea0dd7fc0d74f13c56eee3e/html5/thumbnails/45.jpg)
45
Alpha
• fourth component for transparency• (r,g,b,α)
• fraction we can see through• c = αcf + (1-α)cb
• more on compositing later
![Page 46: Viewing/Projection V, Vision/Color Week 5, Mon Feb 1tmm/courses/314/Vjan2010/... · Viewing/Projection V, Vision/Color Week 5, Mon Feb 1. 2 Department of Computer Science ... •projection-normalization](https://reader034.vdocuments.site/reader034/viewer/2022042201/5ea0dd7fc0d74f13c56eee3e/html5/thumbnails/46.jpg)
46
Additive vs. Subtractive Colors
• additive: light• monitors, LCDs• RGB model
• subtractive: pigment• printers• CMY model• dyes absorb
light
!!!
"
#
$$$
%
&
'
!!!
"
#
$$$
%
&
=
!!!
"
#
$$$
%
&
B
G
R
Y
M
C
1
1
1
additive subtractive
![Page 47: Viewing/Projection V, Vision/Color Week 5, Mon Feb 1tmm/courses/314/Vjan2010/... · Viewing/Projection V, Vision/Color Week 5, Mon Feb 1. 2 Department of Computer Science ... •projection-normalization](https://reader034.vdocuments.site/reader034/viewer/2022042201/5ea0dd7fc0d74f13c56eee3e/html5/thumbnails/47.jpg)
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
![Page 48: Viewing/Projection V, Vision/Color Week 5, Mon Feb 1tmm/courses/314/Vjan2010/... · Viewing/Projection V, Vision/Color Week 5, Mon Feb 1. 2 Department of Computer Science ... •projection-normalization](https://reader034.vdocuments.site/reader034/viewer/2022042201/5ea0dd7fc0d74f13c56eee3e/html5/thumbnails/48.jpg)
48
Basics Of Color
• elements of color:
![Page 49: Viewing/Projection V, Vision/Color Week 5, Mon Feb 1tmm/courses/314/Vjan2010/... · Viewing/Projection V, Vision/Color Week 5, Mon Feb 1. 2 Department of Computer Science ... •projection-normalization](https://reader034.vdocuments.site/reader034/viewer/2022042201/5ea0dd7fc0d74f13c56eee3e/html5/thumbnails/49.jpg)
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
![Page 50: Viewing/Projection V, Vision/Color Week 5, Mon Feb 1tmm/courses/314/Vjan2010/... · Viewing/Projection V, Vision/Color Week 5, Mon Feb 1. 2 Department of Computer Science ... •projection-normalization](https://reader034.vdocuments.site/reader034/viewer/2022042201/5ea0dd7fc0d74f13c56eee3e/html5/thumbnails/50.jpg)
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
![Page 51: Viewing/Projection V, Vision/Color Week 5, Mon Feb 1tmm/courses/314/Vjan2010/... · Viewing/Projection V, Vision/Color Week 5, Mon Feb 1. 2 Department of Computer Science ... •projection-normalization](https://reader034.vdocuments.site/reader034/viewer/2022042201/5ea0dd7fc0d74f13c56eee3e/html5/thumbnails/51.jpg)
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:
http://www.mhhe.com/physsci/astronomy/applets/Blackbody/frame.html
![Page 52: Viewing/Projection V, Vision/Color Week 5, Mon Feb 1tmm/courses/314/Vjan2010/... · Viewing/Projection V, Vision/Color Week 5, Mon Feb 1. 2 Department of Computer Science ... •projection-normalization](https://reader034.vdocuments.site/reader034/viewer/2022042201/5ea0dd7fc0d74f13c56eee3e/html5/thumbnails/52.jpg)
52
Electromagnetic Spectrum
![Page 53: Viewing/Projection V, Vision/Color Week 5, Mon Feb 1tmm/courses/314/Vjan2010/... · Viewing/Projection V, Vision/Color Week 5, Mon Feb 1. 2 Department of Computer Science ... •projection-normalization](https://reader034.vdocuments.site/reader034/viewer/2022042201/5ea0dd7fc0d74f13c56eee3e/html5/thumbnails/53.jpg)
53
Electromagnetic Spectrum
![Page 54: Viewing/Projection V, Vision/Color Week 5, Mon Feb 1tmm/courses/314/Vjan2010/... · Viewing/Projection V, Vision/Color Week 5, Mon Feb 1. 2 Department of Computer Science ... •projection-normalization](https://reader034.vdocuments.site/reader034/viewer/2022042201/5ea0dd7fc0d74f13c56eee3e/html5/thumbnails/54.jpg)
54
White Light
• sun or light bulbs emit all frequencies withinvisible range to produce what we perceive as"white light"
![Page 55: Viewing/Projection V, Vision/Color Week 5, Mon Feb 1tmm/courses/314/Vjan2010/... · Viewing/Projection V, Vision/Color Week 5, Mon Feb 1. 2 Department of Computer Science ... •projection-normalization](https://reader034.vdocuments.site/reader034/viewer/2022042201/5ea0dd7fc0d74f13c56eee3e/html5/thumbnails/55.jpg)
55
Sunlight Spectrum
• spectral distribution: power vs. wavelength
![Page 56: Viewing/Projection V, Vision/Color Week 5, Mon Feb 1tmm/courses/314/Vjan2010/... · Viewing/Projection V, Vision/Color Week 5, Mon Feb 1. 2 Department of Computer Science ... •projection-normalization](https://reader034.vdocuments.site/reader034/viewer/2022042201/5ea0dd7fc0d74f13c56eee3e/html5/thumbnails/56.jpg)
56
ContinuousSpectrum
• sunlight• various “daylight”
lamps
![Page 57: Viewing/Projection V, Vision/Color Week 5, Mon Feb 1tmm/courses/314/Vjan2010/... · Viewing/Projection V, Vision/Color Week 5, Mon Feb 1. 2 Department of Computer Science ... •projection-normalization](https://reader034.vdocuments.site/reader034/viewer/2022042201/5ea0dd7fc0d74f13c56eee3e/html5/thumbnails/57.jpg)
57
Line Spectrum
• ionizedgases
• lasers• some
fluorescentlamps
![Page 58: Viewing/Projection V, Vision/Color Week 5, Mon Feb 1tmm/courses/314/Vjan2010/... · Viewing/Projection V, Vision/Color Week 5, Mon Feb 1. 2 Department of Computer Science ... •projection-normalization](https://reader034.vdocuments.site/reader034/viewer/2022042201/5ea0dd7fc0d74f13c56eee3e/html5/thumbnails/58.jpg)
58
White Light and Color
• when white light is incident upon an object,some frequencies are reflected and some areabsorbed by the object
• combination of frequencies present in thereflected light that determines what weperceive as the color of the object
![Page 59: Viewing/Projection V, Vision/Color Week 5, Mon Feb 1tmm/courses/314/Vjan2010/... · Viewing/Projection V, Vision/Color Week 5, Mon Feb 1. 2 Department of Computer Science ... •projection-normalization](https://reader034.vdocuments.site/reader034/viewer/2022042201/5ea0dd7fc0d74f13c56eee3e/html5/thumbnails/59.jpg)
59
Hue• hue (or simply, "color") is dominant
wavelength/frequency
• integration of energy for all visible wavelengths isproportional to intensity of color
![Page 60: Viewing/Projection V, Vision/Color Week 5, Mon Feb 1tmm/courses/314/Vjan2010/... · Viewing/Projection V, Vision/Color Week 5, Mon Feb 1. 2 Department of Computer Science ... •projection-normalization](https://reader034.vdocuments.site/reader034/viewer/2022042201/5ea0dd7fc0d74f13c56eee3e/html5/thumbnails/60.jpg)
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
![Page 61: Viewing/Projection V, Vision/Color Week 5, Mon Feb 1tmm/courses/314/Vjan2010/... · Viewing/Projection V, Vision/Color Week 5, Mon Feb 1. 2 Department of Computer Science ... •projection-normalization](https://reader034.vdocuments.site/reader034/viewer/2022042201/5ea0dd7fc0d74f13c56eee3e/html5/thumbnails/61.jpg)
61
Intensity vs. Brightness
• intensity : physical term• measured radiant energy emitted per unit of
time, per unit solid angle, and per unitprojected area of the source (related to theluminance of the source)
• lightness/brightness: perceived intensity oflight• nonlinear
![Page 62: Viewing/Projection V, Vision/Color Week 5, Mon Feb 1tmm/courses/314/Vjan2010/... · Viewing/Projection V, Vision/Color Week 5, Mon Feb 1. 2 Department of Computer Science ... •projection-normalization](https://reader034.vdocuments.site/reader034/viewer/2022042201/5ea0dd7fc0d74f13c56eee3e/html5/thumbnails/62.jpg)
62
Perceptual vs. Colorimetric Terms• Perceptual
• Hue
• Saturation
• Lightness• reflecting objects
• Brightness• light sources
• Colorimetric
• Dominant wavelength
• Excitation purity
• Luminance
• Luminance