How do you generate a random number in HLSL?
I'm asking because I want to try gpu ray tracing. You need to generate random directions in a pixel shader. So I want
randFloat(), where the result is a random number between -1 and +1.
Also, what is the deal with the hlsl noise instruction? The docs say it was removed from HLSL 2.0 and up. Why?
I read about an approach where you fill a texture with random values, then have a texture coordinate in each vertex that has an index into that texture. But that's per vertex, I need an instruction I can call in the pixel shader. Plus this approach requires "reseeding" the per-vertex texcoords if you want different values each frame, and that requires a vertex buffer update each frame (which can be expensive!)
With detail, how can you cheaply generate a random number on the GPU?