cs380: introduction to computer graphics projection chapter 10...

22
18/04/12 1 Min H. Kim (KAIST) Foundations of 3D Computer Graphics, S. Gortler, MIT Press, 2012 CS380: Introduction to Computer Graphics Projection Chapter 10 Min H. Kim KAIST School of Computing Min H. Kim (KAIST) Foundations of 3D Computer Graphics, S. Gortler, MIT Press, 2012 SUMMARY Smooth Interpolation 2

Upload: others

Post on 29-Aug-2020

6 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: CS380: Introduction to Computer Graphics Projection Chapter 10 …vclab.kaist.ac.kr/cs380/slide11-projection_v2.pdf · 2018. 4. 12. · 18/04/12 1 Min H. Kim (KAIST) Foundations of

18/04/12

1

MinH.Kim(KAIST) Foundationsof3DComputerGraphics,S.Gortler,MITPress,2012

CS380:IntroductiontoComputerGraphicsProjectionChapter10

MinH.KimKAISTSchoolofComputing

MinH.Kim(KAIST) Foundationsof3DComputerGraphics,S.Gortler,MITPress,2012

SUMMARYSmoothInterpolation

2

Page 2: CS380: Introduction to Computer Graphics Projection Chapter 10 …vclab.kaist.ac.kr/cs380/slide11-projection_v2.pdf · 2018. 4. 12. · 18/04/12 1 Min H. Kim (KAIST) Foundations of

18/04/12

2

MinH.Kim(KAIST) Foundationsof3DComputerGraphics,S.Gortler,MITPress,2012

CubicBezierSpline•  Toevaluatethefunctionatanyvalueof,weperformthefollowingsequenceoflinearinterpolations:

3

c(t) t

f = (1− t)c0 + td0g = (1− t)d0 + te0h = (1− t)e0 + tc0m = (1− t) f + tgn = (1− t)g + thc(t) = (1− t)m + tn

when t = 0.3

MinH.Kim(KAIST) Foundationsof3DComputerGraphics,S.Gortler,MITPress,2012

CubicBezierSpline•  Let’stakethefirst-orderderivatives:

•  Weseethat•  Weseeindeedthattheslopeofmatchestheslopeofthecontrolpolygonat0and1.

4

c(t)= c0(1−t)3+3d0t(1−t)2+3e0t2(1−t)+c1t3

′c (t) = 3c1t2 − 3e0t

2 − 3c0 (t −1)2 + 3d0 (t −1)

2 − 6e0t(t −1)+ 3d0t(2t − 2)

symsabcdtf(t)=a*(1-t)^3+3*b*t*(1-t)^2+3*c*t^2*(1-t)+d*t^3df=diff(f)df(0)=3*b-3*adf(1)=3*d-3*c

′c (0) = 3(d0 − c0 ), ′c (1) = 3(c1 − e0 )c(t)

Page 3: CS380: Introduction to Computer Graphics Projection Chapter 10 …vclab.kaist.ac.kr/cs380/slide11-projection_v2.pdf · 2018. 4. 12. · 18/04/12 1 Min H. Kim (KAIST) Foundations of

18/04/12

3

MinH.Kim(KAIST) Foundationsof3DComputerGraphics,S.Gortler,MITPress,2012

Catmull-RomSplines(CRS)•  Thisalsocanbestatedas

•  Sinceand,intheBezierrepresentation,thistellsusthatweneedtoset:

5

′c (t) i+1 =12ci+2 − ci( )

′c (i) = 3(di − ci ) ′c (i +1) = 3(ci+1 − ei )

di =

16 ci+1 −ci−1( )+ci

ei =−16 ci+2−ci( )+ci+1

′c (t) i =12ci+1 − ci−1( )

cidi

ei ci+1

ci−1

ci+2c(t)= ci(1−t)

3+3dit(1−t)2+3eit2(1−t)+ci+1t3

MinH.Kim(KAIST) Foundationsof3DComputerGraphics,S.Gortler,MITPress,2012

Curves•  Wecancleanlyapplythescalartheorytodescribecurvesintheplaneorspace.

•  Thesplinecurveiscontrolledbyasetofcontrolpointsin2Dor3D.

6

ciBeziercurve(2D) Catmull-Romcurve(2D)

Page 4: CS380: Introduction to Computer Graphics Projection Chapter 10 …vclab.kaist.ac.kr/cs380/slide11-projection_v2.pdf · 2018. 4. 12. · 18/04/12 1 Min H. Kim (KAIST) Foundations of

18/04/12

4

MinH.Kim(KAIST) Foundationsof3DComputerGraphics,S.Gortler,MITPress,2012

QuaternionSplining•  Bezierevaluationstepsoftheform:

•  Become:•  Andtheequationvaluesaredefinedas

•  Inordertointerpolate“theshortway”,wedoconditionalnegationonbeforeapplyingthepoweroperator.

7

r = (1− t)p + tq

r = slerp(p, q, t)di and ei

ei = ((ci+2ci−1)−1/6 )ci+1

di = ((ci+1ci−1−1 )1/6 )ci

(ci+1ci−1−1 )

⇐ di =16ci+1 − ci−1( ) + ci

⇐ ei =−16

ci+2 − ci( ) + ci+1

MinH.Kim(KAIST) Foundationsof3DComputerGraphics,S.Gortler,MITPress,2012

PROJECTIONChapter10

8

Chapters1—10Object&Animation

Chapters10—13Camera

Page 5: CS380: Introduction to Computer Graphics Projection Chapter 10 …vclab.kaist.ac.kr/cs380/slide11-projection_v2.pdf · 2018. 4. 12. · 18/04/12 1 Min H. Kim (KAIST) Foundations of

18/04/12

5

MinH.Kim(KAIST) Foundationsof3DComputerGraphics,S.Gortler,MITPress,2012

RECAP:Modelviewmatrix•  Modelviewmatrix(MVM)

– Describestheorientationandpositionoftheviewandtheorientationandpositionoftheobjectwithrespecttotheeyeframe

–  Thevertexshaderwilltakethesevertexdataandperformthemultiplication,producingtheeyecoordinatesusedinrendering

–  uniformmat4uModelViewMatrix;

•  normalMatrix()producestheinversetransposeofthelinearfactortogetuniformnormalNMVM–  uniformmat4uNormalMatrix;

9

E−1OE−1

O

p =otc = wtOc = etE−1Oc

et

E−1Oc

MinH.Kim(KAIST) Foundationsof3DComputerGraphics,S.Gortler,MITPress,2012

RECAP:Stagesofvertextransformation

10

Modelviewmatrix

Projectionmatrix

Perspectivedivision

Viewporttransforma

tion

eyecoordinates

http://www.glprogramming.com/red/chapter03.html

clipcoordinates

normalizeddevicecoordinates

windowcoordinates

vertex

xeyeze1

⎢⎢⎢⎢⎢

⎥⎥⎥⎥⎥

= E−1O

xoyozo1

⎢⎢⎢⎢⎢

⎥⎥⎥⎥⎥

xoyozo1

⎢⎢⎢⎢⎢

⎥⎥⎥⎥⎥

Page 6: CS380: Introduction to Computer Graphics Projection Chapter 10 …vclab.kaist.ac.kr/cs380/slide11-projection_v2.pdf · 2018. 4. 12. · 18/04/12 1 Min H. Kim (KAIST) Foundations of

18/04/12

6

MinH.Kim(KAIST) Foundationsof3DComputerGraphics,S.Gortler,MITPress,2012

RECAP:Cameraprojection(overview)•  Intrinsicpropertiesofthecamera(theeye)– Afieldofview– Windowaspectratio– Near/farfieldinZ(clipping)– Representedascamerafrustum

•  sendProjectionMatrix:sendthecameramatrixtothevertexshader

•  uniformmat4uProjMatrix;11

MinH.Kim(KAIST) Foundationsof3DComputerGraphics,S.Gortler,MITPress,2012

RECAP:Vertexshader•  Takestheobjectcoordinatesofeveryvertexpositionandturnsthemintoeyecoordinates,aswellasthevertex’snormalcoordinates

12

#version130uniformMatrix4uModelViewMatrix;uniformMatrix4uNormalMatrix;uniformMatrix4uProjMatrix;invec3aColor;invec4aNormal;invec4aVertex;outvec3vColor;outvec3vNormal;outvec3vPosition;

voidmain(){vColor=aColor;vPosition=uModelViewMatrix*aVertex;vec4normal=vec4(aNormal.x,aNormal.y,aNormal.z,0.0);vNormal=vec3(uNormalMatrix*normal);gl_Position=uProjMatrix*vPosition;}

E−1Oc

PE−1OcForcamera(3Dàà2D)

Page 7: CS380: Introduction to Computer Graphics Projection Chapter 10 …vclab.kaist.ac.kr/cs380/slide11-projection_v2.pdf · 2018. 4. 12. · 18/04/12 1 Min H. Kim (KAIST) Foundations of

18/04/12

7

MinH.Kim(KAIST) Foundationsof3DComputerGraphics,S.Gortler,MITPress,2012

Cameratransforms•  Untilnowwehaveconsideredallofourgeometryina3Dspace

•  Ultimatelyeverythingendedupineyecoordinateswithcoordinates

•  Wesaidthatthecameraisplacedattheoriginoftheeyeframe,andthatitislookingdowntheeye’snegativez-axis.

•  Thissomehowproducesa2Dimage.•  Wehadamagicmatrixwhichcreatedgl_Position•  Nowwewillstudythisstep

13

[xe, ye, ze,1]t

et

MinH.Kim(KAIST) Foundationsof3DComputerGraphics,S.Gortler,MITPress,2012

Pinholecameramodel

•  Aslighttravelstowardsthefilmplane,mostisblockedbyanopaquesurfaceplacedattheplane.

•  Butweplaceaverysmallholeinthecenterofthesurface,atthepointwitheyecoordinates

14

ze = 0

[0,0,0,1]t

[0,0,0,1]t

Page 8: CS380: Introduction to Computer Graphics Projection Chapter 10 …vclab.kaist.ac.kr/cs380/slide11-projection_v2.pdf · 2018. 4. 12. · 18/04/12 1 Min H. Kim (KAIST) Foundations of

18/04/12

8

MinH.Kim(KAIST) Foundationsof3DComputerGraphics,S.Gortler,MITPress,2012

Pinholecameramodel

•  Onlyraysoflightthatpassthroughthispointreachthefilmplaneandhavetheirintensityrecordedonfilm.Theimageisrecordedatafilmplaneplacedat,say,

15

ze = 1

[0,0,0,1]t

ze = 1

MinH.Kim(KAIST) Foundationsof3DComputerGraphics,S.Gortler,MITPress,2012

Pinholecameramodel

– Aphysicalcameraneedsafiniteapertureandalens,butwewillignorethis.

•  Toavoidtheimageflip,wecanmathematicallymodelthiswiththefilmplaneinfrontofthepinhole,sayatthe

16

ze = −1

[0,0,0,1]t

ze = −1

Page 9: CS380: Introduction to Computer Graphics Projection Chapter 10 …vclab.kaist.ac.kr/cs380/slide11-projection_v2.pdf · 2018. 4. 12. · 18/04/12 1 Min H. Kim (KAIST) Foundations of

18/04/12

9

MinH.Kim(KAIST) Foundationsof3DComputerGraphics,S.Gortler,MITPress,2012

Pinholecameramodel

•  Ifweholdupthephotographattheplane,andobserveitwithourowneye,placedattheorigin,itwilllooktousjustliketheoriginscenewouldhave.

17

ze = −1

[0,0,0,1]t

ze = −1

MinH.Kim(KAIST) Foundationsof3DComputerGraphics,S.Gortler,MITPress,2012

Basicmathematicalmodel

•  Letususenormalizedcoordinatestospecifypointsonourfilmplane.–  Fornow,letthemmatcheyecoordinatesonthisfilmplane.

•  Wheredoestherayfromtotheoriginhitsthefilmplane?

18

[xn , yn ]t

p

[0,0,0,1]t

p

Page 10: CS380: Introduction to Computer Graphics Projection Chapter 10 …vclab.kaist.ac.kr/cs380/slide11-projection_v2.pdf · 2018. 4. 12. · 18/04/12 1 Min H. Kim (KAIST) Foundations of

18/04/12

10

MinH.Kim(KAIST) Foundationsof3DComputerGraphics,S.Gortler,MITPress,2012

Basicmathematicalmodel

•  Allpointsontherayhitthesamepixel.•  Allpointsontherayareallscales•  Sopointsonrayare:

19

[xe , ye ,ze ]t =α[xn , yn ,−1]t

[0,0,0,1]t

p

α

MinH.Kim(KAIST) Foundationsof3DComputerGraphics,S.Gortler,MITPress,2012

Basicmathematicalmodel

•  So•  So

20

[xe, ye, ze ]t = −ze[xn , yn ,−1]

t

xn = − xeze, yn = − ye

ze

[0,0,0,1]t

−ze

ye p

Page 11: CS380: Introduction to Computer Graphics Projection Chapter 10 …vclab.kaist.ac.kr/cs380/slide11-projection_v2.pdf · 2018. 4. 12. · 18/04/12 1 Min H. Kim (KAIST) Foundations of

18/04/12

11

MinH.Kim(KAIST) Foundationsof3DComputerGraphics,S.Gortler,MITPress,2012

Projectionmatrix

•  Wecanmodelthisexpressionasamatrixoperationasfollows.

21

1 0 0 00 1 0 0− − − −0 0 −1 0

⎢⎢⎢⎢

⎥⎥⎥⎥

xeyeze1

⎢⎢⎢⎢⎢

⎥⎥⎥⎥⎥

=

xnwn

ynwn

−wn

⎢⎢⎢⎢⎢

⎥⎥⎥⎥⎥

=

xcyc−wc

⎢⎢⎢⎢⎢

⎥⎥⎥⎥⎥

[0,0,0,1]t

p

MinH.Kim(KAIST) Foundationsof3DComputerGraphics,S.Gortler,MITPress,2012

Inmatrixform

•  Therawoutputofthematrixmultiply,arecalledtheclipcoordinatesof.

•  isanewvariablecalledthew-coordinate.–  Insuchclipcoordinates,thefourthentryofthecoordinate4-vectorisnotnecessarilyazerooraone.

22

[0,0,0,1]t

[xc , yc ,−,wc ]t

pwn = wc

p

Page 12: CS380: Introduction to Computer Graphics Projection Chapter 10 …vclab.kaist.ac.kr/cs380/slide11-projection_v2.pdf · 2018. 4. 12. · 18/04/12 1 Min H. Kim (KAIST) Foundations of

18/04/12

12

MinH.Kim(KAIST) Foundationsof3DComputerGraphics,S.Gortler,MITPress,2012

Dividebyw

•  Wesaythatand.Ifwewanttoextractalone,wemustperformthedivision

•  Thisrecoversourcameramodel

23

[0,0,0,1]t

xnwn = xcxn

ynwn = yc

p

1 0 0 00 1 0 0− − − −0 0 −1 0

⎢⎢⎢⎢

⎥⎥⎥⎥

xeyeze1

⎢⎢⎢⎢⎢

⎥⎥⎥⎥⎥

=

xnwn

ynwn

−wn

⎢⎢⎢⎢⎢

⎥⎥⎥⎥⎥

=

xcyc−wc

⎢⎢⎢⎢⎢

⎥⎥⎥⎥⎥

xn =

xcwn

=xnwn

wn

MinH.Kim(KAIST) Foundationsof3DComputerGraphics,S.Gortler,MITPress,2012

Dividebyw

•  Ouroutputcoordinates,withsubscripts‘n’,arecallednormalizeddevicecoordinates(NDC)becausetheyaddresspointsontheimageinabstractunitswithoutspecificreferencetonumbersofpixels.

24

[0,0,0,1]t

p

Page 13: CS380: Introduction to Computer Graphics Projection Chapter 10 …vclab.kaist.ac.kr/cs380/slide11-projection_v2.pdf · 2018. 4. 12. · 18/04/12 1 Min H. Kim (KAIST) Foundations of

18/04/12

13

MinH.Kim(KAIST) Foundationsof3DComputerGraphics,S.Gortler,MITPress,2012

Dividebyw

•  Wekeepalloftheimagedatainthecanonicalsquare,andultimatelymapthisontoawindowonthescreen.–  Dataoutsideofthissquaredoesnotberecordedordisplayed.

–  Thisisexactlythemodelweusedtodescribe2DOpenGL25

[0,0,0,1]t

−1≤ xn ≤ +1, −1≤ yn ≤ +1,

p

MinH.Kim(KAIST) Foundationsof3DComputerGraphics,S.Gortler,MITPress,2012

Scales

26

ze = n n

[0,0,0,1]t

yn =1

yn =−1

•  Bychangingtheentriesintheprojectionmatrix,wecanslightlyaltergeometryofthecameratransformation.

•  Wecouldpushthefilmplaneoutto,whereissomenegativenumber(zoomlens)

Page 14: CS380: Introduction to Computer Graphics Projection Chapter 10 …vclab.kaist.ac.kr/cs380/slide11-projection_v2.pdf · 2018. 4. 12. · 18/04/12 1 Min H. Kim (KAIST) Foundations of

18/04/12

14

MinH.Kim(KAIST) Foundationsof3DComputerGraphics,S.Gortler,MITPress,2012

Scales

•  Sopointsonrayare:•  So•  So

27

[xe , ye ,ze ]t =α[xn , yn ,zn]t

[xe , ye ,ze ]t =

zen[xn , yn ,zn]t

xn =xenze, yn =

yenze

[0,0,0,1]t

yn =1

yn =−1

MinH.Kim(KAIST) Foundationsof3DComputerGraphics,S.Gortler,MITPress,2012

Inmatrixform

•  Inmatrixform,thisbecomes:

28

[0,0,0,1]t

xnwn

ynwn

−wn

⎢⎢⎢⎢⎢

⎥⎥⎥⎥⎥

=

−n 0 0 00 −n 0 0− − − −0 0 −1 0

⎢⎢⎢⎢

⎥⎥⎥⎥

xeyeze1

⎢⎢⎢⎢⎢

⎥⎥⎥⎥⎥

(supposingnissomenegativenumber)

yn =1

yn =−1

yn =1

yn =−1

Page 15: CS380: Introduction to Computer Graphics Projection Chapter 10 …vclab.kaist.ac.kr/cs380/slide11-projection_v2.pdf · 2018. 4. 12. · 18/04/12 1 Min H. Kim (KAIST) Foundations of

18/04/12

15

MinH.Kim(KAIST) Foundationsof3DComputerGraphics,S.Gortler,MITPress,2012

Inmatrixform

•  Notethismatrixisthesameas

29

[0,0,0,1]t

−n 0 0 00 −n 0 0− − − −0 0 0 1

⎢⎢⎢⎢

⎥⎥⎥⎥

1 0 0 00 1 0 0− − − −0 0 −1 0

⎢⎢⎢⎢

⎥⎥⎥⎥

yn =1

yn =−1

yn =1

yn =−1

MinH.Kim(KAIST) Foundationsof3DComputerGraphics,S.Gortler,MITPress,2012

Inmatrixform

•  Thishasthesameeffectasstartingwithouroriginalcamera,scalingby,andcroppingtothecanonicalsquare.

30

[0,0,0,1]t

−n

yn =1

yn =−1

yn =1

yn =−1

Page 16: CS380: Introduction to Computer Graphics Projection Chapter 10 …vclab.kaist.ac.kr/cs380/slide11-projection_v2.pdf · 2018. 4. 12. · 18/04/12 1 Min H. Kim (KAIST) Foundations of

18/04/12

16

MinH.Kim(KAIST) Foundationsof3DComputerGraphics,S.Gortler,MITPress,2012

fovY

•  Scalecanbedeterminedbyverticalangularfieldofviewofthedesiredcamera.

•  Ifwewantourcameratohaveafieldofviewofdegrees,thenwecansetgivingus

31

[0,0,0,1]t

θ−n = 1

tan θ2

⎛⎝⎜

⎞⎠⎟

MinH.Kim(KAIST) Foundationsof3DComputerGraphics,S.Gortler,MITPress,2012

fovY

•  Verifythatanypointwho’srayfromtheoriginformsaverticalangleofwiththenegativeaxismapstotheboundaryofthecanonicalsquare

32

[0,0,0,1]t

1

tan θ2

⎛⎝⎜

⎞⎠⎟

0 0 0

0 1

tan θ2

⎛⎝⎜

⎞⎠⎟

0 0

− − − −0 0 −1 0

⎢⎢⎢⎢⎢⎢⎢⎢⎢⎢

⎥⎥⎥⎥⎥⎥⎥⎥⎥⎥

θ / 2 z

Page 17: CS380: Introduction to Computer Graphics Projection Chapter 10 …vclab.kaist.ac.kr/cs380/slide11-projection_v2.pdf · 2018. 4. 12. · 18/04/12 1 Min H. Kim (KAIST) Foundations of

18/04/12

17

MinH.Kim(KAIST) Foundationsof3DComputerGraphics,S.Gortler,MITPress,2012

fovY

•  Thepointwitheyecoordinates:mapstonormalizeddevicecoordinates

33

[0,0,0,1]t

[0, tan θ2

⎛⎝⎜

⎞⎠⎟ ,−1,1]

t

[0,1]t

1

tan θ2

⎛⎝⎜

⎞⎠⎟

0 0 0

0 1

tan θ2

⎛⎝⎜

⎞⎠⎟

0 0

− − − −0 0 −1 0

⎢⎢⎢⎢⎢⎢⎢⎢⎢⎢

⎥⎥⎥⎥⎥⎥⎥⎥⎥⎥

MinH.Kim(KAIST) Foundationsof3DComputerGraphics,S.Gortler,MITPress,2012

Dealingwithaspectratio•  Supposethewindowiswiderthanitishigh.Inourcameratransform,weneedtosquishthingshorizontallysoawiderhorizontalfieldofviewfitsintoourretainedcanonicalsquare.

•  Whenthedataislatermappedtothewindow,itwillbestretchedoutcorrespondinglyandwillnotappeardistorted.

•  Define,theaspectratioofawindow,tobeitswidthdividedbyitsheight(measuredsayinpixels).

34

a

a = width px( )height px( )

Page 18: CS380: Introduction to Computer Graphics Projection Chapter 10 …vclab.kaist.ac.kr/cs380/slide11-projection_v2.pdf · 2018. 4. 12. · 18/04/12 1 Min H. Kim (KAIST) Foundations of

18/04/12

18

MinH.Kim(KAIST) Foundationsof3DComputerGraphics,S.Gortler,MITPress,2012

Dealingwithaspectratio•  Wecanthensetourprojectionmatrixtobe:

•  Sowhenthewindowiswide,wewillkeepmorehorizontalFOV,andwhenthewindowistall,wewillkeeplesshorizontalFOV.

35

1atan θ

2⎛

⎝⎜⎞

⎠⎟

0 0 0

0 1tan θ

2⎛

⎝⎜⎞

⎠⎟

0 0

− − − −0 0 −1 0

⎢⎢⎢⎢⎢⎢⎢⎢⎢⎢⎢

⎥⎥⎥⎥⎥⎥⎥⎥⎥⎥⎥

MinH.Kim(KAIST) Foundationsof3DComputerGraphics,S.Gortler,MITPress,2012

Dealingwithaspectratio•  Asanalternative,wecouldhaveanfovMin,andwhenthewindowistall,wewouldneedtocalculateanappropriatelargerfovYandthenbuildthematrix.

36

Page 19: CS380: Introduction to Computer Graphics Projection Chapter 10 …vclab.kaist.ac.kr/cs380/slide11-projection_v2.pdf · 2018. 4. 12. · 18/04/12 1 Min H. Kim (KAIST) Foundations of

18/04/12

19

MinH.Kim(KAIST) Foundationsof3DComputerGraphics,S.Gortler,MITPress,2012

FOVissues•  Tobea“window”ontotheworld,theFOVshouldmatchtheangularextentsofthewindowintheviewersfield.

•  Thismightgiveatoolimitedviewontotheworld.

•  Sowecanincreaseittoseemore.•  Butthismightgiveasomewhatunnaturallook.

37

MinH.Kim(KAIST) Foundationsof3DComputerGraphics,S.Gortler,MITPress,2012

Shifts

•  Sometimes,wewishtocroptheimagenon-centrally.

•  Thiscanbemodeledastranslatingthenormalizeddevicecoordinates(NDC)’sandthencroppingcentrally.

38

Page 20: CS380: Introduction to Computer Graphics Projection Chapter 10 …vclab.kaist.ac.kr/cs380/slide11-projection_v2.pdf · 2018. 4. 12. · 18/04/12 1 Min H. Kim (KAIST) Foundations of

18/04/12

20

MinH.Kim(KAIST) Foundationsof3DComputerGraphics,S.Gortler,MITPress,2012

Shifts

39

xnwn

ynwn

−wn

⎢⎢⎢⎢⎢

⎥⎥⎥⎥⎥

=

1 0 0 cx0 1 0 c y− − − −0 0 0 1

⎢⎢⎢⎢⎢

⎥⎥⎥⎥⎥

1 0 0 00 1 0 0− − − −0 0 −1 0

⎢⎢⎢⎢

⎥⎥⎥⎥

xeyeze1

⎢⎢⎢⎢⎢

⎥⎥⎥⎥⎥

=

1 0 −cx 00 1 −c y 0− − − −0 0 −1 0

⎢⎢⎢⎢⎢

⎥⎥⎥⎥⎥

xeyeze1

⎢⎢⎢⎢⎢

⎥⎥⎥⎥⎥

MinH.Kim(KAIST) Foundationsof3DComputerGraphics,S.Gortler,MITPress,2012

Shifts

40

•  Usefulfortileddisplays,stereoviewing,andcertainkindsofimages.

Page 21: CS380: Introduction to Computer Graphics Projection Chapter 10 …vclab.kaist.ac.kr/cs380/slide11-projection_v2.pdf · 2018. 4. 12. · 18/04/12 1 Min H. Kim (KAIST) Foundations of

18/04/12

21

MinH.Kim(KAIST) Foundationsof3DComputerGraphics,S.Gortler,MITPress,2012

Frustum•  Shiftsareoftenspecifiedbyfirstspecifyinganear

plane.•  Onthisplane,arectangleisspecifiedwiththeeye

coordinatesofanaxisalignedrectangle.(fornon-distortedoutput,theaspectratioofthisrectangleshouldmatchthatofthefinalwindow.)–  Using

41

ze = n

l, r, t, b.

− 2nr − l

0 r + lr − l

0

0 − 2nt − b

t + bt − b

0

− − − −0 0 −1 0

⎢⎢⎢⎢⎢⎢⎢

⎥⎥⎥⎥⎥⎥⎥

MinH.Kim(KAIST) Foundationsof3DComputerGraphics,S.Gortler,MITPress,2012

Frustum•  Example1:

42

−2nr − l

0 r+ lr − l

0

0 −2nt −b

t +bt −b

0

− − − −0 0 −1 0

⎢⎢⎢⎢⎢⎢⎢

⎥⎥⎥⎥⎥⎥⎥

•  Example2:

xy

z !etl =−3

r =3t =2

b=−2(0,0)

n=−2

2×23+3 0 0

3+3 0

0 2×22+2

02+2 0

− − − −0 0 −1 0

⎢⎢⎢⎢⎢⎢⎢

⎥⎥⎥⎥⎥⎥⎥

xy

z !et

l =2

r =4t =4

b=2(3,3)

n=−2(0,0)

2×24−2 0 4+2

4−2 0

0 2×24−2

4+24−2 0

− − − −0 0 −1 0

⎢⎢⎢⎢⎢⎢⎢

⎥⎥⎥⎥⎥⎥⎥

Page 22: CS380: Introduction to Computer Graphics Projection Chapter 10 …vclab.kaist.ac.kr/cs380/slide11-projection_v2.pdf · 2018. 4. 12. · 18/04/12 1 Min H. Kim (KAIST) Foundations of

18/04/12

22

MinH.Kim(KAIST) Foundationsof3DComputerGraphics,S.Gortler,MITPress,2012

Context•  Projectioncouldbeappliedtoeverypointinthescene.

•  InCG,wewillapplyittotheverticestopositionatriangleonthescreen.

•  Therestofthetrianglewillthengetfilledinonthescreenasweshallsee.

43

MinH.Kim(KAIST) Foundationsof3DComputerGraphics,S.Gortler,MITPress,2012

Summary:Projectionfrom3Dto2D

44

•  3Dà2D

X

Y

−Zx

yX

p

x

cameracenter

imageplane

principalaxis

C +Z

xnyn1

⎢⎢⎢

⎥⎥⎥=

xcycwc

⎢⎢⎢

⎥⎥⎥=

−n 0 −cx0 −n −cy0 0 −1

⎢⎢⎢

⎥⎥⎥

xeyeze

⎢⎢⎢

⎥⎥⎥

u

v

cx

cy p x

y

xnyn1

⎢⎢⎢

⎥⎥⎥=

xcwn

ycwn

wc

wn

⎢⎢⎢⎢⎢⎢⎢

⎥⎥⎥⎥⎥⎥⎥

=

n xeze+ cx

n yeze+ cy

1

⎢⎢⎢⎢⎢⎢⎢

⎥⎥⎥⎥⎥⎥⎥

wc =wn = −zen < 0normalization

NBThecameraframeoriginlookstheoppositedirectionincomputervision