ambient_occlusion.h 2.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  1. // This file is part of libigl, a simple c++ geometry processing library.
  2. //
  3. // Copyright (C) 2013 Alec Jacobson <[email protected]>
  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_EMBREE_AMBIENT_OCCLUSION_H
  9. #define IGL_EMBREE_AMBIENT_OCCLUSION_H
  10. #include "../igl_inline.h"
  11. #include <Eigen/Core>
  12. namespace igl
  13. {
  14. namespace embree
  15. {
  16. /// Compute ambient occlusion per given point
  17. ///
  18. /// @param[in] V #V by 3 list of mesh vertex positiosn
  19. /// @param[in] F #F by 3 list of mesh triangle indices into rows of V
  20. /// @param[in] P #P by 3 list of origin points
  21. /// @param[in] N #P by 3 list of origin normals
  22. /// @param[out] S #P list of ambient occlusion values between 1 (fully occluded) and
  23. /// 0 (not occluded)
  24. template <
  25. typename DerivedV,
  26. typename DerivedF,
  27. typename DerivedP,
  28. typename DerivedN,
  29. typename DerivedS >
  30. IGL_INLINE void ambient_occlusion(
  31. const Eigen::MatrixBase<DerivedV> & V,
  32. const Eigen::MatrixBase<DerivedF> & F,
  33. const Eigen::MatrixBase<DerivedP> & P,
  34. const Eigen::MatrixBase<DerivedN> & N,
  35. const int num_samples,
  36. Eigen::PlainObjectBase<DerivedS> & S);
  37. /// \overload
  38. /// \brief Wrapper which builds new EmbreeIntersector for (V,F). That's expensive so
  39. /// avoid this if repeatedly calling.
  40. ///
  41. /// @param[in] ei EmbreeIntersector containing (V,F)
  42. ///
  43. // Forward define
  44. class EmbreeIntersector;
  45. template <
  46. typename DerivedP,
  47. typename DerivedN,
  48. typename DerivedS >
  49. IGL_INLINE void ambient_occlusion(
  50. const EmbreeIntersector & ei,
  51. const Eigen::MatrixBase<DerivedP> & P,
  52. const Eigen::MatrixBase<DerivedN> & N,
  53. const int num_samples,
  54. Eigen::PlainObjectBase<DerivedS> & S);
  55. }
  56. };
  57. #ifndef IGL_STATIC_LIBRARY
  58. # include "ambient_occlusion.cpp"
  59. #endif
  60. #endif