CS4300/5310 also#today:#3D#project(ini?al#awareness),# ... · CS4300/5310 Computer#Graphics# #...

33
CS 4300/5310 Computer Graphics also today: 3D project (ini?al awareness), Polly image credit: mynameishalo, deviantart

Transcript of CS4300/5310 also#today:#3D#project(ini?al#awareness),# ... · CS4300/5310 Computer#Graphics# #...

Page 1: CS4300/5310 also#today:#3D#project(ini?al#awareness),# ... · CS4300/5310 Computer#Graphics# # also#today:#3D#project(ini?al#awareness),#Polly# # o, t #

CS  4300/5310  Computer  Graphics  

 also  today:  3D  project  (ini?al  awareness),  Polly  

image  cred

it:  m

ynam

eishalo,  deviantart  

Page 2: CS4300/5310 also#today:#3D#project(ini?al#awareness),# ... · CS4300/5310 Computer#Graphics# # also#today:#3D#project(ini?al#awareness),#Polly# # o, t #

ANNOUNCEMENTS  

Page 3: CS4300/5310 also#today:#3D#project(ini?al#awareness),# ... · CS4300/5310 Computer#Graphics# # also#today:#3D#project(ini?al#awareness),#Polly# # o, t #

Upcoming  Deadlines  

§  Raytracer  §  February  19th  

§  2D  Project  Team  Feedback  §  Today!  

§  Art  Contests  §  ongoing…  

Page 4: CS4300/5310 also#today:#3D#project(ini?al#awareness),# ... · CS4300/5310 Computer#Graphics# # also#today:#3D#project(ini?al#awareness),#Polly# # o, t #

WHERE  ARE  WE?  and  where  are  we  going?  

Page 5: CS4300/5310 also#today:#3D#project(ini?al#awareness),# ... · CS4300/5310 Computer#Graphics# # also#today:#3D#project(ini?al#awareness),#Polly# # o, t #

2D  Graphics  

§  Image  processing  §  Image  warping  

§  2D  transforma?ons  

Page 6: CS4300/5310 also#today:#3D#project(ini?al#awareness),# ... · CS4300/5310 Computer#Graphics# # also#today:#3D#project(ini?al#awareness),#Polly# # o, t #

3D  Graphics  

§  Raytracing  §  Rasteriza?on  

§  3D  transforma?ons  

Page 7: CS4300/5310 also#today:#3D#project(ini?al#awareness),# ... · CS4300/5310 Computer#Graphics# # also#today:#3D#project(ini?al#awareness),#Polly# # o, t #

2D  Review  

§ What  does  this  2D  transforma?on  matrix  do?  

4 00 4

!

"#

$

%&

Page 8: CS4300/5310 also#today:#3D#project(ini?al#awareness),# ... · CS4300/5310 Computer#Graphics# # also#today:#3D#project(ini?al#awareness),#Polly# # o, t #

2D  Review  

§ What  does  this  2D  transforma?on  matrix  do?  

2 30 3

!

"#

$

%&

Page 9: CS4300/5310 also#today:#3D#project(ini?al#awareness),# ... · CS4300/5310 Computer#Graphics# # also#today:#3D#project(ini?al#awareness),#Polly# # o, t #

2D  Review  

§ What  does  this  2D  transforma?on  matrix  do?  

2 0 50 4 100 0 1

!

"

###

$

%

&&&

3D?!  

Page 10: CS4300/5310 also#today:#3D#project(ini?al#awareness),# ... · CS4300/5310 Computer#Graphics# # also#today:#3D#project(ini?al#awareness),#Polly# # o, t #

3D  TRANSFORMS  making  objects  move  

Page 11: CS4300/5310 also#today:#3D#project(ini?al#awareness),# ... · CS4300/5310 Computer#Graphics# # also#today:#3D#project(ini?al#awareness),#Polly# # o, t #

Scale  

Page 12: CS4300/5310 also#today:#3D#project(ini?al#awareness),# ... · CS4300/5310 Computer#Graphics# # also#today:#3D#project(ini?al#awareness),#Polly# # o, t #

Scale  

§  Same  as  2D!  

Sx 0 00 Sy 00 0 Sz

!

"

###

$

%

&&&

Page 13: CS4300/5310 also#today:#3D#project(ini?al#awareness),# ... · CS4300/5310 Computer#Graphics# # also#today:#3D#project(ini?al#awareness),#Polly# # o, t #

Shear  

§  2D:  Shear  along  axis  §  3D:  Shear  along  plane  

1 dxy dxzdyx 1 dyzdzx dzy 1

!

"

####

$

%

&&&&

Page 14: CS4300/5310 also#today:#3D#project(ini?al#awareness),# ... · CS4300/5310 Computer#Graphics# # also#today:#3D#project(ini?al#awareness),#Polly# # o, t #

RotaFon  

§  2D:  Around  a  point  (the  origin)  §  3D:  Around  an  axis  

 Rotate  a  point  around  the  z  axis:    

     x’  =  x  cos  θ  –  y  sin  θ        y’  =  x  sin  θ  +  y  cos  θ        z’  =  z  

 § What  is  the  matrix  for  this?  

Page 15: CS4300/5310 also#today:#3D#project(ini?al#awareness),# ... · CS4300/5310 Computer#Graphics# # also#today:#3D#project(ini?al#awareness),#Polly# # o, t #

RotaFon  

cosθ −sinθ 0sinθ cosθ 00 0 1

"

#

$$$

%

&

'''

cosθ 0 sinθ0 1 0

−sinθ 0 cosθ

"

#

$$$

%

&

'''

1 0 00 cosθ −sinθ0 sinθ cosθ

"

#

$$$

%

&

'''

z  axis   y  axis   x  axis  

Page 16: CS4300/5310 also#today:#3D#project(ini?al#awareness),# ... · CS4300/5310 Computer#Graphics# # also#today:#3D#project(ini?al#awareness),#Polly# # o, t #

RotaFon:  PuJng  it  all  Together  

§  Assume  α  is  angle  around  x-­‐axis,  β  around  y-­‐axis,  γ  around  z-­‐axis.  Compose  matrices  for  general  rota?on  matrix:  

cosβ cosγ −cosα sinγ + sinα sinβ cosγ sinα sinγ + cosα sinβ cosγcosβ sinγ cosα cosγ + sinα sinβ sinγ −sinα cosγ + cosα sinβ sinγ−sinβ sinα cosβ cosα cosβ

"

#

$$$

%

&

'''

Page 17: CS4300/5310 also#today:#3D#project(ini?al#awareness),# ... · CS4300/5310 Computer#Graphics# # also#today:#3D#project(ini?al#awareness),#Polly# # o, t #

Affine  Transforms  

§ What  is  a  linear  transforma?on?  

§ What  is  an  affine  transforma?on?  

Page 18: CS4300/5310 also#today:#3D#project(ini?al#awareness),# ... · CS4300/5310 Computer#Graphics# # also#today:#3D#project(ini?al#awareness),#Polly# # o, t #

TranslaFon:  Homogenous  Coordinates  

§ What  are  homogenous  coordinates?  

§  3D  transla?on:  generaliza?on  from  2D  

1 0 0 tx0 1 0 ty0 0 1 tz0 0 0 1

!

"

#####

$

%

&&&&&

Page 19: CS4300/5310 also#today:#3D#project(ini?al#awareness),# ... · CS4300/5310 Computer#Graphics# # also#today:#3D#project(ini?al#awareness),#Polly# # o, t #

3D:  Quick  “Quiz”  

§ What  does  this  3D  transforma?on  matrix  do?  

2 0 0 150 1 0 30 0 3 50 0 0 1

!

"

####

$

%

&&&&

Page 20: CS4300/5310 also#today:#3D#project(ini?al#awareness),# ... · CS4300/5310 Computer#Graphics# # also#today:#3D#project(ini?al#awareness),#Polly# # o, t #

3D:  Quick  “Quiz”  

§ What  does  this  3D  transforma?on  matrix  do?  

1 0 0 250 1 0 01.5 1.5 1 00 0 0 1

!

"

####

$

%

&&&&

Page 21: CS4300/5310 also#today:#3D#project(ini?al#awareness),# ... · CS4300/5310 Computer#Graphics# # also#today:#3D#project(ini?al#awareness),#Polly# # o, t #

3D:  Quick  “Quiz”  

§ What  does  this  3D  transforma?on  matrix  do?  

cos(30) −sin(30) 0 25sin(30) cos(30) 0 00 0 1 00 0 0 1

"

#

$$$$

%

&

''''

Page 22: CS4300/5310 also#today:#3D#project(ini?al#awareness),# ... · CS4300/5310 Computer#Graphics# # also#today:#3D#project(ini?al#awareness),#Polly# # o, t #

Euler  Angles  

§  Pronounced  “Oiler”  

§  Angles  describing  rota?on  around  x,  y,  and  z  axes  §  Or  any  orthonormal  basis  vectors…  

§  Pitch,  roll,  yaw  

Page 23: CS4300/5310 also#today:#3D#project(ini?al#awareness),# ... · CS4300/5310 Computer#Graphics# # also#today:#3D#project(ini?al#awareness),#Polly# # o, t #

The  Problem  with  Euler  Angles  

§  Gimbal  Lock!  §  Rotate  one  of  your  axes  90  degrees  so  it  perfectly  overlaps  another  

§  Lose  one  degree  of  freedom  

   §  Interpola?on  

§  Euler  angles  make  it  look  really  bad  L  

Page 24: CS4300/5310 also#today:#3D#project(ini?al#awareness),# ... · CS4300/5310 Computer#Graphics# # also#today:#3D#project(ini?al#awareness),#Polly# # o, t #

Avoiding  Gimbal  Lock  with  Quaternions  

§ What  is  a  quaternion?  §  A  real  number,  q  §  A  vector,  q  

§  Rota?ons  use  unit  quaternions  §  q2  +  ||q||2  =  1  § Magnitude  of  q  is  sin(θ/2)  §  q  is  cos(θ/2)  §  q  is  the  axis  around  which  the  object  will  rotate  §  θ  is  the  amount  of  the  rota?on  

Page 25: CS4300/5310 also#today:#3D#project(ini?al#awareness),# ... · CS4300/5310 Computer#Graphics# # also#today:#3D#project(ini?al#awareness),#Polly# # o, t #

MulFplying  Quaternions  

§  Q  =  (q,  q)  R  =  (r,  r)  

§  QR  =  (qr  –  q  .  r,  q  ×  r  +  rq  +  qr)  §  This  corresponds  to  applying  R  first,  then  Q  

§  Rota?ng  a  point,  s,  by  quaternion  R:  §  Extend  s  to  quaternion  S:  [0,  sx,  sy,  sz]  § Mul?ply!  

Page 26: CS4300/5310 also#today:#3D#project(ini?al#awareness),# ... · CS4300/5310 Computer#Graphics# # also#today:#3D#project(ini?al#awareness),#Polly# # o, t #

Spherical  Linear  InterpolaFon  (SLERP)  

§  Smoothly  rotate  between  two  quaternion  representa?ons  Q  and  R  

§  Compute  ϕ  =  arccos(qr  +  qxrx  +  qyry  +  qzrz)  

§  Interpola?on  parameter,  t  (0  ≤  t  ≤  1)  §  if  t  =  0  or  ϕ  =  0,  return  Q  §  if  t  =  1  or  ϕ  =  π,  return  R  §  else  return  (1/sin  ϕ)(sin((1  –  t)ϕ)Q  +  sin(tϕ)R)  

Page 27: CS4300/5310 also#today:#3D#project(ini?al#awareness),# ... · CS4300/5310 Computer#Graphics# # also#today:#3D#project(ini?al#awareness),#Polly# # o, t #

3D  PROJECTS  looking  ahead…  

Page 28: CS4300/5310 also#today:#3D#project(ini?al#awareness),# ... · CS4300/5310 Computer#Graphics# # also#today:#3D#project(ini?al#awareness),#Polly# # o, t #

Project  Structure  

§  2-­‐3  person  groups  §  Prefer  not  mixing  grad/undergrad  

§  Proposal:  March  19th  §  Checkpoints:  In  class  March  28th,  April  4th  §  Presenta?ons:  In  class  April  9th,  11th,  16th  §  Report:  April  16th  

Page 29: CS4300/5310 also#today:#3D#project(ini?al#awareness),# ... · CS4300/5310 Computer#Graphics# # also#today:#3D#project(ini?al#awareness),#Polly# # o, t #

Suggested  Topics  

§  Extension  to  Raytracer  § More  complex  geometry  §  Experiment  with  different  camera  types  §  Texturing  and/or  bump  mapping  

§  Interac?ve  Applica?ons  § Make  a  game  §  3D  Data  Visualiza?on  §  Interac?ve  Art  

Page 30: CS4300/5310 also#today:#3D#project(ini?al#awareness),# ... · CS4300/5310 Computer#Graphics# # also#today:#3D#project(ini?al#awareness),#Polly# # o, t #

Project  Goals  

§ More  focused  explora?on  of  3D  topics  §  Longer  term  project  than  2D  §  Time  for  deeper  explora?on  and  reflec?on  

 §  Technical  wri?ng  and  wri?ng  cri?que  

§  Project  cri?que  and  peer  code  review      

Page 31: CS4300/5310 also#today:#3D#project(ini?al#awareness),# ... · CS4300/5310 Computer#Graphics# # also#today:#3D#project(ini?al#awareness),#Polly# # o, t #

WriFng  Requirements  

§  Project  proposal:  3-­‐5  pages  § What  are  you  going  to  do?  §  How  are  you  going  to  do  it?  § Why  is  it  interes?ng?  What  is  the  problem  you  are  trying  to  solve?  

§ What  are  some  related  projects?  §  Project  report:  6-­‐8  pages    

§ What  did  you  do?  §  How  was  it  related  to  what  other  people  have  done?  

§ What  were  the  results?  

Page 32: CS4300/5310 also#today:#3D#project(ini?al#awareness),# ... · CS4300/5310 Computer#Graphics# # also#today:#3D#project(ini?al#awareness),#Polly# # o, t #

What  can  you  do  to  get  started?  

§  Assignments  form  a  “sampler”  of  3D  graphics  §  Raytracing  §  Interac?ve  3D  §  Shaders  

§ What  do  you  find  interes?ng?    § What  do  you  wish  your  assignment  could  do  that  it  can’t?  

§ What  do  you  wish  you  knew  more  about?  

Page 33: CS4300/5310 also#today:#3D#project(ini?al#awareness),# ... · CS4300/5310 Computer#Graphics# # also#today:#3D#project(ini?al#awareness),#Polly# # o, t #

POLLY  building  liwle  prototypes