void CreateNoiseMask() { Vector2 center = new Vector2(samp.size / 2, samp.size / 2); float maxDist = samp.size * radius; //simplified max dist to get better noiseMask. mask.Resize(samp.size); maskTexture = new Texture2D(chunkSize, chunkSize, TextureFormat.RGBA32, false, false); mask.Foreach((x, y) => { float val = 1 - (Vector2.Distance(new Vector2(x, y), center) / maxDist); maskTexture.SetPixel(x, y, new Color(val, val, val)); return(val); }); maskTexture.Apply(); }
public void CreateNoiseMask() { if (samp == null) { return; } Vector2 center = new Vector2(samp.size / 2, samp.size / 2); float maxDist = samp.size * radius; //simplified max dist to get better noiseMask. mask.Resize(samp.size); mask.Foreach((x, y) => { float val = 1 - (Vector2.Distance(new Vector2(x, y), center) / maxDist); return(val); }); }
public override void OnNodeProcess() { if (chunkSizeHasChanged) output.Resize(chunkSize); //recalcul perlin noise values with new seed / position. if (needUpdate) { float scale = 40f; output.Foreach((x, y) => { float nx = (float)x * step + chunkPosition.x; float ny = (float)y * step + chunkPosition.z; float val = PerlinNoise2D.GenerateNoise(nx / scale, ny / scale, 2, 2, 1, 1, seed); for (int i = 0; i < octaves; i++) val *= 1.2f; return val; }); } }