Computer Graphics II - University of...

26
Cameras Computer Graphics II Autumn 2017-2018 CS4085

Transcript of Computer Graphics II - University of...

Page 1: Computer Graphics II - University of Limerickgarryowen.csisdmz.ul.ie/~cs4085/resources/lect05.pdf · Computer Graphics II Autumn 2017-2018 CS4085. Cameras ... Objects that intersect

Cameras

Computer Graphics II

Autumn 2017-2018

CS4085

Page 2: Computer Graphics II - University of Limerickgarryowen.csisdmz.ul.ie/~cs4085/resources/lect05.pdf · Computer Graphics II Autumn 2017-2018 CS4085. Cameras ... Objects that intersect

Cameras

Outline

1 CamerasThe Perspective Camera Model

CS4085

Page 3: Computer Graphics II - University of Limerickgarryowen.csisdmz.ul.ie/~cs4085/resources/lect05.pdf · Computer Graphics II Autumn 2017-2018 CS4085. Cameras ... Objects that intersect

Cameras The Perspective Camera Model

Outline

1 CamerasThe Perspective Camera Model

CS4085

Page 4: Computer Graphics II - University of Limerickgarryowen.csisdmz.ul.ie/~cs4085/resources/lect05.pdf · Computer Graphics II Autumn 2017-2018 CS4085. Cameras ... Objects that intersect

Cameras The Perspective Camera Model

View Volumes

Only a part of world is displayed at any one time: the viewvolumeCulling is the process of determining what objects are notvisibleObjects that intersect the view volume boundaries are onlypartially visibleClipping is the process of intersecting an object with theview volumeVisible data is displayed by projecting it on to a view planeThe viewport is the rectangular region of the view planethat is drawn on the computer screenThe view frustum is defined by the infinite pyramid whoseapex is the eye-point, with four flat (non-parallel sides) andtruncated at the near plane and far plane

CS4085

Page 5: Computer Graphics II - University of Limerickgarryowen.csisdmz.ul.ie/~cs4085/resources/lect05.pdf · Computer Graphics II Autumn 2017-2018 CS4085. Cameras ... Objects that intersect

Cameras The Perspective Camera Model

View Volumes

Only a part of world is displayed at any one time: the viewvolumeCulling is the process of determining what objects are notvisibleObjects that intersect the view volume boundaries are onlypartially visibleClipping is the process of intersecting an object with theview volumeVisible data is displayed by projecting it on to a view planeThe viewport is the rectangular region of the view planethat is drawn on the computer screenThe view frustum is defined by the infinite pyramid whoseapex is the eye-point, with four flat (non-parallel sides) andtruncated at the near plane and far plane

CS4085

Page 6: Computer Graphics II - University of Limerickgarryowen.csisdmz.ul.ie/~cs4085/resources/lect05.pdf · Computer Graphics II Autumn 2017-2018 CS4085. Cameras ... Objects that intersect

Cameras The Perspective Camera Model

View Volumes

Only a part of world is displayed at any one time: the viewvolumeCulling is the process of determining what objects are notvisibleObjects that intersect the view volume boundaries are onlypartially visibleClipping is the process of intersecting an object with theview volumeVisible data is displayed by projecting it on to a view planeThe viewport is the rectangular region of the view planethat is drawn on the computer screenThe view frustum is defined by the infinite pyramid whoseapex is the eye-point, with four flat (non-parallel sides) andtruncated at the near plane and far plane

CS4085

Page 7: Computer Graphics II - University of Limerickgarryowen.csisdmz.ul.ie/~cs4085/resources/lect05.pdf · Computer Graphics II Autumn 2017-2018 CS4085. Cameras ... Objects that intersect

Cameras The Perspective Camera Model

View Volumes

Only a part of world is displayed at any one time: the viewvolumeCulling is the process of determining what objects are notvisibleObjects that intersect the view volume boundaries are onlypartially visibleClipping is the process of intersecting an object with theview volumeVisible data is displayed by projecting it on to a view planeThe viewport is the rectangular region of the view planethat is drawn on the computer screenThe view frustum is defined by the infinite pyramid whoseapex is the eye-point, with four flat (non-parallel sides) andtruncated at the near plane and far plane

CS4085

Page 8: Computer Graphics II - University of Limerickgarryowen.csisdmz.ul.ie/~cs4085/resources/lect05.pdf · Computer Graphics II Autumn 2017-2018 CS4085. Cameras ... Objects that intersect

Cameras The Perspective Camera Model

View Volumes

Only a part of world is displayed at any one time: the viewvolumeCulling is the process of determining what objects are notvisibleObjects that intersect the view volume boundaries are onlypartially visibleClipping is the process of intersecting an object with theview volumeVisible data is displayed by projecting it on to a view plane;this will be orthogonal to viewing directionThe viewport is the rectangular region of the view planethat is drawn on the computer screenThe view frustum is defined by the infinite pyramid whoseapex is the eye-point, with four flat (non-parallel sides) andtruncated at the near plane and far plane

CS4085

Page 9: Computer Graphics II - University of Limerickgarryowen.csisdmz.ul.ie/~cs4085/resources/lect05.pdf · Computer Graphics II Autumn 2017-2018 CS4085. Cameras ... Objects that intersect

Cameras The Perspective Camera Model

View Volumes

Only a part of world is displayed at any one time: the viewvolumeCulling is the process of determining what objects are notvisibleObjects that intersect the view volume boundaries are onlypartially visibleClipping is the process of intersecting an object with theview volumeVisible data is displayed by projecting it on to a view planeThe viewport is the rectangular region of the view planethat is drawn on the computer screenThe view frustum is defined by the infinite pyramid whoseapex is the eye-point, with four flat (non-parallel sides) andtruncated at the near plane and far plane

CS4085

Page 10: Computer Graphics II - University of Limerickgarryowen.csisdmz.ul.ie/~cs4085/resources/lect05.pdf · Computer Graphics II Autumn 2017-2018 CS4085. Cameras ... Objects that intersect

Cameras The Perspective Camera Model

View Volumes

Only a part of world is displayed at any one time: the viewvolumeCulling is the process of determining what objects are notvisibleObjects that intersect the view volume boundaries are onlypartially visibleClipping is the process of intersecting an object with theview volumeVisible data is displayed by projecting it on to a view planeThe viewport is the rectangular region of the view planethat is drawn on the computer screenThe view frustum is defined by the infinite pyramid whoseapex is the eye-point, with four flat (non-parallel sides) andtruncated at the near plane and far plane

CS4085

Page 11: Computer Graphics II - University of Limerickgarryowen.csisdmz.ul.ie/~cs4085/resources/lect05.pdf · Computer Graphics II Autumn 2017-2018 CS4085. Cameras ... Objects that intersect

Cameras The Perspective Camera Model

Camera Model

Projection onto the (near) view plane is computed byintersecting a ray with the view planeThe ray originates at e, the eye point, and passes throughworld point x ; the intersection point with the view plane is yThe combination of eye point, coordinate axes located ateye point, view plane, view port and view frustum definesthe camera modelCamera coordinate system

origin e = (0,0,0) in#»

D − #»

U − #»

R ; 6= (0,0,0) in worldco-ords!unit-length direction vector

D perp. to view planeclosest point to observer is p = e + dmin

D,dmin > 0#»

U is unit-length camera up vector#»

R is unit-length right vector such that#»

R =#»

D × #»

U (in RHCS)

CS4085

Page 12: Computer Graphics II - University of Limerickgarryowen.csisdmz.ul.ie/~cs4085/resources/lect05.pdf · Computer Graphics II Autumn 2017-2018 CS4085. Cameras ... Objects that intersect

Cameras The Perspective Camera Model

Camera Model

Projection onto the (near) view plane is computed byintersecting a ray with the view planeThe ray originates at e, the eye point, and passes throughworld point x ; the intersection point with the view plane is yThe combination of eye point, coordinate axes located ateye point, view plane, view port and view frustum definesthe camera modelCamera coordinate system

origin e = (0,0,0) in#»

D − #»

U − #»

Runit-length direction vector

D perp. to view plane; pointsaway from observer so eye point is on negative side ofplane by conventionclosest point to observer is p = e + dmin

D,dmin > 0#»

U is unit-length camera up vector#»

R is unit-length right vector such that#»

R =#»

D × #»

U (in RHCS)

CS4085

Page 13: Computer Graphics II - University of Limerickgarryowen.csisdmz.ul.ie/~cs4085/resources/lect05.pdf · Computer Graphics II Autumn 2017-2018 CS4085. Cameras ... Objects that intersect

Cameras The Perspective Camera Model

Camera Model

Projection onto the (near) view plane is computed byintersecting a ray with the view planeThe ray originates at e, the eye point, and passes throughworld point x ; the intersection point with the view plane is yThe combination of eye point, coordinate axes located ateye point, view plane, view port and view frustum definesthe camera modelCamera coordinate system

origin e = (0,0,0) in#»

D − #»

U − #»

Runit-length direction vector

D perp. to view planeclosest point to observer is p = e + dmin

D,dmin > 0#»

U is unit-length camera up vector#»

R is unit-length right vector such that#»

R =#»

D × #»

U (in RHCS)

CS4085

Page 14: Computer Graphics II - University of Limerickgarryowen.csisdmz.ul.ie/~cs4085/resources/lect05.pdf · Computer Graphics II Autumn 2017-2018 CS4085. Cameras ... Objects that intersect

Cameras The Perspective Camera Model

Camera Model

Projection onto the (near) view plane is computed byintersecting a ray with the view planeThe ray originates at e, the eye point, and passes throughworld point x ; the intersection point with the view plane is yThe combination of eye point, coordinate axes located ateye point, view plane, view port and view frustum definesthe camera modelCamera coordinate system

origin e = (0,0,0) in#»

D − #»

U − #»

Runit-length direction vector

D perp. to view planeclosest point to observer is p = e + dmin

D,dmin > 0#»

U is unit-length camera up vector chosen to be parallel toopposing edges of viewport#»

R is unit-length right vector such that#»

R =#»

D × #»

U (in RHCS)

CS4085

Page 15: Computer Graphics II - University of Limerickgarryowen.csisdmz.ul.ie/~cs4085/resources/lect05.pdf · Computer Graphics II Autumn 2017-2018 CS4085. Cameras ... Objects that intersect

Cameras The Perspective Camera Model

Camera Model

Projection onto the (near) view plane is computed byintersecting a ray with the view planeThe ray originates at e, the eye point, and passes throughworld point x ; the intersection point with the view plane is yThe combination of eye point, coordinate axes located ateye point, view plane, view port and view frustum definesthe camera modelCamera coordinate system

origin e = (0,0,0) in#»

D − #»

U − #»

Runit-length direction vector

D perp. to view planeclosest point to observer is p = e + dmin

D,dmin > 0#»

U is unit-length camera up vector#»

R is unit-length right vector such that#»

R =#»

D × #»

U (in RHCS)

CS4085

Page 16: Computer Graphics II - University of Limerickgarryowen.csisdmz.ul.ie/~cs4085/resources/lect05.pdf · Computer Graphics II Autumn 2017-2018 CS4085. Cameras ... Objects that intersect

Cameras The Perspective Camera Model

Camera Model

e

vtl

vbl

vbr

vtrp

wtl

wbl

wbr

wtr

View plane vertices, v.. and far plane, w..

Both normals point into frustum; near plane#»

D, far plane−

D

CS4085

Page 17: Computer Graphics II - University of Limerickgarryowen.csisdmz.ul.ie/~cs4085/resources/lect05.pdf · Computer Graphics II Autumn 2017-2018 CS4085. Cameras ... Objects that intersect

Cameras The Perspective Camera Model

Frustum Vertices

View plane vertices are vbl = e + dmin#»

D + umin#»

U + rmin#»

R,and (in coordinates form)vtl = e + (dmin,umax , rmin),vbr = e + (dmin,umin, rmax),vtr = e + (dmin,umax , rmax)

Far plane vertices rely on “similar triangle” scaling factor

dmax

dmin

Far plane vertices arewbl = e + dmax

dmin(dmin,umin, rmin),

wtl = e + dmaxdmin

(dmin,umax , rmin),wbr = e + dmax

dmin(dmin,umin, rmax),

wtr = e + dmaxdmin

(dmin,umax , rmax)

CS4085

Page 18: Computer Graphics II - University of Limerickgarryowen.csisdmz.ul.ie/~cs4085/resources/lect05.pdf · Computer Graphics II Autumn 2017-2018 CS4085. Cameras ... Objects that intersect

Cameras The Perspective Camera Model

Frustum planes

Near plane has a point p = e + dmin#»

D; the vector between thisand any point x on this plane, x − p, is orthogonal to normal,

D.So

D tx =#»

D t(e + dmin#»

D) =#»

D te + dmin

Similarly for point x on far plane and its normal −#»

D

−#»

D tx = −#»

D t(e + dmax#»

D) = −(#»

D te + dmax)

On left plane, three points are e, vtl and vbl . The normalpointing into frustum is given by (no

U component)

(vbl − e)× (vtl − e) =(dmin#»

D + umin#»

U + rmin#»

R)×

(dmin#»

D + umax#»

U + rmin#»

R)

=...

=(umax − umin)(dmin#»

R − rmin#»

D)

CS4085

Page 19: Computer Graphics II - University of Limerickgarryowen.csisdmz.ul.ie/~cs4085/resources/lect05.pdf · Computer Graphics II Autumn 2017-2018 CS4085. Cameras ... Objects that intersect

Cameras The Perspective Camera Model

Frustum planes (contd.)

When made unit-length, the left plane normal,#»

N l is

dmin#»

R − rmin#»

D√d2

min + r2min

and the equation of points on this plane is

N l · (x − e) = 0

We can repeat this for right plane using (vtr − e)× (vbr − e) andget

N r =−dmin

R + rmax#»

D√d2

min + r2max

,#»

N r · (x − e) = 0

and likewise for top and bottom faces

CS4085

Page 20: Computer Graphics II - University of Limerickgarryowen.csisdmz.ul.ie/~cs4085/resources/lect05.pdf · Computer Graphics II Autumn 2017-2018 CS4085. Cameras ... Objects that intersect

Cameras The Perspective Camera Model

Camera Model (concl.)

We usually choose a symmetric view frustum so thatumax = −umin and rmax = −rmin

This implies four independent parametersdmin,dmax ,umax and rmax

Alternativelywe can specify the field of view in the

U direction and theaspect ratio of view port windowField of view is 2θu then and aspect ratio, ρ, isρ = rmax/umaxWe get umax = dmin tan θu and then rmax = ρumaxThen dmin,dmax , θu and ρ completely specify the frustumagain

CS4085

Page 21: Computer Graphics II - University of Limerickgarryowen.csisdmz.ul.ie/~cs4085/resources/lect05.pdf · Computer Graphics II Autumn 2017-2018 CS4085. Cameras ... Objects that intersect

Cameras The Perspective Camera Model

Camera Model (concl.)

We usually choose a symmetric view frustum so thatumax = −umin and rmax = −rmin

This implies four independent parametersdmin,dmax ,umax and rmax

Alternativelywe can specify the field of view in the

U direction and theaspect ratio of view port windowField of view is 2θu then and aspect ratio, ρ, isρ = rmax/umaxWe get umax = dmin tan θu and then rmax = ρumaxThen dmin,dmax , θu and ρ completely specify the frustumagain

CS4085

Page 22: Computer Graphics II - University of Limerickgarryowen.csisdmz.ul.ie/~cs4085/resources/lect05.pdf · Computer Graphics II Autumn 2017-2018 CS4085. Cameras ... Objects that intersect

Cameras The Perspective Camera Model

Camera Model (concl.)

We usually choose a symmetric view frustum so thatumax = −umin and rmax = −rmin

This implies four independent parametersdmin,dmax ,umax and rmax

Alternativelywe can specify the field of view in the

U direction and theaspect ratio of view port windowField of view is 2θu then and aspect ratio, ρ, isρ = rmax/umaxWe get umax = dmin tan θu and then rmax = ρumaxThen dmin,dmax , θu and ρ completely specify the frustumagain

CS4085

Page 23: Computer Graphics II - University of Limerickgarryowen.csisdmz.ul.ie/~cs4085/resources/lect05.pdf · Computer Graphics II Autumn 2017-2018 CS4085. Cameras ... Objects that intersect

Cameras The Perspective Camera Model

Camera Model (concl.)

We usually choose a symmetric view frustum so thatumax = −umin and rmax = −rminThis implies four independent parametersdmin,dmax ,umax and rmaxAlternatively

we can specify the field of view in the#»

U direction and theaspect ratio of view port window

U

De

umax

umin

dmin dmaxθu

Field of view is 2θu then and aspect ratio, ρ, isρ = rmax/umaxWe get umax = dmin tan θu and then rmax = ρumaxThen dmin,dmax , θu and ρ completely specify the frustumagain

CS4085

Page 24: Computer Graphics II - University of Limerickgarryowen.csisdmz.ul.ie/~cs4085/resources/lect05.pdf · Computer Graphics II Autumn 2017-2018 CS4085. Cameras ... Objects that intersect

Cameras The Perspective Camera Model

Camera Model (concl.)

We usually choose a symmetric view frustum so thatumax = −umin and rmax = −rmin

This implies four independent parametersdmin,dmax ,umax and rmax

Alternativelywe can specify the field of view in the

U direction and theaspect ratio of view port windowField of view is 2θu then and aspect ratio, ρ, isρ = rmax/umaxWe get umax = dmin tan θu and then rmax = ρumaxThen dmin,dmax , θu and ρ completely specify the frustumagain

CS4085

Page 25: Computer Graphics II - University of Limerickgarryowen.csisdmz.ul.ie/~cs4085/resources/lect05.pdf · Computer Graphics II Autumn 2017-2018 CS4085. Cameras ... Objects that intersect

Cameras The Perspective Camera Model

Camera Model (concl.)

We usually choose a symmetric view frustum so thatumax = −umin and rmax = −rmin

This implies four independent parametersdmin,dmax ,umax and rmax

Alternativelywe can specify the field of view in the

U direction and theaspect ratio of view port windowField of view is 2θu then and aspect ratio, ρ, isρ = rmax/umaxWe get umax = dmin tan θu and then rmax = ρumaxThen dmin,dmax , θu and ρ completely specify the frustumagain

CS4085

Page 26: Computer Graphics II - University of Limerickgarryowen.csisdmz.ul.ie/~cs4085/resources/lect05.pdf · Computer Graphics II Autumn 2017-2018 CS4085. Cameras ... Objects that intersect

Cameras The Perspective Camera Model

Camera Model (concl.)

We usually choose a symmetric view frustum so thatumax = −umin and rmax = −rmin

This implies four independent parametersdmin,dmax ,umax and rmax

Alternativelywe can specify the field of view in the

U direction and theaspect ratio of view port windowField of view is 2θu then and aspect ratio, ρ, isρ = rmax/umaxWe get umax = dmin tan θu and then rmax = ρumaxThen dmin,dmax , θu and ρ completely specify the frustumagain

CS4085