Random Values


i’m trying to create random values in shader, the first thing i found was the “float noise1(float)” function. i tried it, it didnt work, i tried all of those 4 noise functions, none worked, so i read about it in the registry:

which appears do be wrong or deprecated (or i’m doing something wrong), so i read about it in the GLSL 4.5 specs, and it says these functions are all deprecated since 4.4 :confused:

on the web i found some pseudo-random stuff:

but isnt there another way to generate random (or pseudo-random) numbers ??
currently i’m using:

float rand(vec2 co)
    return fract(sin(dot(co.xy ,vec2(12.9898,78.233))) * 43758.5453);

One thing you could do is simply to send the time as a uniform. Then use a random number generator algorithm. There are many. You would certainly be able to find one that you could implement in a shader.

The main reason that they’re deprecated is that they were never implemented.

AFAIK it’s actually conformant for all of the noise() functions to just return 0 every time they’re used.

An alternative is to pre-generate the noise into a texture, then do a lookup using the same params as you would use for a GLSL noise() call.

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