CS4300/5310 also#today:#giving#a2#minute#talk# … · CS4300/5310 Computer#Graphics# #...

43
CS 4300/5310 Computer Graphics also today: giving a 2 minute talk image credit: pikanjo, newgrounds

Transcript of CS4300/5310 also#today:#giving#a2#minute#talk# … · CS4300/5310 Computer#Graphics# #...

Page 1: CS4300/5310 also#today:#giving#a2#minute#talk# … · CS4300/5310 Computer#Graphics# # also#today:#giving#a2#minute#talk# # o, ounds #

CS  4300/5310  Computer  Graphics  

 also  today:  giving  a  2  minute  talk  

image  cred

it:  pikanjo,  new

grou

nds  

Page 2: CS4300/5310 also#today:#giving#a2#minute#talk# … · CS4300/5310 Computer#Graphics# # also#today:#giving#a2#minute#talk# # o, ounds #

ANNOUNCEMENTS  

Page 3: CS4300/5310 also#today:#giving#a2#minute#talk# … · CS4300/5310 Computer#Graphics# # also#today:#giving#a2#minute#talk# # o, ounds #

Upcoming  Deadlines  

 §  2D  Project  main  deadline:  February  5th    §  That’s  in  5  days!  

Page 4: CS4300/5310 also#today:#giving#a2#minute#talk# … · CS4300/5310 Computer#Graphics# # also#today:#giving#a2#minute#talk# # o, ounds #

My  office  has  moved!  

§  New  office:  Meserve  Hall,  Room  146  

§  DirecPons  §  Go  through  unmarked  grey  door  facing  Centennial  Common  

§  Go  up  a  few  stairs,  leR  through  the  door  at  top  

§  Follow  signs  for  game  design,  along  right  hallway  

Page 5: CS4300/5310 also#today:#giving#a2#minute#talk# … · CS4300/5310 Computer#Graphics# # also#today:#giving#a2#minute#talk# # o, ounds #

RAYCASTING  conPnued  from  last  Pme…  

Page 6: CS4300/5310 also#today:#giving#a2#minute#talk# … · CS4300/5310 Computer#Graphics# # also#today:#giving#a2#minute#talk# # o, ounds #

Algorithm  Overview  

for  every  pixel,  p,  in  the  image    let  r  be  the  ray  from  camera  through  pixel    calculate  intersecEon  between  r  and  scene  objects    if  (!intersecPon)      set  p  to  “background  color”    else      p  =  color  calculated  from  first  object  it  hits  

Page 7: CS4300/5310 also#today:#giving#a2#minute#talk# … · CS4300/5310 Computer#Graphics# # also#today:#giving#a2#minute#talk# # o, ounds #

IntersecEng  with  Scene  Objects  

Page 8: CS4300/5310 also#today:#giving#a2#minute#talk# … · CS4300/5310 Computer#Graphics# # also#today:#giving#a2#minute#talk# # o, ounds #

Aside:  3D  Picking  

§ When  we  click  on  the  screen,  what  object  are  we  selecPng?  § We  can  use  raycasPng  to  figure  this  out!  

Page 9: CS4300/5310 also#today:#giving#a2#minute#talk# … · CS4300/5310 Computer#Graphics# # also#today:#giving#a2#minute#talk# # o, ounds #

Spheres  

§  RepresentaPon  of  a  sphere:  §  Center,  C  §  Radius,  r  §  ||x  –  c||2  =  r2  

§  Ray:    §  Origin,  O  §  DirecPon,  L  §  Distance  along  line,  d  §  x  =  O  +  dL  

O  

L  

Page 10: CS4300/5310 also#today:#giving#a2#minute#talk# … · CS4300/5310 Computer#Graphics# # also#today:#giving#a2#minute#talk# # o, ounds #

Spheres  

§  ||O  +  dL  –  C||2  =  r2    

§  Solve  for  d….  

O  

L  

Page 11: CS4300/5310 also#today:#giving#a2#minute#talk# … · CS4300/5310 Computer#Graphics# # also#today:#giving#a2#minute#talk# # o, ounds #

Planes  

§  Plane:  §  x.N  +  depth  =  0  

§  Ray:    §  Origin,  O  §  DirecPon,  L  §  Distance  along  line,  d  §  x  =  O  +  dL  

N  

Page 12: CS4300/5310 also#today:#giving#a2#minute#talk# … · CS4300/5310 Computer#Graphics# # also#today:#giving#a2#minute#talk# # o, ounds #

Planes  

§  (O  +  dL)  .  N  +  depth  =  0  

§  Solve  for  d?  

N  

Page 13: CS4300/5310 also#today:#giving#a2#minute#talk# … · CS4300/5310 Computer#Graphics# # also#today:#giving#a2#minute#talk# # o, ounds #

Triangles  (Strategy  I)  

Page 14: CS4300/5310 also#today:#giving#a2#minute#talk# … · CS4300/5310 Computer#Graphics# # also#today:#giving#a2#minute#talk# # o, ounds #

Triangles  (Strategy  I)  

§  Check  if  point  on  the  plane  is  inside  the  triangle  

§  AxC  should  be  same  direcPon  as  AxB   X  

A  

B  

C  

Page 15: CS4300/5310 also#today:#giving#a2#minute#talk# … · CS4300/5310 Computer#Graphics# # also#today:#giving#a2#minute#talk# # o, ounds #

Triangles  (Strategy  I)  

§  Check  if  point  on  the  plane  is  inside  the  triangle  

§  AxC  should  be  same  direcPon  as  AxB  §  And  its  not!  

Y  A  

B  

C  

Page 16: CS4300/5310 also#today:#giving#a2#minute#talk# … · CS4300/5310 Computer#Graphics# # also#today:#giving#a2#minute#talk# # o, ounds #

Triangles  (Strategy  II)  

§  Barycentric  coordinates  

§  X  =  α(T2-­‐T1)  +  β(T0  –  T1)  

§  Solve  for  α  and  β  §  if  α  >  1  or  β  >  1,  fail  §  if  α  +  β  >  1,  fail  

X  

T0  

T1   T2  

Page 17: CS4300/5310 also#today:#giving#a2#minute#talk# … · CS4300/5310 Computer#Graphics# # also#today:#giving#a2#minute#talk# # o, ounds #

More  complicated  things?  

§  Can  intersect  with  any  mathemaPcal  representaPon  of  a  3D  structure!  §  But  somePmes  the  math  gets  kinda  complicated  

§  Examples  §  Cones,  cylinders  §  Boxes  §  Polygons  (convex,  concave)  §  Compound  geometry  

Page 18: CS4300/5310 also#today:#giving#a2#minute#talk# … · CS4300/5310 Computer#Graphics# # also#today:#giving#a2#minute#talk# # o, ounds #

OpEmizaEon  Approaches  

§  Bounding  volumes  §  Uniform  grid  §  Octrees  §  BSP  Trees  

§  “Embarrassingly  parallel”  

Page 19: CS4300/5310 also#today:#giving#a2#minute#talk# … · CS4300/5310 Computer#Graphics# # also#today:#giving#a2#minute#talk# # o, ounds #

LIGHTING  AND  SHADING  

Page 20: CS4300/5310 also#today:#giving#a2#minute#talk# … · CS4300/5310 Computer#Graphics# # also#today:#giving#a2#minute#talk# # o, ounds #

Types  of  LighEng  

§  Local  IlluminaPon  §  Emission  from  light  sources  §  Scanering  at  surface  

§  Global  IlluminaPon  §  Shadows  §  ReflecPon  §  RefracPon  

Page 21: CS4300/5310 also#today:#giving#a2#minute#talk# … · CS4300/5310 Computer#Graphics# # also#today:#giving#a2#minute#talk# # o, ounds #

Types  of  LighEng  

§  Local  IlluminaPon  §  Emission  from  light  sources  §  Scanering  at  surface  

§  Global  IlluminaPon  §  Shadows  §  ReflecPon  §  RefracPon  

Page 22: CS4300/5310 also#today:#giving#a2#minute#talk# … · CS4300/5310 Computer#Graphics# # also#today:#giving#a2#minute#talk# # o, ounds #

Light  Sources  

§  Point  light  

§  DirecPonal  light  

§  Spot  light  

§  Ambient  light  

Page 23: CS4300/5310 also#today:#giving#a2#minute#talk# … · CS4300/5310 Computer#Graphics# # also#today:#giving#a2#minute#talk# # o, ounds #

Point  Light  

§  Like  a  light  bulb  that  radiates  light  equally  in  all  direcPons  §  AnenuaPon:  the  further  an  object  is  from  the  light,  the  less  light  it  receives  

§  Parameters:  §  PosiPon:  x,  y,  z  §  Intensity  (I0):  r,  g,  b    §  AnenuaPon  factor:  a,  b,  c  

d  

IL =I0

a+ b*d + c*d 2

Page 24: CS4300/5310 also#today:#giving#a2#minute#talk# … · CS4300/5310 Computer#Graphics# # also#today:#giving#a2#minute#talk# # o, ounds #

DirecEonal  Light  

§  Like  a  point  light  that  is  infinitely  far  away  with  no  anenuaPon  §  Good  for  modeling  “daylight”  

§  Parameters:  §  DirecPon:  dx,  dy,  dz  §  Intensity  (I0):  r,  g,  b  

IL = I0

Page 25: CS4300/5310 also#today:#giving#a2#minute#talk# … · CS4300/5310 Computer#Graphics# # also#today:#giving#a2#minute#talk# # o, ounds #

Spot  Light  

§  DirecPonal  light  that  is  anchored  to  a  point  §  Desk  lamp,  flashlight,  spotlight  

§  Parameters:  §  PosiPon:  x,  y,  z  §  DirecPon:  dx,  dy,  dz  §  AnenuaPon:  a,  b,  c  §  Intensity  (I0):  r,  g,  b  

L D

IL =I0 (L•D)a+ bd + cd 2

Page 26: CS4300/5310 also#today:#giving#a2#minute#talk# … · CS4300/5310 Computer#Graphics# # also#today:#giving#a2#minute#talk# # o, ounds #

Ambient  Light  

§  “Hacky”  model  of  light  in  a  scene  resulPng  from  it  bouncing  around  everywhere  §  Good  for  modeling  “background”  light  

§  Parameters  §  Intensity:  r,  g,  b  

IA = I0

Page 27: CS4300/5310 also#today:#giving#a2#minute#talk# … · CS4300/5310 Computer#Graphics# # also#today:#giving#a2#minute#talk# # o, ounds #

Types  of  LighEng  

§  Local  IlluminaPon  §  Emission  from  light  sources  §  ScaSering  at  surface  

§  Global  IlluminaPon  §  Shadows  §  ReflecPon  §  RefracPon  

Page 28: CS4300/5310 also#today:#giving#a2#minute#talk# … · CS4300/5310 Computer#Graphics# # also#today:#giving#a2#minute#talk# # o, ounds #

Surface  Material  ProperEes  

§ MA:  ambient  color  § MD:  diffuse  color  § MS:  specular  color  §  n:  specular  light  exponent  § ME:  emissive  light  color  § MT:  transmissive  color  § MR:  index  of  refracPon  

Page 29: CS4300/5310 also#today:#giving#a2#minute#talk# … · CS4300/5310 Computer#Graphics# # also#today:#giving#a2#minute#talk# # o, ounds #

Algorithm  Overview  

for  every  pixel,  p,  in  the  image    let  r  be  the  ray  from  camera  through  pixel    calculate  intersecEon  between  r  and  scene  objects    if  (!intersecPon)      set  p  to  “background  color”    else      p  =  color  calculated  from  first  object  it  hits  

Page 30: CS4300/5310 also#today:#giving#a2#minute#talk# … · CS4300/5310 Computer#Graphics# # also#today:#giving#a2#minute#talk# # o, ounds #

What  color  is  my  pixel?  

Amount  of  ambient  light  at  surface  +    amount  of  diffuse  light  at  surface  +  amount  of  specular  light  at  surface  +    amount  of  emissive  light  from  material  +  light  reflected  by  the  object  +  light  due  to  transparency  of  object  

color  =  ΣL  …  

Page 31: CS4300/5310 also#today:#giving#a2#minute#talk# … · CS4300/5310 Computer#Graphics# # also#today:#giving#a2#minute#talk# # o, ounds #

How  much  ambient  light?  

§  There  is  usually  only  one  ambient  light  in  a  scene  

color  =  MAIA  

Surface  Material  

N  L  V  

R  

I  

Page 32: CS4300/5310 also#today:#giving#a2#minute#talk# … · CS4300/5310 Computer#Graphics# # also#today:#giving#a2#minute#talk# # o, ounds #

How  much  diffuse  light?  (LamberEan  Shading)  

§  Diffuse  shading:  mane  color  §  Assume  material  reflects  light  evenly  in  all  direcPons  

color  =  MAIA  +  ΣLMD(N�L)IL  

Surface  Material  

N  L  V  

R  

I  

Page 33: CS4300/5310 also#today:#giving#a2#minute#talk# … · CS4300/5310 Computer#Graphics# # also#today:#giving#a2#minute#talk# # o, ounds #

How  much  specular  light?  (Phong  Shading)  

§  Specular  light:  idealized  reflecPon  §  Depends  on  how  much  is  seen  by  viewer  

color  =  MAIA  +  ΣL(MD(N�L)IL  +  MS(V�R)nIL)  

Surface  Material  

N  L  V  

R  

I  

Page 34: CS4300/5310 also#today:#giving#a2#minute#talk# … · CS4300/5310 Computer#Graphics# # also#today:#giving#a2#minute#talk# # o, ounds #

LamberEan  and  Phong  Shading:  Examples  

LamberPan  (Diffuse)   Blinn-­‐Phong  (Specular)  

Page 35: CS4300/5310 also#today:#giving#a2#minute#talk# … · CS4300/5310 Computer#Graphics# # also#today:#giving#a2#minute#talk# # o, ounds #

How  much  emissive  light?    

§  Specular  light:  idealized  reflecPon  §  Depends  on  how  much  is  seen  by  viewer  

color  =  MAIA  +  ME  +  ΣL(MD(N�L)IL  +  MS(V�R)nIL)  

Surface  Material  

N  L  V  

R  

I  

Page 36: CS4300/5310 also#today:#giving#a2#minute#talk# … · CS4300/5310 Computer#Graphics# # also#today:#giving#a2#minute#talk# # o, ounds #

Shadows  

§  If  there  is  an  object  in  the  way  of  the  light,  it’s  in  shadow  for  that  light  

Surface  Material  

N  L  V  

R  

color  =  MAIA  +  ME  +  ΣLSL(MD(N�L)IL  +  MS(V�R)nIL)  

I  

Page 37: CS4300/5310 also#today:#giving#a2#minute#talk# … · CS4300/5310 Computer#Graphics# # also#today:#giving#a2#minute#talk# # o, ounds #

Types  of  LighEng  

§  Local  IlluminaPon  §  Emission  from  light  sources  §  Scanering  at  surface  

§  Global  IlluminaEon  §  Shadows  §  ReflecPon  §  RefracPon  

Page 38: CS4300/5310 also#today:#giving#a2#minute#talk# … · CS4300/5310 Computer#Graphics# # also#today:#giving#a2#minute#talk# # o, ounds #

ReflecEon  

§  If  there  is  an  object  in  the  way  of  the  light,  it’s  in  shadow  for  that  light  

Surface  Material  

N  L  V  

R  

color  =  MAIA  +  ME  +  ΣLSL(MD(N�L)IL  +  MS(V�R)nIL)  +  MSIR    

R   I  

Page 39: CS4300/5310 also#today:#giving#a2#minute#talk# … · CS4300/5310 Computer#Graphics# # also#today:#giving#a2#minute#talk# # o, ounds #

RefracEon  

§  Transmissive  light:  how  does  light  bend  as  it  goes  through  the  surface?  [Book  chapter  13.1]  

Surface  Material  

N  L  V  

R  

color  =  MAIA  +  ME  +  ΣLSL(MD(N�L)IL  +  MS(V�R)nIL)  +  MSIR  +  MTIT    

R  

T  

I  

Page 40: CS4300/5310 also#today:#giving#a2#minute#talk# … · CS4300/5310 Computer#Graphics# # also#today:#giving#a2#minute#talk# # o, ounds #

Raytracing  vs.  RaycasEng  

§  RaycasPng  §  Non-­‐recursive  §  Only  capable  of  diffuse,  specular,  emissive  lighPng  

§  Raytracing  §  Recursive  §  Send  out  rays  for:  

§  Shadow  § ReflecPon  § RefracPon  

§  Important  to  have  maximum  depth  of  rays  to  avoid  infinite  loops  (e.g.  hall  of  mirrors)  

Page 41: CS4300/5310 also#today:#giving#a2#minute#talk# … · CS4300/5310 Computer#Graphics# # also#today:#giving#a2#minute#talk# # o, ounds #

2  MINUTE  TALKS  pracPce  your  elevator  pitch  

Page 42: CS4300/5310 also#today:#giving#a2#minute#talk# … · CS4300/5310 Computer#Graphics# # also#today:#giving#a2#minute#talk# # o, ounds #

Ideal  Talk  PresentaEon  Format  

§  15  seconds  § Who  you  are,  what  your  project  is  called  

§  1  minute  §  Summary  of  what  you  did  

§  45  seconds  §  Video  demonstraPng  what  you  did  

Page 43: CS4300/5310 also#today:#giving#a2#minute#talk# … · CS4300/5310 Computer#Graphics# # also#today:#giving#a2#minute#talk# # o, ounds #

Goals  of  the  Elevator  Pitch  

§  CreaPng  a  posiPve  impression  

§  Opening  the  door  to  further  conversaPon  

Source:  hnp://graduateschool.nd.edu/assets/32665/elevator_pitch_presentaPon.pdf