HLSL Question - Random numbers?

Started by
2 comments, last by sirob 18 years, 8 months ago
Hey all, Just a quickie here: Is it possible to generate a random number inside a shader? I can't seem to find any intrinsic function to do this and I obviously can't set an outside value because that'll set it for the entire pass and not on a per vertex / pixel value. Thanks.
Advertisement
No.

You would have to generate one outside and pass it in.

ace
Quote:
I obviously can't set an outside value because that'll set it for the entire pass and not on a per vertex / pixel value.

You could (obviously :-) sent an array of outside values.

Furthermore, a small RNG is not so hard to write so might as well include one in your HLSL file.

Greetz,

Illco
You could also use a texture with random values if this is for a pixelshader or VS3.0 and up.
Sirob Yes.» - status: Work-O-Rama.

This topic is closed to new replies.

Advertisement