ambient_occlusion.m 778 B

12345678910111213141516171819202122
  1. % AMBIENT_OCCLUSION Compute ambient occlusion per given point
  2. %
  3. % S = ambient_occlusion(V,F,P,N,num_samples)
  4. %
  5. % Inputs:
  6. % V #V by 3 list of mesh vertex positions
  7. % F #F by 3 list of mesh triangle facet indices into V
  8. % P #P by 3 list of origin points
  9. % N #P by 3 list of origin normals
  10. % num_samples number of samples
  11. % Outputs:
  12. % S #P list of ambient occlusion values between 1 (fully occluded) and 0
  13. % (not occluded)
  14. %
  15. % Examples:
  16. % % mesh (V,F), scalar field Z
  17. % AO = ambient_occlusion(V,F,V,per_vertex_normals(V,F),1000);
  18. % tsurf(F,V,'FaceVertexCData', ...
  19. % bsxfun(@times,1-AO, ...
  20. % squeeze(ind2rgb(floor(matrixnormalize(Z)*256),jet(256)))), ...
  21. % fphong,'EdgeColor','none');
  22. %