public Terrain(DepthTexture diffuseMap, DepthTexture bumpMap, float yScale, float xzScale) { if (diffuseMap.Height != bumpMap.Height || diffuseMap.Width != bumpMap.Width) { throw new Exception("diffuseMap and bumpMap must be the same size"); } if (yScale < 1.0f || xzScale < 1.0f) { throw new Exception("only can scale up or keep a scale of 1"); } //make bare-bones simplified arrays/per-computed values this.xzScale = xzScale; h = bumpMap.Height; w = bumpMap.Width; this.bumpMap = new float[bumpMap.Width, bumpMap.Height]; this.diffuseMap = new Pixel[diffuseMap.Width, diffuseMap.Height]; Parallel.For(0, bumpMap.Width, x => { for (int y = 0; y < bumpMap.Height; y++) { this.bumpMap[x, y] = bumpMap.GetPixel(x, y).R *yScale; ref Pixel tmpPix = ref this.diffuseMap[x, y]; BasePixel tmpPix2 = diffuseMap.GetPixel(x, y); tmpPix.R = tmpPix2.R; tmpPix.G = tmpPix2.G; tmpPix.B = tmpPix2.B; } }); }