HDR Workflows for Video Game Rendering

58
1

description

My summary of why and how to do HDR and ToneMapping in modern games. Mostly words, opinions, and very little, bad, code.

Transcript of HDR Workflows for Video Game Rendering

Page 1: HDR Workflows for Video Game Rendering

1  

Page 2: HDR Workflows for Video Game Rendering

2  

Page 3: HDR Workflows for Video Game Rendering

3  

Page 4: HDR Workflows for Video Game Rendering

Some)mes,  we  even  do  some  pre2y  advanced  colorspace  reasoning,  i.e.  gamma/linear  textures  in  CryEngine  h2p://www.crytek.com/download/AdvRTRend_crytek.ppt    “Some”  confusion  s)ll  persists…  I.e.      Which  spaces  are  linear  and  which  have  a  gamma  curve?  sRGB-­‐>CIEXYZ,  do  you  need  to  degamma?  h2p://www.brucelindbloom.com/index.html?Eqn_RGB_XYZ_Matrix.html  …  h2p://en.wikipedia.org/wiki/RGB_color_space    Why  sRGB  is  gamma  2.2?  Does  it  really  make  sense  today?  What  “gamma”  does  our  eye  “need”?  Perceptual  color  spaces…  See  CIELAB  h2p://en.wikipedia.org/wiki/Lab_color_space    What  color  space  does  HDR  live  in?  What  does  HDR  really  mean,  for  colors?  sRGB  is  defined  normalizing  on  the  white  point  intensity…  h2p://blogs.msdn.com/b/billcrow/archive/2007/10/25/hdr-­‐and-­‐color-­‐spaces.aspx    Anyhow…  

4  

Page 5: HDR Workflows for Video Game Rendering

5  

Page 6: HDR Workflows for Video Game Rendering

6  

Page 7: HDR Workflows for Video Game Rendering

7  

Page 8: HDR Workflows for Video Game Rendering

8  

Page 9: HDR Workflows for Video Game Rendering

9  

Page 10: HDR Workflows for Video Game Rendering

10  

Page 11: HDR Workflows for Video Game Rendering

11  

Page 12: HDR Workflows for Video Game Rendering

•  Ok,  not  true  in  all  cases,  for  example,  if  we  used  a  tonemapper  with  local  adap)on  (which,  games  don’t  really  do),  that  would  be  a  post-­‐filter  that  can’t  be  achieved  with  shaders  in  an  LDR.  Alpha  blending  also  can’t  exactly  match.  Dynamic  exposure  won’t  have  access  to  the  exact  same  informa)on  and  so  on.  Don’t  take  that  too  literally,  my  point  is  that  you  have  to  think  what  you’re  doing  and  why.  For  decades  now,  offline  renderers  were  not  working  in  linear  space,  nor  HDR,  and  that  didn’t  stop  ar)sts  from  crea)ng  perfectly  photorealis)c  images.  

12  

Page 13: HDR Workflows for Video Game Rendering

To  me,  the  first  three  are  either  irrelevant  or  easy  to  do  in  LDR,  not  that  interes)ng…  Let  me  be  clear  here.      With  enough  effort  we  can  take  some  equa)ons,  and  parameters,  and  tweak  them  and  tweak  them  un)l  they  look  perfect,  from  all  angles  and  situa)ons.  As  the  complexity  of  the  equa)ons  and  parameters  and  situa)ons  grow,  this  tweaking  work  becomes  unwieldy.    For  example,  we  can  take  our  shaders,  maybe  they  are  outpumng  a  color  and  the  highlights  are  clipped.  We  can  apply  to  that  color  and  these  highlights  some  desatura)on.  We  don’t  know  why,  but  it’s  necessary  to  make  the  image  not  look  like  a  nuclear  explosion  of  colors.  We  can  keep  tweaking  in  this  way,  un)l  it  looks  right  from  all  angles,  but  at  the  end  of  the  day,  aner  we  “blindly”  tweaked  and  hacked  things  without  “meaning”,  we  should  obtain  exactly  an  approxima)on  of  the  rules  of  physics  and  percep)on  we  “know”…    Physically  based  rendering  lets  us  reason  in  a  framework  of  certainty.  This  equa)on  is  a  material,  this  is  a  light,  this  is  energy,  this  is  a  color,  this  is  how  the  eye  sees  things.  It’s  s)ll  very  easy  to  forget  what’s  important,  to  choose  the  right  models,  to  miss  some  light  or  make  mistakes.  But  we  can  compare  the  output  with  our  reference,  the  reality,  see  our  error,  and  understand  where  and  why.  Hopefully.  

13  

Page 14: HDR Workflows for Video Game Rendering

Image  from  Fallout.  The  “errors”  are  my  own  interpreta)on,  maybe  this  image  was  fine  both  for  the  ar)sts,  and  was  tone  mapped  right…    Is  being  physically  based  always  be2er?  Not  really.  With  the  right  tools,  the  right  ar)sts,  and  maybe  in  a  game  that  is  more  constrained,  a  “painterly”,  ar)s)c  approach  might  very  well  be  the  way  to  go…  

14  

Page 15: HDR Workflows for Video Game Rendering

*At  least,  for  a  game  that  strives  for  realism    In  a  non  physically-­‐based,  or  be2er,  physically-­‐reasonable  renderer,  changing  a  variable  onen  requires  global  changes,  as  the  scene  was  setup  with  en))es  that  are  onen  correlated  and  do  not  carry  a  par)cular  meaning…  Shaders  output  a  color,  somehow…  

15  

Page 16: HDR Workflows for Video Game Rendering

16  

Page 17: HDR Workflows for Video Game Rendering

17  

Page 18: HDR Workflows for Video Game Rendering

18  

Page 19: HDR Workflows for Video Game Rendering

19  

Page 20: HDR Workflows for Video Game Rendering

20  

Page 21: HDR Workflows for Video Game Rendering

21  

Page 22: HDR Workflows for Video Game Rendering

22  

Page 23: HDR Workflows for Video Game Rendering

23  

Page 24: HDR Workflows for Video Game Rendering

24  

Page 25: HDR Workflows for Video Game Rendering

25  

Page 26: HDR Workflows for Video Game Rendering

26  

Page 27: HDR Workflows for Video Game Rendering

27  

Page 28: HDR Workflows for Video Game Rendering

28  

Page 29: HDR Workflows for Video Game Rendering

29  

Page 30: HDR Workflows for Video Game Rendering

30  

Page 31: HDR Workflows for Video Game Rendering

31  

Page 32: HDR Workflows for Video Game Rendering

32  

Page 33: HDR Workflows for Video Game Rendering

The  idea  of  local  TM  operators  is  that  loss  of  contrast  at  low  spa)al  frequencies  is  hard  to  perceive,  thus  we  can  “compress”  there  and  get  be2er  detail  (representa)on,  range  for  contrast  in  the  high  frequencies).  Local  filters  could  be  done  «tastefully»,  i.e.  Bilateral  filters,  edge  aware…  in  games,  righsully,  we  onen  prefer  to  convey  brightness  over  preserving  detail  anyways.    

33  

Page 34: HDR Workflows for Video Game Rendering

34  

Page 35: HDR Workflows for Video Game Rendering

If  the  tone  mapping  is  fixed  a-­‐priory,  we  could  tune  in  tone-­‐mapped  space  directly…  ...things  can  get  ugly  if  we  need  to  render  the  same  scene  under  different  tone  mappings,  if  we  tuned  for  one.  If  we  tune  directly  with  an  “art  directed”  tonemapping/colorgrading,  the  risk  is  that  our  scene  won’t  be  “physically  reasonable”  anymore.  We  might  not  be  able  to  tone  it  again,  to  change  our  decisions.  Easy  example  is  of  scenes  tuned  for  NO  tonemapping,  the  dynamic  range  is  onen  squished  down  by  the  ar)sts  (to  avoid  clipping)  in  a  way  that  won’t  ever  look  “right”  if  aner  authoring  we  just  decide  to  bolt-­‐on  some  tonemapping  operators…      

35  

Page 36: HDR Workflows for Video Game Rendering

36  

Page 37: HDR Workflows for Video Game Rendering

37  

Page 38: HDR Workflows for Video Game Rendering

38  

Page 39: HDR Workflows for Video Game Rendering

39  

Page 40: HDR Workflows for Video Game Rendering

40  

Page 41: HDR Workflows for Video Game Rendering

41  

Page 42: HDR Workflows for Video Game Rendering

42  

Page 43: HDR Workflows for Video Game Rendering

Simplify[D[1/(1  +  Exp[-­‐x*4]),  x]  /.  x  -­‐>  0]  Manipulate[    Plot[      Piecewise[{            {(1/(1  +  Exp[-­‐x*4]))  *  c  +  (0.5  +  x)*(1  -­‐  c),  x  <  0},            {(1/(1  +  Exp[-­‐x*4]))  *  d  +  (0.5  +  x)*(1  -­‐  d),  x  >=  0}            }]  /.  {x  -­‐>  (y  -­‐  b)/a}      ,  {y,  -­‐3,  3},  PlotRange  -­‐>  {0,  1}],    {{a,  1,  "range"},  0.1,  10},  {{b,  0,  "center"},  -­‐3,        3},  {{c,  1,  "low  curve"},  -­‐5,  1},  {{d,  1,  "hi  curve"},  -­‐5,  1}]  

43  

Page 44: HDR Workflows for Video Game Rendering

44  

Page 45: HDR Workflows for Video Game Rendering

45  

Page 46: HDR Workflows for Video Game Rendering

Why  not  using  alterna)ve  color  spaces?  HSL  and  similar  perceptual  models  are  built,  by  defini)on,  to  be  able  to  do  said  decoupling.  

Old,  «ar)st»  oriented  color  spaces.  Slow  to  convert  Today:  CIELAB,  CIELUV  

Changing  L  in  LAB  does  not  alter  color...  Problem:  S)ll  don’t  work  well  with  HDR  ranges…  

 

46  

Page 47: HDR Workflows for Video Game Rendering

47  

Page 48: HDR Workflows for Video Game Rendering

48  

Page 49: HDR Workflows for Video Game Rendering

49  

Page 50: HDR Workflows for Video Game Rendering

In  reality,  we  adapt  to  many  condi)ons,  i.e.  white  point,  but  you  have  to  be  aware  of  what  we  lose  from  HDR-­‐>LDR  and  what  is  s)ll  “working”  in  our  percep)on  of  an  LDR  image,  and  thus  we  don’t  need  to  simulate…  It’s  a  very  complicated  ma2er  that  also  depends  on  your  monitor  profile,  the  angle  the  monitor  spawns  in  your  view  and  so  on…  Also,  not  all  persons  are  the  same,  for  example,  vision  changes  quite  significantly  with  the  age,  i.e.  pdf.aminer.org/000/346/554/fast_tone_mapping_for_high_dynamic_range_images.pdf    

50  

Page 51: HDR Workflows for Video Game Rendering

Decoupling  ligh)ng  from  texture  is  what  bilateral  TMO  tries  to  achieve.  The  concept  of  “intrinsic  images”…  see  the  reference  

51  

Page 52: HDR Workflows for Video Game Rendering

52  

Page 53: HDR Workflows for Video Game Rendering

53  

Page 54: HDR Workflows for Video Game Rendering

54  

Page 55: HDR Workflows for Video Game Rendering

55  

Page 56: HDR Workflows for Video Game Rendering

56  

Page 57: HDR Workflows for Video Game Rendering

h2p://www.audioholics.com/tweaks/calibrate-­‐your-­‐system/hdmi-­‐black-­‐levels-­‐xvycc-­‐rgb  h2p://en.wikipedia.org/wiki/XvYCC  h2p://research.microson.com/en-­‐us/UM/redmond/groups/IVM/hdview/ColorExamples.htm  

57  

Page 58: HDR Workflows for Video Game Rendering

58