Generating a random number in shader

Is there a way to generate a random number in glsl?
I need to generate sample directions.

No, there are functions that generate pseud-random values but these are not implemented on NVIDIA.
What people usually do is to use a texture with random values. That is of course limited to fragment shader on older hardware.

With G80, you can use integer operations in the shaders and therefore, implement random number generators from lets say Numerical Recipes. Using the vertex or primitive id also gives you a seed value.

Using the vertex or primitive id also gives you a seed value.
Wait, primitives have ID’s now (on G80’s)? What extension opens that up?

EXT_gpu_shader4

This topic was automatically closed 183 days after the last reply. New replies are no longer allowed.