ambient_occlusion.h 2.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980
  1. // This file is part of libigl, a simple c++ geometry processing library.
  2. //
  3. // Copyright (C) 2015 Alec Jacobson <alecjacobson@gmail.com>
  4. //
  5. // This Source Code Form is subject to the terms of the Mozilla Public License
  6. // v. 2.0. If a copy of the MPL was not distributed with this file, You can
  7. // obtain one at http://mozilla.org/MPL/2.0/.
  8. #ifndef IGL_AMBIENT_OCCLUSION_H
  9. #define IGL_AMBIENT_OCCLUSION_H
  10. #include "igl_inline.h"
  11. #include "AABB.h"
  12. #include <Eigen/Core>
  13. #include <functional>
  14. namespace igl
  15. {
  16. // Compute ambient occlusion per given point
  17. //
  18. // Inputs:
  19. // shoot_ray function handle that outputs hits of a given ray against a
  20. // mesh (embedded in function handles as captured variable/data)
  21. // P #P by 3 list of origin points
  22. // N #P by 3 list of origin normals
  23. // Outputs:
  24. // S #P list of ambient occlusion values between 1 (fully occluded) and
  25. // 0 (not occluded)
  26. //
  27. template <
  28. typename DerivedP,
  29. typename DerivedN,
  30. typename DerivedS >
  31. IGL_INLINE void ambient_occlusion(
  32. const std::function<
  33. bool(
  34. const Eigen::Vector3f&,
  35. const Eigen::Vector3f&)
  36. > & shoot_ray,
  37. const Eigen::PlainObjectBase<DerivedP> & P,
  38. const Eigen::PlainObjectBase<DerivedN> & N,
  39. const int num_samples,
  40. Eigen::PlainObjectBase<DerivedS> & S);
  41. // Inputs:
  42. // AABB axis-aligned bounding box hierarchy around (V,F)
  43. template <
  44. typename DerivedV,
  45. int DIM,
  46. typename DerivedF,
  47. typename DerivedP,
  48. typename DerivedN,
  49. typename DerivedS >
  50. IGL_INLINE void ambient_occlusion(
  51. const igl::AABB<DerivedV,DIM> & aabb,
  52. const Eigen::PlainObjectBase<DerivedV> & V,
  53. const Eigen::PlainObjectBase<DerivedF> & F,
  54. const Eigen::PlainObjectBase<DerivedP> & P,
  55. const Eigen::PlainObjectBase<DerivedN> & N,
  56. const int num_samples,
  57. Eigen::PlainObjectBase<DerivedS> & S);
  58. // Inputs:
  59. // V #V by 3 list of mesh vertex positions
  60. // F #F by 3 list of mesh face indices into V
  61. template <
  62. typename DerivedV,
  63. typename DerivedF,
  64. typename DerivedP,
  65. typename DerivedN,
  66. typename DerivedS >
  67. IGL_INLINE void ambient_occlusion(
  68. const Eigen::PlainObjectBase<DerivedV> & V,
  69. const Eigen::PlainObjectBase<DerivedF> & F,
  70. const Eigen::PlainObjectBase<DerivedP> & P,
  71. const Eigen::PlainObjectBase<DerivedN> & N,
  72. const int num_samples,
  73. Eigen::PlainObjectBase<DerivedS> & S);
  74. };
  75. #ifndef IGL_STATIC_LIBRARY
  76. # include "ambient_occlusion.cpp"
  77. #endif
  78. #endif