ambient_occlusion.h 1.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  1. // This file is part of libigl, a simple c++ geometry processing library.
  2. //
  3. // Copyright (C) 2013 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_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. // Forward define
  17. class EmbreeIntersector;
  18. // Compute ambient occlusion per given point
  19. //
  20. // Inputs:
  21. // ei EmbreeIntersector containing (V,F)
  22. // P #P by 3 list of origin points
  23. // N #P by 3 list of origin normals
  24. // Outputs:
  25. // S #P list of ambient occlusion values between 1 (fully occluded) and
  26. // 0 (not occluded)
  27. //
  28. template <
  29. typename DerivedP,
  30. typename DerivedN,
  31. typename DerivedS >
  32. IGL_INLINE void ambient_occlusion(
  33. const EmbreeIntersector & ei,
  34. const Eigen::PlainObjectBase<DerivedP> & P,
  35. const Eigen::PlainObjectBase<DerivedN> & N,
  36. const int num_samples,
  37. Eigen::PlainObjectBase<DerivedS> & S);
  38. // Wrapper which builds new EmbreeIntersector for (V,F). That's expensive so
  39. // avoid this if repeatedly calling.
  40. template <
  41. typename DerivedV,
  42. typename DerivedF,
  43. typename DerivedP,
  44. typename DerivedN,
  45. typename DerivedS >
  46. IGL_INLINE void ambient_occlusion(
  47. const Eigen::PlainObjectBase<DerivedV> & V,
  48. const Eigen::PlainObjectBase<DerivedF> & F,
  49. const Eigen::PlainObjectBase<DerivedP> & P,
  50. const Eigen::PlainObjectBase<DerivedN> & N,
  51. const int num_samples,
  52. Eigen::PlainObjectBase<DerivedS> & S);
  53. }
  54. };
  55. #ifndef IGL_STATIC_LIBRARY
  56. # include "ambient_occlusion.cpp"
  57. #endif
  58. #endif