public void Update() { _utTextureRendererProxy.Update(); _commonExecutor.Update(); _unityThreadComputeShaderExecutorObject.Update(); MyTexturePair texturePair; bool takeSucceded = _resultBag.TryTake(out texturePair); if (takeSucceded) { var unitySideLength = 10f; var realSideLength = 240 * 24; var metersPerUnit = realSideLength / unitySideLength; var gameObject = GameObject.CreatePrimitive(PrimitiveType.Quad); var material = new Material(Shader.Find("Custom/Terrain/Terrain_Debug")); gameObject.GetComponent <MeshRenderer>().material = material; gameObject.name = "Terrain"; gameObject.transform.localRotation = Quaternion.Euler(0, 0, 0); gameObject.transform.localScale = new Vector3(10, 6500 / metersPerUnit, 10); gameObject.transform.localPosition = new Vector3(0, 0, 0); gameObject.GetComponent <MeshFilter>().mesh = PlaneGenerator.CreateFlatPlaneMesh(240, 240); material.SetTexture("_HeightmapTex0", texturePair.Tex0); material.SetTexture("_HeightmapTex1", texturePair.Tex1); } }
public void Start() { //var heightTexture = SavingFileManager.LoadPngTextureFromFile(@"C:\inz\cont\smallCut.png", 240, // 240, TextureFormat.RGBA32, true, true); //_currentHeightmap = HeightmapUtils.CreateHeightmapArrayFromTexture(heightTexture); DiamondSquareCreator creator = new DiamondSquareCreator(new RandomProvider(22)); _currentHeightmap = creator.CreateDiamondSquareNoiseArray(new IntVector2(240, 240), 64); MyArrayUtils.Multiply(_currentHeightmap.HeightmapAsArray, 0.1f); _go = GameObject.CreatePrimitive(PrimitiveType.Quad); var material = new Material(Shader.Find("Custom/Terrain/Terrain_Debug")); _go.GetComponent <MeshRenderer>().material = material; _go.name = "Terrain"; _go.transform.localRotation = Quaternion.Euler(0, 0, 0); _go.transform.localScale = new Vector3(10, 10, 10); _go.transform.localPosition = new Vector3(0, 0, 0); _go.GetComponent <MeshFilter>().mesh = PlaneGenerator.CreateFlatPlaneMesh(240, 240); var doneTexture = HeightmapUtils.CreateTextureFromHeightmap(_currentHeightmap); _go.GetComponent <MeshRenderer>().material.SetTexture("_HeightmapTex0", doneTexture); _go.GetComponent <MeshRenderer>().material.SetTexture("_HeightmapTex1", doneTexture); _oldDoneTexture = doneTexture; }
public void Start() { TaskUtils.SetGlobalMultithreading(false); var rgbaMainTexture = SavingFileManager.LoadPngTextureFromFile(@"C:\inz\cont\n49_e019_1arc_v3.png", 3600, 3600, TextureFormat.ARGB32, true, false); MainTexture = _transformator.EncodedHeightTextureToPlainAsync(new TextureWithSize() { Size = new IntVector2(3600, 3600), Texture = rgbaMainTexture }).Result; //var heightArray = HeightmapUtils.CreateHeightmapArrayFromTexture(MainTexture); //for (int x = 0; x < 5; x++) //{ // for (int y = 0; y < 5; y++) // { // heightArray.HeightmapAsArray[x, y] = 0.3f; // } //} //MainTexture = HeightmapUtils.CreateTextureFromHeightmap(heightArray); InitializeFields(); var unitySideLength = 10f; var realSideLength = 240 * 24; var metersPerUnit = realSideLength / unitySideLength; _gameObject = GameObject.CreatePrimitive(PrimitiveType.Quad); var material = new Material(Shader.Find("Custom/Terrain/Terrain_Debug_Plain")); _gameObject.GetComponent <MeshRenderer>().material = material; _gameObject.name = "Terrain"; _gameObject.transform.localRotation = Quaternion.Euler(0, 0, 0); //_gameObject.transform.localScale = new Vector3(10, (6500 / metersPerUnit) , 10); //_gameObject.transform.localPosition = new Vector3(0 , 0, 0); //_gameObject.transform.localScale = new Vector3(10, (6500 / metersPerUnit) * 8, 10); //_gameObject.transform.localPosition = new Vector3(0, 0, 0); _gameObject.transform.localScale = new Vector3(10, 1 / 64f * (6500 / metersPerUnit) * 8 * 8, 10); _gameObject.transform.localPosition = new Vector3(0, -30, 0); _gameObject.GetComponent <MeshFilter>().mesh = PlaneGenerator.CreateFlatPlaneMesh(240, 240); RegenerateTextures(); //Camera.main.transform.localPosition = new Vector3(10,2,0); //Camera.main.transform.eulerAngles = new Vector3(30,-45,0); Camera.main.transform.localPosition = new Vector3(-1, -25, 10); Camera.main.transform.eulerAngles = new Vector3(30, 132, 0); }
public void Start() { TaskUtils.SetGlobalMultithreading(false); var rgbaMainTexture = SavingFileManager.LoadPngTextureFromFile(@"C:\inz\cont\n49_e019_1arc_v3.png", 3600, 3600, TextureFormat.ARGB32, true, false); TerrainTextureFormatTransformator transformator = new TerrainTextureFormatTransformator(new CommonExecutorUTProxy()); var mainTexture = transformator.EncodedHeightTextureToPlainAsync(new TextureWithSize() { Size = new IntVector2(3600, 3600), Texture = rgbaMainTexture }).Result; var gameObject = GameObject.CreatePrimitive(PrimitiveType.Quad); var material = new Material(Shader.Find("Custom/Terrain/Ring1")); TerrainAndNormalTexture pair = CreateTerrainAndNormalTexture(mainTexture); material.SetTexture("_HeightmapTex", pair.HeightTexture); material.SetTexture("_NormalmapTex", pair.NormalTexture); gameObject.GetComponent <MeshRenderer>().material = material; gameObject.name = "Terrain"; gameObject.transform.localRotation = Quaternion.Euler(0, 0, 0); var unitySideLength = 10f; var realSideLength = 240 * 24; var metersPerUnit = realSideLength / unitySideLength; if (_terrainResolution == TerrainCardinalResolution.MIN_RESOLUTION) { gameObject.transform.localScale = new Vector3(10, (6500 / metersPerUnit), 10); gameObject.transform.localPosition = new Vector3(0, 0, 0); } else if (_terrainResolution == TerrainCardinalResolution.MID_RESOLUTION) { gameObject.transform.localScale = new Vector3(10, (6500 / metersPerUnit) * 8, 10); gameObject.transform.localPosition = new Vector3(0, 0, 0); } else { gameObject.transform.localScale = new Vector3(10, (6500 / metersPerUnit) * 8 * 8, 10); gameObject.transform.localPosition = new Vector3(0, -30, 0); } gameObject.GetComponent <MeshFilter>().mesh = PlaneGenerator.CreateFlatPlaneMesh(240, 240); }
public static void CreateTerrainShowingGameObject(Texture2D conventionalRing1Texture, float heightDelta) { _terrainGameObject = GameObject.CreatePrimitive(PrimitiveType.Plane); _terrainGameObject.name = "Terrain"; var terrainMaterial = new Material(Shader.Find("Custom/Terrain/Terrain1")); terrainMaterial.SetTexture("_HeightmapTex", conventionalRing1Texture); terrainMaterial.SetFloat("_MaxHeight", heightDelta); _terrainGameObject.GetComponent <Renderer>().material = terrainMaterial; _terrainGameObject.GetComponent <MeshFilter>().mesh = PlaneGenerator.CreateFlatPlaneMesh(256, 250); GameObject.Destroy(_terrainGameObject.GetComponent <MeshCollider>()); _terrainGameObject.transform.localScale = new Vector3(100, 100.0f / 712.0f, 100); _terrainGameObject.transform.localPosition = new Vector3(10.0f, -60f, 0f); }
public void CreateTerrainObject(TextureWithSize textureWithSize, Vector2 startPosition) { var go = GameObject.CreatePrimitive(PrimitiveType.Plane); go.GetComponent <MeshFilter>().mesh = PlaneGenerator.CreateFlatPlaneMesh(241, 241); var material = new Material(Shader.Find("Custom/Debug/SimpleTerrain")); material.SetTexture("_HeightmapTex", textureWithSize.Texture); material.SetFloat("_HeightmapTexWidth", 241); go.GetComponent <MeshRenderer>().material = material; go.transform.localPosition = new Vector3(startPosition.x, 0, startPosition.y); go.transform.localScale = new Vector3(90, 10, 90); go.name = $"TerrainAt" + startPosition; }
public async Task <GRingMeshDetail> ProvideMeshDetailsAsync() { var mesh = await _meshGenerator.AddOrder( () => PlaneGenerator.CreateFlatPlaneMesh(_gameObjectMeshResolution.X, _gameObjectMeshResolution.Y)); var pack = new UniformsPack(); pack.SetUniform("_HeightmapLodOffset", _heightmapLodOffset); return(new GRingMeshDetail() { Mesh = mesh, Uniforms = pack, HeightmapLod = _heightmapLodOffset }); }
public void Update() { _utTextureRendererProxy.Update(); _commonExecutorUtProxy.Update(); _computeShaderExecutorObject.Update(); GeneratedTerrainElements generatedElement; if (_generatedElements.TryTake(out generatedElement)) { var heightElement = generatedElement.HeightElement; var normalElement = generatedElement.NormalElement; var gameObject = GameObject.CreatePrimitive(PrimitiveType.Quad); var material = new Material(Shader.Find("Custom/Terrain/Ring1")); material.SetTexture("_HeightmapTex", heightElement.TokenizedElement.DetailElement.Texture.Texture); material.SetVector("_HeightmapUv", heightElement.UvBase.ToVector4()); material.SetTexture("_NormalmapTex", normalElement.TokenizedElement.DetailElement.Texture.Texture); material.SetVector("_NormalmapUv", normalElement.UvBase.ToVector4()); gameObject.GetComponent <MeshRenderer>().material = material; gameObject.name = "Terrain"; gameObject.transform.localRotation = Quaternion.Euler(0, 0, 0); var unitySideLength = 10f; var realSideLength = 240 * 24; var metersPerUnit = realSideLength / unitySideLength; if (_terrainResolution == TerrainCardinalResolution.MIN_RESOLUTION) { gameObject.transform.localScale = new Vector3(10, (6500 / metersPerUnit), 10); gameObject.transform.localPosition = new Vector3(0, 0, 0); } else if (_terrainResolution == TerrainCardinalResolution.MID_RESOLUTION) { gameObject.transform.localScale = new Vector3(10, (6500 / metersPerUnit) * 8, 10); gameObject.transform.localPosition = new Vector3(0, 0, 0); } else { gameObject.transform.localScale = new Vector3(10, (6500 / metersPerUnit) * 8 * 8, 10); gameObject.transform.localPosition = new Vector3(0, -30, 0); } gameObject.GetComponent <MeshFilter>().mesh = PlaneGenerator.CreateFlatPlaneMesh(240, 240); } }
private void CreateComparisionObject() { _go = GameObject.CreatePrimitive(PrimitiveType.Quad); var material = new Material(Shader.Find("Custom/Terrain/Terrain_Debug")); _go.GetComponent <MeshRenderer>().material = material; _go.name = "Terrain"; _go.transform.localRotation = Quaternion.Euler(0, 0, 0); _go.transform.localScale = new Vector3(10, 1, 10); _go.transform.localPosition = new Vector3(0, 0, 0); _go.GetComponent <MeshFilter>().mesh = PlaneGenerator.CreateFlatPlaneMesh(240, 240); var doneTexture = HeightmapUtils.CreateTextureFromHeightmap(_currentHeightmap); _go.GetComponent <MeshRenderer>().material.SetTexture("_HeightmapTex0", doneTexture); _go.GetComponent <MeshRenderer>().material.SetTexture("_HeightmapTex1", doneTexture); }
public static GameObject CreateFlatTerrainPlane(Point2D gameObjectSize, MyRectangle inGamePosition, UniformsPack pack) { var gameObject = new GameObject("Ring1 terrain object " + inGamePosition.ToString()); var terrainMaterial = new Material(Shader.Find("Custom/Terrain/Terrain1")); pack.SetUniformsToMaterial(terrainMaterial); gameObject.AddComponent <MeshRenderer>(); gameObject.GetComponent <Renderer>().material = terrainMaterial; gameObject.AddComponent <MeshFilter>().mesh = PlaneGenerator.CreateFlatPlaneMesh(gameObjectSize.X, gameObjectSize.Y); gameObject.transform.localScale = new Vector3(inGamePosition.Width, 1, inGamePosition.Height); gameObject.transform.localPosition = new Vector3(inGamePosition.X, 0, inGamePosition.Y); return(gameObject); }
private async Task <GRingTerrainId> CreateTerrainAsync() { var triplet = _tripletProvider.ProvideTriplet(); var mesh = await _meshGeneratorUtProxy.AddOrder(() => PlaneGenerator.CreateFlatPlaneMesh(65, 65)); var creationTemplatesList = new List <Ring1GroundPieceCreationTemplate>(); int layerIndex = 0; UniformsPack pack = new UniformsPack(); pack.SetUniform("_LodLevel", _flatLod.ScalarValue); pack.SetUniform("_NodeId", LastId); var groundShapeDetails = await _groundShapeProvider.ProvideGroundTextureDetail(); _groundShapeToken = groundShapeDetails.GroundShapeToken; pack.MergeWith(groundShapeDetails.Uniforms); creationTemplatesList.Add( new Ring1GroundPieceCreationTemplate() { Name = $"TerrainElementLayer l:{layerIndex} fl:{_flatLod.ScalarValue}, X:{LastId++}", ParentGameObject = _parentObject, PieceMesh = mesh, TransformTriplet = triplet, ShaderName = "Custom/Terrain/DebugTerrainedLod", //ShaderName = "Custom/Terrain/Ring0", ShaderKeywordSet = groundShapeDetails.ShaderKeywordSet, Uniforms = pack, Modifier = new Ring1GroundPieceModifier() }); var toReturn = new GRingTerrainId() { ElementsIds = creationTemplatesList.Select(c => _orderGrabber.AddCreationOrder(c)).ToList() }; return(toReturn); }
private void CreateDebugObject(DebugObjectSpecification specification, Texture weldTexture, TerrainWeldUvs uvs) { var go = GameObject.CreatePrimitive(PrimitiveType.Plane); go.GetComponent <MeshFilter>().mesh = PlaneGenerator.CreateFlatPlaneMesh(specification.MeshResolution.X, specification.MeshResolution.Y); Material material = new Material(Shader.Find("Custom/Test/TerrainWelding")); material.SetTexture("_HeightmapTex", specification.HeightTexture.Texture); material.SetVector("_HeightmapUv", specification.HeightmapUv); material.SetFloat("_HeightmapLodOffset", specification.HeightmapLodOffset); material.SetTexture("_WeldTexture", weldTexture); material.SetVector("_LeftWeldTextureUvRange", uvs.LeftUv); material.SetVector("_RightWeldTextureUvRange", uvs.RightUv); material.SetVector("_TopWeldTextureUvRange", uvs.TopUv); material.SetVector("_BottomWeldTextureUvRange", uvs.BottomUv); go.GetComponent <MeshRenderer>().material = material; go.transform.localPosition = new Vector3(specification.StartPos.x, 0, specification.StartPos.y); go.transform.localScale = specification.LocalScale; }
protected override async Task <UInt32> CreateTerrainAsync() { //todo DOPISZ REAGOWANIE NA ZNIKNIeCIE elementu terenu - trzeba odeslac do TerrainShapeDb informacje o odblokowaniu tekstury!! var creationDetails = CalculateQueryDetails(Ring1Node.QuadLodLevel); var gameObjectMeshResolution = creationDetails.TerrainMeshResolution; //new IntVector2(241, 241); var inGamePosition = _coordsCalculator.CalculateGlobalObjectPosition(Ring1Node.Ring1Position); var mesh = await _meshGenerator.AddOrder( () => PlaneGenerator.CreateFlatPlaneMesh(gameObjectMeshResolution.X, gameObjectMeshResolution.Y)); var debugTestDivider = 240f; var triplet = new MyTransformTriplet( new Vector3(inGamePosition.X / debugTestDivider, 0, inGamePosition.Y / debugTestDivider), Vector3.zero, new Vector3(inGamePosition.Width / debugTestDivider, 20, inGamePosition.Height / debugTestDivider)); //todo! var stainResourceWithCoords = await _stainTerrainServiceProxy.RetriveResource(inGamePosition); UniformsPack pack = await CreateUniformsPack(creationDetails.QueryElementDetails, creationDetails.Pack, stainResourceWithCoords); var creationTemplate = new Ring1GroundPieceCreationTemplate() { Name = "Ring1 terrain object " + inGamePosition.ToString(), ParentGameObject = ParentObject, PieceMesh = mesh, ShaderName = "Custom/Terrain/Ring1", TransformTriplet = triplet, Uniforms = pack, ShaderKeywordSet = creationDetails.KeywordSet }; var objectId = OrderGrabber.AddCreationOrder(creationTemplate); return(objectId); }
private void CreateTestObject(HeightmapArray baseArray, List <HeightmapArray> otherArrays) { _go = GameObject.CreatePrimitive(PrimitiveType.Quad); var material = new Material(Shader.Find("Custom/Terrain/Terrain_Debug_Comparision")); _go.GetComponent <MeshRenderer>().material = material; _go.name = "Terrain"; _go.transform.localRotation = Quaternion.Euler(0, 0, 0); _go.transform.localScale = new Vector3(10, 1, 10); _go.transform.localPosition = new Vector3(0, 0, 0); _go.GetComponent <MeshFilter>().mesh = PlaneGenerator.CreateFlatPlaneMesh(240, 240); MyHeightTextureArray heightTextureArray = new MyHeightTextureArray(240, 240, otherArrays.Count + 1, TextureFormat.ARGB32, false, true); heightTextureArray.AddElementArray(baseArray, 0); for (int i = 0; i < otherArrays.Count; i++) { heightTextureArray.AddElementArray(otherArrays[i], i + 1); } _go.GetComponent <MeshRenderer>().material .SetTexture("_HeightmapTexArray", heightTextureArray.ApplyAndRetrive()); }
public void Start_Hydraulic_Debuggable() { var heightTexture1 = SavingFileManager.LoadPngTextureFromFile(@"C:\inz\cont\smallCut.png", 240, 240, TextureFormat.RGBA32, true, true); var heightmap1 = HeightmapUtils.CreateHeightmapArrayFromTexture(heightTexture1); //DiamondSquareCreator creator = new DiamondSquareCreator(new RandomProvider(22)); //var heightmap2 = creator.CreateDiamondSquareNoiseArray(new IntVector2(240, 240), 64); //MyArrayUtils.Multiply(heightmap2.HeightmapAsArray, 0.1f); var tParam = EroderDebugObject.CalculateFromHillFactor(1, new ArrayExtremes(0, 5000), 24); var extents = MyArrayUtils.CalculateExtremes(heightmap1.HeightmapAsArray); MyArrayUtils.Normalize(heightmap1.HeightmapAsArray); var configuration = new HydraulicEroderConfiguration() { StepCount = 20, NeighbourFinder = NeighbourFinders.Big9Finder, kr_ConstantWaterAddition = 0.001f, ks_GroundToSedimentFactor = 1f, ke_WaterEvaporationFactor = 0.05f, kc_MaxSedimentationFactor = 0.8f, FinalSedimentationToGround = false, WaterGenerator = HydraulicEroderWaterGenerator.FirstFrame, DestinationFinder = HydraulicEroderWaterDestinationFinder.OnlyBest }; var copyArray = MyArrayUtils.DeepClone(heightmap1.HeightmapAsArray); var currentHeightArray = new SimpleHeightArray(copyArray); var eroder = new DebuggableHydraulicEroder(); var debuggingOutput = eroder.Erode(currentHeightArray, configuration, 1); var sedimentExtentsArr = debuggingOutput.SedimentSnapshots .Select(c => MyArrayUtils.CalculateExtremes(c.Array)).ToList(); var sedimentExtents = new ArrayExtremes(sedimentExtentsArr.Min(c => c.Min), sedimentExtentsArr.Max(c => c.Max)); debuggingOutput.SedimentSnapshots.ForEach(c => MyArrayUtils.Normalize(c.Array, sedimentExtents)); var waterExtentsArr = debuggingOutput.WaterSnapshots.Select(c => MyArrayUtils.CalculateExtremes(c.Array)) .ToList(); var waterExtents = new ArrayExtremes(waterExtentsArr.Min(c => c.Min), waterExtentsArr.Max(c => c.Max)); debuggingOutput.WaterSnapshots.ForEach(c => MyArrayUtils.Normalize(c.Array, waterExtents)); _go = GameObject.CreatePrimitive(PrimitiveType.Quad); var material = new Material(Shader.Find("Custom/Terrain/Terrain_Debug_Comparision_StepByStep")); _go.GetComponent <MeshRenderer>().material = material; _go.name = "Terrain"; _go.transform.localRotation = Quaternion.Euler(0, 0, 0); _go.transform.localScale = new Vector3(10, 1, 10); _go.transform.localPosition = new Vector3(0, 0, 0); _go.GetComponent <MeshFilter>().mesh = PlaneGenerator.CreateFlatPlaneMesh(240, 240); MyHeightTextureArray heightTextureArray = new MyHeightTextureArray(240, 240, 2, TextureFormat.ARGB32, false, true); heightTextureArray.AddElementArray(heightmap1, 0); heightTextureArray.AddElementArray(new HeightmapArray(currentHeightArray.Array), 1); _go.GetComponent <MeshRenderer>().material .SetTexture("_HeightmapTexArray", heightTextureArray.ApplyAndRetrive()); MyHeightTextureArray waterArray = new MyHeightTextureArray(240, 240, debuggingOutput.WaterSnapshots.Count, TextureFormat.ARGB32, false, true); int i = 0; foreach (var waterSnapshot in debuggingOutput.WaterSnapshots) { waterArray.AddElementArray(new HeightmapArray(waterSnapshot.Array), i); i++; } _go.GetComponent <MeshRenderer>().material.SetTexture("_WaterArray", waterArray.ApplyAndRetrive()); MyHeightTextureArray sedimentArray = new MyHeightTextureArray(240, 240, debuggingOutput.SedimentSnapshots.Count, TextureFormat.ARGB32, false, true); int j = 0; foreach (var sedimentSnapshot in debuggingOutput.SedimentSnapshots) { sedimentArray.AddElementArray(new HeightmapArray(sedimentSnapshot.Array), j); j++; } _go.GetComponent <MeshRenderer>().material.SetTexture("_SedimentArray", sedimentArray.ApplyAndRetrive()); }
public void Start_Mai_Debug() { var heightTexture1 = SavingFileManager.LoadPngTextureFromFile(@"C:\inz\cont\smallCut.png", 240, 240, TextureFormat.RGBA32, true, true); var heightmap1 = HeightmapUtils.CreateHeightmapArrayFromTexture(heightTexture1); //DiamondSquareCreator creator = new DiamondSquareCreator(new RandomProvider(22)); //var heightmap2 = creator.CreateDiamondSquareNoiseArray(new IntVector2(240, 240), 64); //MyArrayUtils.Multiply(heightmap2.HeightmapAsArray, 0.1f); //HeightmapArray workingHeightmap = LoadHeightmapFromTextureFile(@"C:\inz\cont\temp3.png"); HeightmapArray workingHeightmap = heightmap1; MyArrayUtils.Normalize(workingHeightmap.HeightmapAsArray); MyArrayUtils.InvertNormalized(workingHeightmap.HeightmapAsArray); HeightmapArray originalMap = new HeightmapArray(MyArrayUtils.DeepClone(workingHeightmap.HeightmapAsArray)); MyArrayUtils.Multiply(workingHeightmap.HeightmapAsArray, 400); var configuration = new MeiHydraulicEroderConfiguration() { StepCount = 50, A_PipeCrossSection = 0.05f, ConstantWaterAdding = 1 / 64f, GravityAcceleration = 9.81f, DeltaT = 1f, DepositionConstant = 0.0001f * 12 * 2f, DissolvingConstant = 0.0001f * 12 * 2f, EvaporationConstant = 0.05f * 10, GridSize = new Vector2(1, 1), L_PipeLength = 1, SedimentCapacityConstant = 250 }; var eroder = new MeiHydraulicEroder(); var debOutput = eroder.ErodeWithDebug(SimpleHeightArray.FromHeightmap(workingHeightmap), configuration); MyArrayUtils.Multiply(workingHeightmap.HeightmapAsArray, 1f / 400); debOutput.NormalizeInGroups(); _go = GameObject.CreatePrimitive(PrimitiveType.Quad); var material = new Material(Shader.Find("Custom/Terrain/Terrain_Mei_Debug_Comparision_StepByStep")); _go.GetComponent <MeshRenderer>().material = material; _go.name = "Terrain"; _go.transform.localRotation = Quaternion.Euler(0, 0, 0); _go.transform.localScale = new Vector3(10, 1, 10); _go.transform.localPosition = new Vector3(0, 0, 0); _go.GetComponent <MeshFilter>().mesh = PlaneGenerator.CreateFlatPlaneMesh(240, 240); MyHeightTextureArray heightTextureArray = new MyHeightTextureArray(240, 240, 2, TextureFormat.ARGB32, false, true); heightTextureArray.AddElementArray(originalMap, 0); heightTextureArray.AddElementArray(workingHeightmap, 1); _go.GetComponent <MeshRenderer>().material .SetTexture("_HeightmapTexArray", heightTextureArray.ApplyAndRetrive()); var arrayListsCount = debOutput.OneArrayListCount; var arrayListsLength = debOutput.OneArrayListLength; MyHeightTextureArray detailHeightTexturesArray = new MyHeightTextureArray(240, 240, arrayListsCount * arrayListsLength, TextureFormat.ARGB32, false, true); foreach (var snapshot in debOutput.ArraysDict.Values.SelectMany(c => c)) { detailHeightTexturesArray.AddElementArray(snapshot); } _go.GetComponent <MeshRenderer>().material .SetTexture("_DetailTexArray", detailHeightTexturesArray.ApplyAndRetrive()); _go.GetComponent <MeshRenderer>().material.SetFloat("_DetailTexLength", arrayListsLength); }