PDA

View Full Version : generating a random number in shader



Beau
12-08-2006, 12:38 AM
Is there a way to generate a random number in glsl?
I need to generate sample directions.

k_szczech
12-08-2006, 01:47 AM
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.

ScottManDeath
12-08-2006, 02:10 AM
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.

Korval
12-08-2006, 01:47 PM
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?

Overmind
12-08-2006, 02:00 PM
EXT_gpu_shader4