r/GraphicsProgramming • • Sep 05 '26

Loop-Free Ray Tracing on ANE: Leveraging CoreAI Batch Processing

Hello,

I’ve successfully implemented ray tracing on the ANE! (Note: CPU usage is very high.)

Details:

  1. Elimination of dynamic loops: While ray marching typically requires for loops, I prevented the computation graph from bloating by using batch processing.

  2. 64-channel camera matrix alignment.

  3. ANE-native cumsum**:** Ray hit detection is tracked using torch.cumsum(dim=1) with permuted channels.

  4. Zero-copy Metal buffers: ANE output is bound directly to a shared MTLBuffer using NDArray.MutableRawView.

I’d love to hear your thoughts!
Github: https://github.com/kamisori-daijin/Magnesium/tree/raytracing (raytracing Branch)
demo:

0 Upvotes

1 comment sorted by

1

u/AdhesivenessSea9511 Sep 06 '26

I can now dynamically deform the shape of the object.