Successfully reported this slideshow.
We use your LinkedIn profile and activity data to personalize ads and to show you more relevant ads. You can change your ad preferences anytime.

Introduction to Bidirectional Path Tracing (BDPT) & Implementation using OpenCL (CEDEC 2015)

8,048 views

Published on

Additional tech report will be published at CEDEC Digital library (CEDiL).

Published in: Technology
  • Be the first to comment

Introduction to Bidirectional Path Tracing (BDPT) & Implementation using OpenCL (CEDEC 2015)

  1. 1. INTRODUCTION  TO  BIDIRECTIONAL  PATH  TRACING     &  ITS  IMPLEMENTATION  USING  OPENCL     双方向パストレーシング(BDPT)の基礎からOPENCLによる実装まで   TAKAHIRO  HARADA          (AMD)   SHO  IKEDA  (RICOH)   SYOYO  FUJITA            (LTE)  
  2. 2. 2   |      OPENCL  BDPT    |    AUGUST  28,  2015    |      HARADA,  IKEDA,  FUJITA   OVERVIEW  OF  THIS  TALK   y  IntroducJon  (Harada,  20min  -­‐  25min)   ‒ Start  with  path  tracing  review   ‒ Transforming  path  tracing  to  bidirecJonal  path  tracing   y  BidirecJonal  Path  Tracing  (Ikeda,  20min  -­‐  25min)   ‒ Classic  BDPT   ‒ Instant  BDPT   ‒ Lvc  BDPT   y  IntegraJon  of  BidirecJonal  Path  Tracing  to  the  Engine  (Harada,  5min)   y  Examples  (Harada,  5min)  
  3. 3. 3   |      OPENCL  BDPT    |    AUGUST  28,  2015    |      HARADA,  IKEDA,  FUJITA   PATH  TRACING  (MONTE  CARLO  RAY  TRACING)   y  !=  Raster  graphics  (game)   y  BeauJful  rendering   y  Global  illuminaJon  
  4. 4. 4   |      OPENCL  BDPT    |    AUGUST  28,  2015    |      HARADA,  IKEDA,  FUJITA   PATH  TRACING  (MONTE  CARLO  RAY  TRACING)   y  ComputaJonally  expensive   ‒ Take  Jme  to  converge   ‒ Noisy  at  first,  gebng  cleaner  later   y  Make  1  step  rendering  faster   ‒ Total  Jme  decreases   ‒ OpJmizaJon  (using  more  CPU  cores,  GPUs)   ‒  OpenCL  (my  talk@CEDEC2014)   y  Make  1  step  less  noisy   ‒ Need  less  steps   ‒ Beeer  sampling  techniques   ‒ Clever  algorithm   ‒  BDPT  (this  talk)  
  5. 5. PATH  TRACING   IMPORTANCE  SAMPLING   MULTIPLE  IMPORTANCE  SAMPLING  
  6. 6. 6   |      OPENCL  BDPT    |    AUGUST  28,  2015    |      HARADA,  IKEDA,  FUJITA   FIRST  PATH  TRACING  
  7. 7. 7   |      OPENCL  BDPT    |    AUGUST  28,  2015    |      HARADA,  IKEDA,  FUJITA   PATH  TRACING  IMPLEMENTATION  #1   for(int i=0; i<nx; i++) for(int j=0; j<ny; j++)! {! Ray ray = genPrimaryRay( i, j );! ! float4 coeff = 1.f;! float4& output = pixel[i,j];! for(int depth=0; depth<maxDepth; depth++)! {! Hit hit = intersect( ray );! if( !hit.hasHit() ) break;! ! if( hit.isEmissive() )! {// Implicit Connection! output += coeff * getEmission( hit );! break;! }! ! ray, f, pdf = randomSample( hit );! coeff *= f * dot( hit.m_n, ray.m_dir ) / pdf;! }! }!  
  8. 8. 8   |      OPENCL  BDPT    |    AUGUST  28,  2015    |      HARADA,  IKEDA,  FUJITA   SAMPLING  NEXT  RAY   y  For  non  transmission  surface,  no  need  to   sample  the  other  side   RANDOM  SAMPLING   for(int i=0; i<nx; i++) for(int j=0; j<ny; j++)! {! Ray ray = genPrimaryRay( i, j );! ! float4 coeff = 1.f;! float4& output = pixel[i,j];! for(int depth=0; depth<maxDepth; depth++)! {! Hit hit = intersect( ray );! if( !hit.hasHit() ) break;! ! if( hit.isEmissive() )! {// Implicit Connection! output += coeff * getEmission( hit );! break;! }! ! ray, f, pdf = randomSample( hit );! coeff *= f * dot( hit.m_n, ray.m_dir ) / pdf;! }! }!  
  9. 9. 9   |      OPENCL  BDPT    |    AUGUST  28,  2015    |      HARADA,  IKEDA,  FUJITA   SAMPLING  NEXT  RAY   y  Random  sampling  is  not  always  efficient   ‒ Diffuse  surface  =>  OK   ‒ Glossy  surface  =>  Hmm  L   ‒ Specular  surface  =>  Bad  L   y  We  usually  know  the  reflecJon  characterisJcs  about  surface   ‒ Why  not  use  them?   ‒ “Importance  sampling”  (BRDF)   RANDOM  SAMPLING    
  10. 10. 10   |      OPENCL  BDPT    |    AUGUST  28,  2015    |      HARADA,  IKEDA,  FUJITA   IMPORTANCE  SAMPLING  (BRDF)   y  Specular  surface   ‒ Only  reflect  in  the  mirrored  direcJon   ‒ Always  sample  the  direcJon  (pdf  =  1)   y  Glossy  surface   ‒ Mostly  reflect  around  mirrored  direcJon   ‒ Sample  around  the  mirrored  direcJon   Specular  (R)   Glossy   Mae  Specular  (T)  
  11. 11. 11   |      OPENCL  BDPT    |    AUGUST  28,  2015    |      HARADA,  IKEDA,  FUJITA   PATH  TRACING  IMPLEMENTATION  #2   for(int i=0; i<nx; i++) for(int j=0; j<ny; j++)! {! Ray ray = genPrimaryRay( i, j );! ! float4 coeff = 1.f;! float4& output = pixel[i,j];! for(int depth=0; depth<maxDepth; depth++)! {! Hit hit = intersect( ray );! if( !hit.hasHit() ) break;! ! if( hit.isEmissive() )! {// Implicit Connection! output += coeff * getEmission( hit );! break;! }! ! ray, f, pdf = randomSample( hit );! coeff *= f * dot( hit.m_n, ray.m_dir ) / pdf;! }! }!   for(int i=0; i<nx; i++) for(int j=0; j<ny; j++)! {! Ray ray = genPrimaryRay( i, j );! ! float4 coeff = 1.f;! float4& output = pixel[i,j];! for(int depth=0; depth<maxDepth; depth++)! {! Hit hit = intersect( ray );! if( !hit.hasHit() ) break;! ! if( hit.isEmissive() )! {// Implicit Connection! output += coeff * getEmission( hit );! break;! }! ! ray, f, pdf = brdfSample( hit );! coeff *= f * dot( hit.m_n, ray.m_dir ) / pdf;! }! }!   Random  Sampling   Brdf  Importance  Sampling  
  12. 12. 12   |      OPENCL  BDPT    |    AUGUST  28,  2015    |      HARADA,  IKEDA,  FUJITA   PATH  TRACING  IMPLEMENTATION  #2   for(int i=0; i<nx; i++) for(int j=0; j<ny; j++)! {! Ray ray = genPrimaryRay( i, j );! ! float4 coeff = 1.f;! float4& output = pixel[i,j];! for(int depth=0; depth<maxDepth; depth++)! {! Hit hit = intersect( ray );! if( !hit.hasHit() ) break;! ! if( hit.isEmissive() )! {// Implicit Connection! output += coeff * getEmission( hit );! break;! }! ! ray, f, pdf = randomSample( hit );! coeff *= f * dot( hit.m_n, ray.m_dir ) / pdf;! }! }!   for(int i=0; i<nx; i++) for(int j=0; j<ny; j++)! {! Ray ray = genPrimaryRay( i, j );! ! float4 coeff = 1.f;! float4& output = pixel[i,j];! for(int depth=0; depth<maxDepth; depth++)! {! Hit hit = intersect( ray );! if( !hit.hasHit() ) break;! ! if( hit.isEmissive() )! {// Implicit Connection! output += coeff * getEmission( hit );! break;! }! ! ray, f, pdf = brdfSample( hit );! coeff *= f * dot( hit.m_n, ray.m_dir ) / pdf;! }! }!   Random  Sampling   Brdf  Importance  Sampling  
  13. 13. 13   |      OPENCL  BDPT    |    AUGUST  28,  2015    |      HARADA,  IKEDA,  FUJITA   INEFFICIENT  CASE   y  Rough  surface  +  Small  light   y  Brdf  sampling  rarely  hits  the  light   y  SoluJon   ‒ We  know  where  the  lights  are   ‒ Why  ignoring??   ‒ Generate  ray  from  lights   ‒ “Importance  sampling”  (Light)   Rough   Reference  Brdf  sampling  
  14. 14. 14   |      OPENCL  BDPT    |    AUGUST  28,  2015    |      HARADA,  IKEDA,  FUJITA   INEFFICIENT  CASE   y  Rough  surface  +  Small  light   y  Brdf  sampling  rarely  hits  the  light   y  SoluJon   ‒ We  know  where  the  lights  are   ‒ Why  ignoring??   ‒ Generate  ray  from  lights   ‒ “Importance  sampling”  (Light)   Rough   Reference  Brdf  sampling  Light  sampling  
  15. 15. 15   |      OPENCL  BDPT    |    AUGUST  28,  2015    |      HARADA,  IKEDA,  FUJITA   PATH  TRACING  IMPLEMENTATION  #3   for(int i=0; i<nx; i++) for(int j=0; j<ny; j++)! {! Ray ray = genPrimaryRay( i, j );! ! float4 coeff = 1.f;! float4& output = pixel[i,j];! for(int depth=0; depth<maxDepth; depth++)! {! Hit hit = intersect( ray );! if( !hit.hasHit() ) break;! ! if( hit.isEmissive() )! {// Implicit Connection! output += coeff * getEmission( hit );! break;! }! ! ray, f, pdf = brdfSample( hit );! coeff *= f * dot( hit.m_n, ray.m_dir ) / pdf;! }! }!   for(int i=0; i<nx; i++) for(int j=0; j<ny; j++)! {! Ray ray = genPrimaryRay( i, j );! ! float4 coeff = 1.f;! float4& output = pixel[i,j];! for(int depth=0; depth<maxDepth; depth++)! {! Hit hit = intersect( ray );! if( !hit.hasHit() ) break;! {// Explicit Connection! ray, pdf = lightSample( hit );! Hit hit1 = intersect( ray );! if( !hit1.hasHit() )! {! output+=coeff*getEmission( hit1 )/pdf;! }! }! ray, f, pdf = brdfSample( hit );! coeff *= f * dot( hit.m_n, ray.m_dir ) / pdf;! }! }!   Brdf  Importance  Sampling   Light  Importance  Sampling  
  16. 16. 16   |      OPENCL  BDPT    |    AUGUST  28,  2015    |      HARADA,  IKEDA,  FUJITA   IMPLICIT  CONNECTION,  EXPLICIT  CONNECTION   y  Implicit  ConnecJon   ‒ A  ray  accidentally  hit  a  light  source   ‒  Ater  primary  rays  are  generated  from  camera   ‒  Ater  bounced  rays  are  sampled  from  BRDF   y  Explicit  ConnecJon   ‒ A  path  is  intenJonally  connected  to  a  light  source   ‒  Direct  illuminaJon  (sample  a  vertex  on  a  light  source)   Camera Light Object Camera Light Object
  17. 17. 17   |      OPENCL  BDPT    |    AUGUST  28,  2015    |      HARADA,  IKEDA,  FUJITA   PATH  TRACING  IMPLEMENTATION  #3   y  We  should  not  accumulaJng  implicit  hits  for  this  implementaBon   y  Even  if  a  ray  hits  an  emissive  surface,  we  ignore  it   y  Sounds  like  we  are  wasJng  something   NOTE  
  18. 18. 18   |      OPENCL  BDPT    |    AUGUST  28,  2015    |      HARADA,  IKEDA,  FUJITA   BRDF  SAMPLING  +  LIGHT  SAMPLING   y  Both  generate  image   ‒ Each  technique  has  strong  &  weak  points   ‒ Converges  to  the  same  image  at  the  end   Brdf  sampling  (16spp)   Light  sampling  (16spp)   Brdf  sampling  (inf. spp)   Light  sampling  (inf. spp)   =  
  19. 19. 19   |      OPENCL  BDPT    |    AUGUST  28,  2015    |      HARADA,  IKEDA,  FUJITA   PATH  TRACING  IMPLEMENTATION  #3   y  We  should  not  accumulaJng  implicit  hits  for  this  implementaBon   y  Even  if  a  ray  hits  an  emissive  surface,  we  ignore  it   y  Sounds  like  we  are  wasJng  something   y  Can  we  use  it  somehow?   NOTE  
  20. 20. 20   |      OPENCL  BDPT    |    AUGUST  28,  2015    |      HARADA,  IKEDA,  FUJITA   BRDF  SAMPLING  +  LIGHT  SAMPLING   y  Then  simply…  Take  an  average?   ‒ Works   ‒  but  not  the  best   y  We  can  set  any  coefficients  if  they  sum  up  to  1.0   ‒ brdfSampledImage  *  0.2  +  lightSampledImage  *  0.8  ?   ‒ brdfSampledImage  *  0.8  +  lightSampledImage  *  0.2  ?   ‒ Hmm…   x  0.5  +     x  0.5     Brdf  sample   Light  sample   x  0.2  +     x  0.8     Brdf  sample   Light  sample  
  21. 21. 21   |      OPENCL  BDPT    |    AUGUST  28,  2015    |      HARADA,  IKEDA,  FUJITA   J  L   COMPARING  BRDF  SAMPLING  AND  LIGHT  SAMPLING   y  Light  sampling   ‒ Good  for  rough  surface   ‒ Bad  for  sharp  surface   y  Brdf  sampling   ‒ Bad  for  rough  surface   ‒ Good  for  sharp  surface   L  J  
  22. 22. 22   |      OPENCL  BDPT    |    AUGUST  28,  2015    |      HARADA,  IKEDA,  FUJITA   BRDF  SAMPLING  +  LIGHT  SAMPLING   y  Then  simply…  Take  an  average?   ‒ Works   ‒  but  not  the  best   y  We  can  set  any  coefficients  if  they  sum  up  to  1.0   ‒ brdfSampledImage  *  0.2  +  lightSampledImage  *  0.8  ?   ‒ brdfSampledImage  *  0.8  +  lightSampledImage  *  0.2  ?   ‒ Hmm   y  We  do  not  have  to  se  the  same  coefficients  for  all  the  pixels  J   ‒ “MulJple  importance  sampling”   ‒ Per  pixel  weight   x  0.5  +     x  0.5     Brdf  sample   Light  sample   x  0.2  +     x  0.8     Brdf  sample   Light  sample   x   +   x   =   Brdf  sample   Light  sample  w_b   w_l   MIS  
  23. 23. 23   |      OPENCL  BDPT    |    AUGUST  28,  2015    |      HARADA,  IKEDA,  FUJITA   BRDF  SAMPLING  +  LIGHT  SAMPLING   y  Uniform  weighJng  (Average)   y  Per  pixel  weighJng  (MulJple  Importance  Sampling,  MIS)   VISUALIZATION  OF  MIS   x   +   x   =   Brdf  sample   Light  sample  w_b   w_l   MIS   +   =  1.0   w_b   w_l   x   +   x   =   Brdf  sample   Light  sample  w_b   w_l   Average   0.5   0.5   0.5   0.5  +   =  1.0   w_b   w_l  
  24. 24. 24   |      OPENCL  BDPT    |    AUGUST  28,  2015    |      HARADA,  IKEDA,  FUJITA   MULTIPLE  IMPORTANCE  SAMPLING   y  Light  sampling   y  Brdf  sampling   0.1  0.9   0.9  0.1   0.5   0.5  
  25. 25. 25   |      OPENCL  BDPT    |    AUGUST  28,  2015    |      HARADA,  IKEDA,  FUJITA   MULTIPLE  IMPORTANCE  SAMPLING  WEIGHT   y  Detailed  look  at  brdf  &  light  sampling  (direct  illuminaJon)   y  Possible  to  sample  the  same  direcJon  using  both  sampling  technique   ‒ Only  difference  is  the  PDF  (probability  density  funcJon)   y  Rough  surface   ‒ PDF  of  Brdf  sampling  is  almost  uniform   ‒  Low  confidence  in  the  sample  =>  Higher  noise   ‒ PDF  of  light  sampling  has  a  strong  spike  at  light  direcJon   ‒  High  confidence  in  the  sample    =>  Lower  noise   Brdf  Sampling   Light  Sampling  
  26. 26. 26   |      OPENCL  BDPT    |    AUGUST  28,  2015    |      HARADA,  IKEDA,  FUJITA   MULTIPLE  IMPORTANCE  SAMPLING  WEIGHT   y  Detailed  look  at  brdf  &  light  sampling  (direct  illuminaJon)   y  Possible  to  sample  the  same  direcJon  using  both  sampling  technique   ‒ Only  difference  is  the  PDF  (probability  density  funcJon)   y  Sharp  surface   ‒ PDF  of  Brdf  sampling  is  almost  uniform   ‒  Very  high  confidence  in  the  sample  =>  Lower  noise   ‒ PDF  of  light  sampling  has  a  strong  spike  at  light  direcJon   ‒  RelaJvely  lower  confidence  in  the  sample    =>  Higher  noise   Brdf  Sampling   Light  Sampling  
  27. 27. 27   |      OPENCL  BDPT    |    AUGUST  28,  2015    |      HARADA,  IKEDA,  FUJITA   MULTIPLE  IMPORTANCE  SAMPLING  WEIGHT   y  Use  sampling  PDF  to  compute  weight   y  Weight  for  light  sample  (Explicit  hit)           y  Weight  for  brdf  sample  (Implicit  hit)     y  This  is  very  important  for  an  efficient  BDPT  
  28. 28. 28   |      OPENCL  BDPT    |    AUGUST  28,  2015    |      HARADA,  IKEDA,  FUJITA   PATH  TRACING  IMPLEMENTATION  #4  (FINAL)   for(int i=0; i<nx; i++) for(int j=0; j<ny; j++)! {! Ray ray = genPrimaryRay( i, j );! ! float4 coeff = 1.f;! float4& output = pixel[i,j];! float pdfb = 0.f;! for(int depth=0; depth<maxDepth; depth++)! {! Hit hit = intersect( ray );! if( !hit.hasHit() ) break;! if( hit.isEmissive() )! {// Implicit Connection! pdfl = lightPdf( hit );! w = pdfb / (pdfb + pdfl);! output += coeff * getEmission( hit ) * w;! break;! }! {// Explicit Connection! ray, pdfl = lightSample( hit );! Hit hit1 = intersect( ray );! if( !hit1.hasHit() )! {! w = pdfl / (pdfb + pdfl);! output += coeff * getEmission( hit1 ) * w / pdfl;! }! }! ray, f, pdfb = brdfSample( hit );! coeff *= f * dot( hit.m_n, nextRay.m_dir ) / pdfb;! }! }!  
  29. 29. BEYOND  PATH  TRACING  
  30. 30. 30   |      OPENCL  BDPT    |    AUGUST  28,  2015    |      HARADA,  IKEDA,  FUJITA   OUTDOOR  
  31. 31. 31   |      OPENCL  BDPT    |    AUGUST  28,  2015    |      HARADA,  IKEDA,  FUJITA   INDOOR/OUTDOOR  
  32. 32. 32   |      OPENCL  BDPT    |    AUGUST  28,  2015    |      HARADA,  IKEDA,  FUJITA   INDOOR  
  33. 33. 33   |      OPENCL  BDPT    |    AUGUST  28,  2015    |      HARADA,  IKEDA,  FUJITA   PATH  TRACING  IS  NOT  PERFECT   y  Path  tracing  is  really  good  at  an out  door  scene   y  But  not  for  a  scene  mostly  lit  by  indirect  illuminaJon  (indoor,  day  Jme)  
  34. 34. 34   |      OPENCL  BDPT    |    AUGUST  28,  2015    |      HARADA,  IKEDA,  FUJITA   PATH  TRACING  IS  NOT  PERFECT   64  spp   256  spp   1024  spp   x  4   x  4  Indoor  Indoor/outdoor  Outdoor   Good   Ok   Bad   Path  Tracing  is..  
  35. 35. 35   |      OPENCL  BDPT    |    AUGUST  28,  2015    |      HARADA,  IKEDA,  FUJITA   BAD  CONVERGENCE  FOR  INDOOR  SCENE   y  Ray  needs  to  be  bounced  more  than  once   before  connecJng  to  the  light  source   y  As  we  bounce,  we  get  less  &  less  confident   about  the  path   ‒ Lower  probability  =>  More  noise  
  36. 36. 36   |      OPENCL  BDPT    |    AUGUST  28,  2015    |      HARADA,  IKEDA,  FUJITA   LIGHT  TRACING   y  If  traced  from  the  light,  it  is  beeer  (more  confident)   y  Path  Tracing   y  Light  Tracing   Camera Light Object Camera Light Object Path  Tracing   BDPT  
  37. 37. 37   |      OPENCL  BDPT    |    AUGUST  28,  2015    |      HARADA,  IKEDA,  FUJITA   PATH  TRACING  +  1  LIGHT  PATH   y  Can  we  mix  path  tracing  &  light  tracing   ‒ Trace  1  light  path   ‒ Connect  to  camera  path   Camera Light Object
  38. 38. 38   |      OPENCL  BDPT    |    AUGUST  28,  2015    |      HARADA,  IKEDA,  FUJITA   PATH  TRACING  +  1  LIGHT  PATH   y  Can  we  mix  path  tracing  &  light  tracing   ‒ Trace  1  light  path   ‒ Connect  to  camera  path   y  Improves  some  situaJons  (not  all)   ‒ Example.  A  room  is  lit  by  bounced  light   y  Can  we  trace  more  than  1  light  path,  and  combine?   ‒ =>  BidirecJonal  Path  Tracing   Camera Light Object Path  Tracing   Path  Trace  +  1  light  path   64  spp  
  39. 39. BDPT  
  40. 40. Bi-Directional Path Tracing (BDPT) Camera path Light path Connection Camera Light Object •  BDPT traces paths from the camera and the light source
 •  BDPT combines various path sampling strategies
  41. 41. Bi-Directional Path Tracing (BDPT) Camera path Light path Connection Camera Light Object •  BDPT traces paths from the camera and the light source
 •  BDPT combines various path sampling strategies
  42. 42. Bi-Directional Path Tracing (BDPT) Camera path Light path Connection Camera Light Object •  BDPT traces paths from the camera and the light source
 •  BDPT combines various path sampling strategies
  43. 43. Bi-Directional Path Tracing (BDPT) Camera path Light path Connection Camera Light Object •  BDPT traces paths from the camera and the light source
 •  BDPT combines various path sampling strategies
  44. 44. BDPT I = w0 w1 + + … wk · · · x0 xk •  The contributions of the sampling strategies are weighted
  45. 45. BDPT + Multiple Importance Sampling (MIS) Xs = x0, · · · xs + xs+1, · · · xk x0 xk xs xs+1 •  MIS weight computation ws(X) = ps(X) Pk i=0 pi(X)
  46. 46. x0 xk xs xs+1 Xs = x0, · · · xs + xs+1, · · · xk ps(X) = !p 0 · !p 1 · · · !p s · p s+1 · · · p k 1 · p k BDPT + Multiple Importance Sampling (MIS) (2 The product of the pdfs of the path sampling
  47. 47. The problem of BDPT on GPU implementation 0 1 2 3Global Memory 0 1 2 •  BDPT stores all the vertices on the camera and light paths
 •  The global memory consumption is high
  48. 48. 0 1 2 3Global Memory 0 1 2 •  BDPT stores all the vertices on the camera and light paths
 •  The global memory consumption is high The problem of BDPT on GPU implementation
  49. 49. 0 1 2 3Global Memory 0 1 2 •  BDPT stores all the vertices on the camera and light paths
 •  The global memory consumption is high The problem of BDPT on GPU implementation
  50. 50. 0 1 2 3Global Memory 0 1 2 •  BDPT stores all the vertices on the camera and light paths
 •  The global memory consumption is high The problem of BDPT on GPU implementation
  51. 51. p  Instant BDPT
 p  Lvc BDPT BDPT algorithm with low memory consumption
  52. 52. Instant BDPT Implicit view ( ) path Explicit view ( ) path Implicit light ( ) path Explicit light ( ) path VI VE LE LI •  Path sampling strategies are limited to 4 (PT and LT)
 •  Low memory consumption
 •  If the camera has no collision detection, 3 sampling strategies
  53. 53. Instant BDPT + MIS Explicit view ( ) path VE wVE (X) = pVE (X) pVE (X) + pVI (X) + pLE (X) 1 wVE (X) = 1 + pVI (X) pVE (X) + pLE (X) pVE (X)
  54. 54. Instant BDPT + MIS (2 1 wVE (X) = 1 + pVI (X) pVE (X) + pLE (X) pVE (X) pVI (X) pVE (X) = !p k 1 p k+1 !p k 1 p k+1
  55. 55. Instant BDPT + MIS (3 1 wVE (X) = 1 + pVI (X) pVE (X) + pLE (X) pVE (X) x0 xk s0 = 1 P(x 1 ! x0 ! x1) pLE (X) pVE (X) = s0s1 · · · sk x1
  56. 56. Instant BDPT + MIS (3 1 wVE (X) = 1 + pVI (X) pVE (X) + pLE (X) pVE (X) x0 xk s1 = 1 P(x0 ! x1 ! x2)G(x0 $ x1) pLE (X) pVE (X) = s0s1 · · · sk x1
  57. 57. Instant BDPT + MIS (3 1 wVE (X) = 1 + pVI (X) pVE (X) + pLE (X) pVE (X) x0 xk pLE (X) pVE (X) = s0s1 · · · sk sk = P(xk 1 xk xk+1)G(xk 1 $ xk) x1
  58. 58. Instant BDPT OpenCL implementation
  59. 59. Instant BDPT : Bad case1 x0 xk
  60. 60. x0 xk Instant BDPT : Bad case1
  61. 61. x0 xk Instant BDPT : Bad case1
  62. 62. x0 xk Instant BDPT : Bad case1
  63. 63. x0 xk Specular Instant BDPT : Bad case
  64. 64. x0 xk Specular Instant BDPT : Bad case
  65. 65. x0 xk Specular Instant BDPT : Bad case
  66. 66. x0 xk Specular Instant BDPT : Bad case
  67. 67. p  Instant BDPT
 p  Lvc BDPT BDPT algorithm with low memory consumption
  68. 68. Lvc BDPT light vertex cache 0 1 2 3Light Vertex Cache •  Light vertex cache •  Recursive MIS
  69. 69. Lvc BDPT light vertex cache 0 1 2 3Light Vertex Cache •  Light vertex cache •  Recursive MIS
  70. 70. Lvc BDPT light vertex cache 0 1 2 3Light Vertex Cache •  Light vertex cache •  Recursive MIS
  71. 71. Lvc BDPT light vertex cache 0 1 2 3Light Vertex Cache •  Light vertex cache •  Recursive MIS
 •  LvcBDPT doesn’t have the global memory for the camera path
  72. 72. Recursive MIS x0 xk xs ws(X) = ps(X) Pk i=0 pi(X) 1 ws(X) = Pk i=0 pi(X) ps(X) p s+1 · dE s + 1 + !p s · dL s+1=
  73. 73. 1 ws(X) = p s+1 · dE s + 1 + !p s · dL s+1 dE 1 = 1 !p 0 dE s = 1 + p sdE s 1 !p s 1 dL k = 1 p k+1 Recursive MIS x0 xk xs dL s+1 = 1 + !p s+1 · dL s+2 p s+2
  74. 74. 1 ws(X) = p s+1 · dE s + 1 + !p s · dL s+1 Lvc BDPT + Recursive MIS x0 xk xs dE 1 = 1 !p 0
  75. 75. 1 ws(X) = p s+1 · dE s + 1 + !p s · dL s+1 x0 xk xs dE s = 1 + p sdE s 1 !p s 1 Lvc BDPT + Recursive MIS
  76. 76. 1 ws(X) = p s+1 · dE s + 1 + !p s · dL s+1 x0 xk xs dE s = 1 + p sdE s 1 !p s 1 dL k = 1 p k+1 Lvc BDPT + Recursive MIS
  77. 77. 1 ws(X) = p s+1 · dE s + 1 + !p s · dL s+1 x0 xk xs dE s = 1 + p sdE s 1 !p s 1 dL k 1 = 1 + !p k 1 · dL k p k Lvc BDPT + Recursive MIS
  78. 78. 1 ws(X) = p s+1 · dE s + 1 + !p s · dL s+1 x0 xk xs dE s = 1 + p sdE s 1 !p s 1 dL s+1 = 1 + !p s+1 · dL s+2 p s+2 Lvc BDPT + Recursive MIS
  79. 79. Lvc BDPT OpenCL implementation
  80. 80. InstantBDPT LvcBDPT
  81. 81. InstantBDPT LvcBDPT
  82. 82. InstantBDPT LvcBDPT
  83. 83. INTEGRATION  TO  THE   ENGINE  
  84. 84. 84   |      OPENCL  BDPT    |    AUGUST  28,  2015    |      HARADA,  IKEDA,  FUJITA   Back  End   World  GPU  (OCL)   -­‐  Path  Tracing   -­‐  Light  Tracing   -­‐      -­‐      World  CPU   -­‐  Path  Tracing  (OpJmized)   Front  End   ENGINE  ARCHITECTURE  OVERVIEW   Data  Loader   -­‐  Obj   -­‐  Eson   -­‐  Fbx   Data  Manager   -­‐  Texture   -­‐  Material   -­‐  Mesh   Tahoe  API   Texture  Loader   -­‐  Png   -­‐  Hdr   -­‐  OpenExr   -­‐  …   Factory  (CPU)   Camera   -­‐  PerspecJve   -­‐  Parallel   -­‐  Bake   -­‐  VR   Material  System   -­‐  Default   -­‐  Graph   -­‐  OSL   Light  Sampler   -­‐  Uniform   -­‐  Group   -­‐  StochasJc   Factory  (OCL)  
  85. 85. 85   |      OPENCL  BDPT    |    AUGUST  28,  2015    |      HARADA,  IKEDA,  FUJITA   Back  End   World  GPU  (OCL)   -­‐  Path  Tracing   -­‐  Light  Tracing   -­‐  BidirecJonal  Path  Tracing  (LvcBDPT)   -­‐  BidirecJonal  Path  Tracing  (InstantBDPT)   World  CPU   -­‐  Path  Tracing  (OpJmized)   Front  End   ENGINE  ARCHITECTURE  OVERVIEW   Data  Loader   -­‐  Obj   -­‐  Eson   -­‐  Fbx   Data  Manager   -­‐  Texture   -­‐  Material   -­‐  Mesh   Tahoe  API   Texture  Loader   -­‐  Png   -­‐  Hdr   -­‐  OpenExr   -­‐  …   Factory  (CPU)   Camera   -­‐  PerspecJve   -­‐  Parallel   -­‐  Bake   -­‐  VR   Material  System   -­‐  Default   -­‐  Graph   -­‐  OSL   Light  Sampler   -­‐  Uniform   -­‐  Group   -­‐  StochasJc   Factory  (OCL)  
  86. 86. 86   |      OPENCL  BDPT    |    AUGUST  28,  2015    |      HARADA,  IKEDA,  FUJITA   PATH  TRACING  CODE   y  Not  employing  a  mega  kernel  implementaJon   y  There  are  many  small  kernels  for  path  tracing   ‒ Easier  to  debug   ‒ Performance   ‒ Extendibility  =>  Key  to  add  BDPT   y  (See  my  slides  @  CEDEC  2014)  
  87. 87. 87   |      OPENCL  BDPT    |    AUGUST  28,  2015    |      HARADA,  IKEDA,  FUJITA   PATH  TRACING  KERNELS   y  Prepare   ‒ Camera  ray  set  up   y  Loop   ‒ Ray  cast   ‒ Implicit  hit  accumulaJon   ‒ Material  prepare   ‒ Shadow  ray  set  up   ‒ Material  evaluaJon   ‒ Ray  cast   ‒ Explicit  hit  accumulaJon   ‒ Sample  next  ray   Path  Tracing   Each  line  is  one  or  more  OCL  kernels  
  88. 88. 88   |      OPENCL  BDPT    |    AUGUST  28,  2015    |      HARADA,  IKEDA,  FUJITA   INSTANT  BDPT   y  Prepare   ‒ Set  up  camera  ray   ‒ Sample  light  point   y  Loop   ‒ Ray  cast   ‒ Material  prepare  (sampleBrdf)   ‒ Implicit  connecJon   ‒ Explicit  connecJon  to  light   ‒  Make  shadow  ray   ‒  Ray  cast   ‒  Connect  to  light   ‒ Sample  next  ray   ‒ Update  MIS  weight  term   Trace  Light  Path   Trace  Camera  Path   Orange:  New  kernels  wrieen  for  BDPT   White    :  Using  path  tracing  kernels  
  89. 89. 89   |      OPENCL  BDPT    |    AUGUST  28,  2015    |      HARADA,  IKEDA,  FUJITA   INSTANT  BDPT   y  Prepare   ‒ Set  up  light  ray   ‒ Sample  lens  point   ‒ Explicit  connecJon  light  to  camera   y  Loop   ‒ Ray  cast   ‒ Material  prepare  (sampleBrdf)   ‒ Explicit  connecJon  to  camera   ‒  Make  shadow  ray   ‒  Ray  cast   ‒  Set  pixel  index   ‒  Connect  to  camera   ‒ Sample  next  ray   ‒ Update  MIS  weight  term   y  Prepare   ‒ Set  up  camera  ray   ‒ Sample  light  point   y  Loop   ‒ Ray  cast   ‒ Material  prepare  (sampleBrdf)   ‒ Implicit  connecJon   ‒ Explicit  connecJon  to  light   ‒  Make  shadow  ray   ‒  Ray  cast   ‒  Connect  to  light   ‒ Sample  next  ray   ‒ Update  MIS  weight  term   Trace  Light  Path   Trace  Camera  Path   Orange:  New  kernels  wrieen  for  BDPT   White    :  Using  path  tracing  kernels  
  90. 90. 90   |      OPENCL  BDPT    |    AUGUST  28,  2015    |      HARADA,  IKEDA,  FUJITA   LVCBDPT   y  More  complicated  than  Instant  BDPT   y  ImplementaJon  is  not  that  far  from  Instant  BDPT  
  91. 91. EXAMPLES  
  92. 92. 92   |      OPENCL  BDPT    |    AUGUST  28,  2015    |      HARADA,  IKEDA,  FUJITA   BDPT   PT  
  93. 93. 93   |      OPENCL  BDPT    |    AUGUST  28,  2015    |      HARADA,  IKEDA,  FUJITA   BDPT   PT  
  94. 94. 94   |      OPENCL  BDPT    |    AUGUST  28,  2015    |      HARADA,  IKEDA,  FUJITA   BDPT   PT  
  95. 95. 95   |      OPENCL  BDPT    |    AUGUST  28,  2015    |      HARADA,  IKEDA,  FUJITA   CLOSING   y  References   ‒ AddiJonal  note   ‒  To  be  published  in  CEDEC  library   ‒  Detailed  explanaJon  of  Instant  BDPT,  Lvc  BDPT   ‒ CEDEC  2013   ‒  hep://www.slideshare.net/takahiroharada/introducJon-­‐to-­‐monte-­‐carlo-­‐ray-­‐tracing-­‐cedec2013   ‒ CEDEC  2014   ‒  hep://www.slideshare.net/takahiroharada/introducJon-­‐to-­‐monte-­‐carlo-­‐ray-­‐tracing-­‐opencl-­‐implementaJon-­‐cedec-­‐2014   y  Feedback  is  welcome   ‒ For  next  years  presentaJon  
  96. 96. 96   |      OPENCL  BDPT    |    AUGUST  28,  2015    |      HARADA,  IKEDA,  FUJITA   NON  SYMMETRIC  BRDF   Without  Fix   With  Fix  
  97. 97. 97   |      OPENCL  BDPT    |    AUGUST  28,  2015    |      HARADA,  IKEDA,  FUJITA   NON  SYMMETRIC  BRDF   With  Fix   With  Fix  

×