I was told that for ray tracing I shoulduse OpenCL

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?

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.

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/

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.