//------------------------------------------------------------------------- // end: GPU compute / grid samples // GPU compute / custom samples //------------------------------------------------------------------------- public static void Compute(Vector2Array input, FloatArray output, NoiseScale scale, NoiseOffset offset, int numOctaves, float octaveOffsetFactor) { ComputeShader shader; int kernelId; GetClassicCustom2(out shader, out kernelId); NoiseCommon.Compute(input, output, shader, kernelId, scale, offset, numOctaves, octaveOffsetFactor); }
//------------------------------------------------------------------------- // end: common // GPU compute / grid samples //------------------------------------------------------------------------- public static void Compute(FloatArray output, NoiseScale scale, NoiseOffset offset, int numOctaves, float octaveOffsetFactor) { ComputeShader shader; int kernelId; GetClassicGrid2(out shader, out kernelId); NoiseCommon.Compute(output, shader, kernelId, scale.GetArray(), offset, numOctaves, octaveOffsetFactor); }
//------------------------------------------------------------------------- // end: common // GPU compute / grid samples //------------------------------------------------------------------------- public static void Compute(FloatArray output, int seed = 0) { ComputeShader shader; int kernelId; GetRandom1(out shader, out kernelId); NoiseCommon.Compute(output, shader, kernelId, seed); }
public static void Compute(Vector3Array output, NoiseScale scale, NoiseOffset offset, int numOctaves, float octaveOffsetFactor) { ComputeShader shader; int kernelId; GetSimplexGradientGrid3(out shader, out kernelId); NoiseCommon.Compute(output, shader, kernelId, scale, offset, numOctaves, octaveOffsetFactor); }
//------------------------------------------------------------------------- // end: GPU compute / grid samples // CPU //------------------------------------------------------------------------- public static float Get(float v, int seed = 0) { // return frac(sin(mod(s, 6.2831853)) * 43758.5453123); float s = NoiseCommon.JumbleSeed(seed); float r = Mathf.Sin(Mathf.Repeat(s + v, 6.2831853f)) * 43758.5453123f; r = (r >= 0.0f) ? r : -r; r -= Mathf.Floor(r); return(r); }
public static float Get(Vector2 v, int seed = 0) { // float d = dot(s + 0.1234567, float2(1111112.9819837, 78.237173)); float s = NoiseCommon.JumbleSeed(seed); float d = (s + v.x + 0.1234567f) * 1111112.9819837f + (s + v.y + 0.1234567f) * 78.237173f; // return frac(sin(m) * 43758.5453123); float r = Mathf.Sin(d) * 43758.5453123f; r = (r >= 0.0f) ? r : -r; r -= Mathf.Floor(r); return(r); }