// This file is part of libigl, a simple c++ geometry processing library. // // Copyright (C) 2013 Alec Jacobson // // This Source Code Form is subject to the terms of the Mozilla Public License // v. 2.0. If a copy of the MPL was not distributed with this file, You can // obtain one at http://mozilla.org/MPL/2.0/. #include "ambient_occlusion.h" #include "EmbreeIntersector.h" #include #include template < typename DerivedP, typename DerivedN, typename DerivedS > IGL_INLINE void igl::embree::ambient_occlusion( const igl::embree::EmbreeIntersector & ei, const Eigen::PlainObjectBase & P, const Eigen::PlainObjectBase & N, const int num_samples, Eigen::PlainObjectBase & S) { using namespace Eigen; using namespace igl; const int n = P.rows(); // Resize output S.resize(n,1); // Embree seems to be parallel when constructing but not when tracing rays #pragma omp parallel for // loop over mesh vertices for(int p = 0;p(); const Vector3f normal = N.row(p).template cast(); int num_hits = 0; MatrixXf D = random_dir_stratified(num_samples).cast(); for(int s = 0;s IGL_INLINE void igl::embree::ambient_occlusion( const Eigen::PlainObjectBase & V, const Eigen::PlainObjectBase & F, const Eigen::PlainObjectBase & P, const Eigen::PlainObjectBase & N, const int num_samples, Eigen::PlainObjectBase & S) { using namespace igl; using namespace Eigen; EmbreeIntersector ei; ei.init(V.template cast(),F.template cast()); ambient_occlusion(ei,P,N,num_samples,S); } #ifdef IGL_STATIC_LIBRARY // Explicit template specialization template void igl::embree::ambient_occlusion, Eigen::Matrix, Eigen::Matrix >(igl::embree::EmbreeIntersector const&, Eigen::PlainObjectBase > const&, Eigen::PlainObjectBase > const&, int, Eigen::PlainObjectBase >&); template void igl::embree::ambient_occlusion, Eigen::Matrix, Eigen::Matrix >(igl::embree::EmbreeIntersector const&, Eigen::PlainObjectBase > const&, Eigen::PlainObjectBase > const&, int, Eigen::PlainObjectBase >&); template void igl::embree::ambient_occlusion, Eigen::Matrix, Eigen::Matrix, Eigen::Matrix, Eigen::Matrix >(Eigen::PlainObjectBase > const&, Eigen::PlainObjectBase > const&, Eigen::PlainObjectBase > const&, Eigen::PlainObjectBase > const&, int, Eigen::PlainObjectBase >&); template void igl::embree::ambient_occlusion, Eigen::Matrix, Eigen::Matrix, Eigen::Matrix, Eigen::Matrix >(Eigen::PlainObjectBase > const&, Eigen::PlainObjectBase > const&, Eigen::PlainObjectBase > const&, Eigen::PlainObjectBase > const&, int, Eigen::PlainObjectBase >&); #endif