public void CreateGraph() { float[,] simplexGraph = SimplexNoise.Calc2D(this.width, this.height, this.noiseScale); for (int x = 0; x < this.width; x++) { for (int z = 0; z < this.height; z++) { float y = simplexGraph[x, z] * this.heightScale; string prefabName = "x" + x + ", z" + z + ", y" + y; GameObject newObj = InstantiatePrefab(prefabName, objPrefab, this.gameObject, new Vector3(x, y, z)); //newObj.transform.localScale = new Vector3 (1, y*this.heightScale, 1); } } }
public AmbientLightSystem(GraphicsDevice device, EffectFactory effectFactory, IComponentContainer <AmbientLight> lights) { this.Device = device; this.Effect = effectFactory.Construct <AmbientLightEffect>(); this.BlurEffect = effectFactory.Construct <BlurEffect>(); this.Lights = lights; this.FullScreenTriangle = new FullScreenTriangle(); this.Kernel = this.GenerateKernel(); var random = new Random(255); this.NoiseMap = new Texture2D(device, 64, 64, false, SurfaceFormat.Color); SimplexNoise.Seed = random.Next(); var noiseX = SimplexNoise.Calc2D(this.NoiseMap.Width, this.NoiseMap.Height, 1.0f); SimplexNoise.Seed = random.Next(); var noiseY = SimplexNoise.Calc2D(this.NoiseMap.Width, this.NoiseMap.Height, 1.0f); SimplexNoise.Seed = random.Next(); var noiseZ = SimplexNoise.Calc2D(this.NoiseMap.Width, this.NoiseMap.Height, 1.0f); var noise = new Color[this.NoiseMap.Width * this.NoiseMap.Height]; for (var y = 0; y < this.NoiseMap.Height; y++) { for (var x = 0; x < this.NoiseMap.Width; x++) { var r = (noiseX[x, y] / 128.0f) - 1.0f; var g = (noiseY[x, y] / 128.0f) - 1.0f; var b = (noiseZ[x, y] / 128.0f) - 1.0f; noise[x * y] = new Color(r, g, b); } } this.NoiseMap.SetData(noise); }