Skip to content

Instantly share code, notes, and snippets.

@warmist
Last active October 19, 2020 08:53
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save warmist/f5183b4cd424b79238796eabbcca9965 to your computer and use it in GitHub Desktop.
Save warmist/f5183b4cd424b79238796eabbcca9965 to your computer and use it in GitHub Desktop.
//from Hash Functions for GPU Rendering (Jarzynski et al.)
//http://www.jcgt.org/published/0009/03/02/
uint3 pcg3d(uint3 v)
{
v = v * 1664525u + 1013904223u;
v.x += v.y*v.z; v.y += v.z*v.x; v.z += v.x*v.y;
v ˆ= v >> 16u;
v.x += v.y*v.z; v.y += v.z*v.x; v.z += v.x*v.y;
return v;
}
uint4 pcg4d(uint4 v)
{
v = v * 1664525u + 1013904223u;
v.x += v.y*v.w; v.y += v.z*v.x; v.z += v.x*v.y; v.w += v.y*v.z;
v ˆ= v >> 16u;
v.x += v.y*v.w; v.y += v.z*v.x; v.z += v.x*v.y; v.w += v.y*v.z;
return v;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment