Raytracing + RNG

I’m currently working on a GPU based ray tracing. The next step I’ll take

needs some random numbers.

Can anybody tell me what’s the most efficient way to generate some good

distributed random numbers on the GPU?

My algorithm does (roughly) the following:

for each pixel

  compute closest intersetion

  compute direct lighting

  compute random ray based on BRDF by using two random numbers

For the third computation I need two random numbers. But how can I compute them?

I mean, I could precompute a bunch of random numbers at the beginning of each

frame, store them in texture memory and access them by the thread-id/block-id.

That might be the worst solution.

There are bunch of ways of doing this, I’ve used this code in the past with some success:
[url=“http://www-old.amolf.nl/~vanmeel/mdgpu/download2.html”]http://www-old.amolf.nl/~vanmeel/mdgpu/download2.html[/url]