lighttransport / nanort

NanoRT, single header only modern ray tracing kernel.
MIT License
1.07k stars 89 forks source link

Real time raycaster? #57

Closed NukeBird closed 4 years ago

NukeBird commented 4 years ago

My first attempt was a creation of real-time raycaster (single hit, no recursive rays aka ray tracing)

For a blender monkey with ~15k tris I got ~100ms for FullHD frame. I tested every pixel on the screen (so 1920*1080 = 2073600 rays), model occupied 30-40% of window space

I knew that such a raycaster won't be fast, but to be honest I expected a bit more. Maybe I did something wrong? Or is here any tricks to achieve better performance? BVH and traversal settings are default, I'm testing everything in 1 thread

It's theoretical question, just wanna know how much speed I can get. Atm I'm using software rasterization (7-8ms for 1920x1080, 10-16ms at close range) and planning to use nanort for occlusion culling (so I'll stop rasterize triangles I can't see)

I'm sorry for such a silly question I just wanna know the limits. Here is always possibility that I'm doing something wrong :)

NukeBird commented 4 years ago

i7-7700

syoyo commented 4 years ago

NanoRT is not designed for realtime use. But you can implement ray-packet traversal(e.g. for efficient occlusion culling), SIMD ray traversal, etc. based on NanoRT code.

You can use Embree(as you may know, fast(est) CPU ray tracing kernel) to measure how much you can achieve by utilizing (general purpose) CPU raycaster.

According to our internal experiment, NanoRT(scalar) ray casting performance is 3 to 4 times slower than Embree(SSE2 or AVX) for triangle scene, 5 to 7 times slower for hair geometry.