For a noise shader I'm looking for a pseudo random number algorithm with 3d vector argument, i.e., for every integer vector it returns a value in [0,1]. It should be as fast as possible without producing visual artifacts and giving the same results on every GPU.
Two variants (pseudo code) I found are
rand1(vec3 (x,y,z)){
return xorshift32(x ^ xorshift32(y ^ xorshift32(z)));
}
which already uses 20 arithmetic operations and still has to be casted and normalized and
rand2(vec3 v){
return fract(sin(dot(v, vec3(12.9898, 78.233, ?))) * 43758.5453);
};
which might be faster but uses sin
causing precision problems and different results on different GPU's.
Do you know any other algorithms requiring less arithmetic operations? Thanks in advance.
Aucun commentaire:
Enregistrer un commentaire