Random From UV

RenderMonkey has a very Cool Texture generator, that allow you to generate a texture from HLSL.

Well It is cool until you need to generate a random texture from UV.

Here are some quick code that is prob not mathematically correct, but it work for me.

float4 Texture2DFill( float2 vTexCoord : POSITION,
float2 vTexelSize : PSIZE) : COLOR
{
float uvFactor = dot(vTexCoord, float2( 1528.4f, 51.3f));
float rand = frac(fmod(uvFactor * 51223.00445, 20)) * 20;
rand *= uvFactor;
rand *= sqrt(rand * 347);
rand = fmod(rand, 2 * 3.1412 * uvFactor);
rand = frac(rand);
return rand;
}