static SampleFunctions() { functions = new UtilFuncs.Sampler[6]; simplex = new SE.OpenSimplexNoise(7); // Flat ground functions[0] = (float x, float y, float z) => { Debug.LogFormat("Sampling at {0} {1} {2}", x, y, z); return(0.5f - y); }; // Sphere functions[1] = (float x, float y, float z) => { Vector3 p = new Vector3(x - 0.5f, y - 0.5f, z - 0.5f); return(Sphere(p.x, p.y, p.z, 0.25f)); }; // Simplex functions[2] = (float x, float y, float z) => { float r = 1132f; return((float)simplex.Evaluate(x * r, y * r, z * r)); }; // Rotated Cuboid functions[3] = (float x, float y, float z) => { Vector3 p = new Vector3((x - 1.5f) * 2f, (y - 1.5f) * 2f, (z - 1.5f) * 2f); return(RotatedCuboid(p, 0.6f)); }; // Simplex Terrain functions[4] = (float x, float y, float z) => { float result = y - 1.5f; float r = 3f; float r2 = r * 8; result += 0.5f * (float)simplex.Evaluate(x * r, y * r, z * r); result += 0.15f * (float)simplex.Evaluate(x * r2, y * r2, z * r2); return(result); }; }
private static float sample(SE.OpenSimplexNoise noise, float x, float y, float z) { float r = 0.2f; float f = 0.03f; float ms = 0.009f; float result = 2.0f - y; result += (float)noise.Evaluate(x * r, y * r, z * r) * 1.6f; result += (float)noise.Evaluate(x * f, y * f, z * f) * 20f; result += (float)noise.Evaluate(x * f, y * f, z * ms) * 50f; return(result); }
public static float Noise3DSample(float x, float y, float z) { float r = 0.05f; float ground = -1.5f + y; float noise = (float)s.Evaluate((double)x * r, (double)y * r, (double)z * r) * 15; float result = 0f; result += Mathf.Min(ground, noise); //result += ground; return(result); }
public static float DebugNoise(Vector3 position) { float r = 1.8f; return((float)noise.Evaluate(position.x * r, position.y * r, position.z * r)); }