PDA

View Full Version : I was told that for ray tracing I shoulduse OpenCL



tobindax
09-11-2010, 12:52 AM
Is it true? Can GLSL do it? If it can do it but do it worse, is it definite? Can it be improved in the future or right now with the right extensions?

absence
09-11-2010, 02:47 AM
Both can be used for ray tracing. I guess it makes more sense to ues GLSL if the result is to be integrated with other real-time rendering in OpenGL, and to use OpenCL if the ray tracer is less integrated or stand-alone. Last time I checked both languages lacked recursion though, so you have to implement the algorithms without it.

Nighthawk
09-11-2010, 07:27 AM
I have implemented a raytracer in both GLSL and CUDA(which is comparable to OpenCL).

In GLSL, it is not possible to implement a stack, which is critical for fast traversal of the tree-like acceleration structures(BVH, KD-tree etc).

The problem is you cannot write freely to memory and read it back during one shader run(for pushing/poping stack entries). I used a kd-tree and simply "restarted" scanning the kd tree from the root instead of poping an element from the stack in my GLSL raytracer(->google "kd restart")

Link tip for RT raytracing: http://ompf.org/forum/

Dark Photon
09-12-2010, 05:54 AM
Is it true? Can GLSL do it? If it can do it but do it worse, is it definite? Can it be improved in the future or right now with the right extensions?
Just to add to Nighthawk's post, it was mentioned at SIGGRAPH that the main reason to use OpenCL/D3D Compute is if you can make efficient use of the SM shared memory on the GPU. If you can't, just use normal GL shaders.