question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

pyembree ray casting acceleration

See original GitHub issue

Hi @mikedh and thanks for the nice work with trimesh. I am quite new with it but it really gets in hand.

My question now is related with the ray casting approach based on the pyembree acceleration. I need to ray cast quite a few rays in a 3D scene, approx. 18060108 rays and maybe even more. Imagine that I have a scene with 16676 faces and from each face center I need to cast 1083 rays (i.e. 16676x1083 = 18060108).

As you understand I want to avoid for loops and I cast all the rays at once. Also I am using the pyembree based solution, as it states to accelerate the casting procedure in comparison to normal version, as follows:

import trimesh
import numpy as np

mesh = trimesh.Trimesh(vertices=vertices, faces=faces, face_normals=normals, process=False, use_embree=True) # create mesh from given data

intersection_points, index_ray, index_tri = mesh.ray.intersects_location(origins, drays, multiple_hits=False) # where origins are my triangle centers and drays my rays direction vectors

but this seems to perform quite slow as well, even though I am using pyembree acceleration. Is this the best I can get or I am doing something wrong?

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:14 (4 by maintainers)

github_iconTop GitHub Comments

1reaction
ttsesmcommented, Jun 20, 2020

Thanks for sharing @aluo-x. In my case though using v2.17.7 instead of v2.14 did not provide any significant acceleration.

1reaction
aluo-xcommented, Jun 19, 2020

So basically, embree 2.17.7 is as far as I know the latest compatible version with the embree python package. To use it:

  1. Start a conda environment without embree, pyembree, trimesh etc.
  2. git clone --recursive https://github.com/conda-forge/embree-feedstock.git
  3. Modify the meta.yaml file, take care to change the version and delete the sha256 (skipping that check) or fixing it to the correct one
  4. cd into the recipe folder, type conda build .
  5. Wait until it finishes, will appear frozen at times
  6. Take note of the output path, and conda install NEW_PKG_PATH where you put in the location of the package
  7. Install the pyembree package, and trimesh package. I usually install from source (git clone recursive, then python setup.py develop or conda build depending on if it has a recipe.
Read more comments on GitHub >

github_iconTop Results From Across the Web

trimesh.ray.ray_pyembree — trimesh 3.17.1 documentation
Ray queries using the pyembree package with the API wrapped to match our native raytracer. class trimesh.ray.ray_pyembree.RayMeshIntersector(geometry ...
Read more >
Intel Embree
High Performance Ray Tracing. Intel® Embree is a collection of high performance ray tracing kernels that helps graphics application engineers to improve the ......
Read more >
python - Intersection between 2d image point and 3d mesh
To find the intersection of a ray and a mesh, the Ray Tracing algorithm typically uses different acceleration structures.
Read more >
Introduction — Advanced Ray Tracing documentation
The Embree API is a low-level C99 ray tracing API which can be used to construct 3D scenes and perform ray queries of...
Read more >
Blog - lukeparry.uk
... towards ray-tracing capability for volumes and meshes using OSPRay. ... Alternatively, PyEmbree, based on Intel's Embree library can be ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found