public WeldMapLevel2Manager(WeldingExecutor weldingExecutor, WeldMapLevel2ManagerConfiguration configuration)
 {
     _configuration   = configuration;
     _weldingExecutor = weldingExecutor;
     _stripColumns    = new WeldMapColumn[configuration.ColumnsCount];
     for (int i = 0; i < configuration.ColumnsCount; i++)
     {
         _stripColumns[i] = new WeldMapColumn(configuration.StripsPerOneColumnCount);
     }
 }
Example #2
0
        private void RunTest2(List <Debug2TerrainSpecification> terrainSpecifications,
                              List <Debug2WeldSpecification> weldSpecifications)
        {
            var dtt = new DebugTerrainTester(ComputeShaderContainer);

            dtt.Start(false, true);

            var terrains = terrainSpecifications.Select(s =>
            {
                var realTerrain = dtt.TerrainShapeDbProxy.Query(new TerrainDescriptionQuery()
                {
                    QueryArea = s.QueryArea,
                    RequestedElementDetails = new List <TerrainDescriptionQueryElementDetail>()
                    {
                        new TerrainDescriptionQueryElementDetail()
                        {
                            Type       = TerrainDescriptionElementTypeEnum.HEIGHT_ARRAY,
                            Resolution = TerrainCardinalResolution.MIN_RESOLUTION
                        }
                    }
                }).Result.GetElementOfType(TerrainDescriptionElementTypeEnum.HEIGHT_ARRAY);
                return(new HeightTextureWithUvBase()
                {
                    Texture = realTerrain.TokenizedElement.DetailElement.Texture,
                    UvBase = realTerrain.UvBase
                });
            }).ToList();


            var weldTexture = new RenderTexture(1024, 1024, 0, RenderTextureFormat.RFloat);

            weldTexture.wrapMode          = TextureWrapMode.Clamp;
            weldTexture.enableRandomWrite = true;
            weldTexture.filterMode        = FilterMode.Point;
            weldTexture.Create();
            var weldTextureManager = new WeldingExecutor(ComputeShaderContainer,
                                                         new UnityThreadComputeShaderExecutorObject(), weldTexture);

            foreach (var weldSpecification in weldSpecifications)
            {
                var side1Specification = terrainSpecifications[weldSpecification.Index1];
                var side2Specification = terrainSpecifications[weldSpecification.Index2];

                WeldTextureDrawingOrder weldingOrder = new WeldTextureDrawingOrder()
                {
                    WeldOnTextureInfo = new WeldOnTextureInfo()
                    {
                        ColumnIndex = weldSpecification.ColumnIndex,
                        WeldRange   = weldSpecification.WeldRange
                    },
                    FirstSideInfo = new WeldTextureDrawingSideInfo()
                    {
                        ConstantCoord          = weldSpecification.Side1ConstantCoord,
                        FullLodSidePixelsRange = weldSpecification.Side1FullLodSidePixelsRange,
                        HeightTexture          = terrains[weldSpecification.Index1].Texture,
                        LodLevel         = side1Specification.LodLevel,
                        SideType         = weldSpecification.Side1SideType,
                        SamplingDistance = weldSpecification.Side1SamplingDistance
                    },
                    SecondSideInfo = new WeldTextureDrawingSideInfo()
                    {
                        ConstantCoord          = weldSpecification.Side2ConstantCoord,
                        FullLodSidePixelsRange = weldSpecification.Side2FullLodSidePixelsRange,
                        HeightTexture          = terrains[weldSpecification.Index2].Texture,
                        LodLevel         = side2Specification.LodLevel,
                        SideType         = weldSpecification.Side2SideType,
                        SamplingDistance = weldSpecification.Side2SamplingDistance
                    },
                };
                weldTextureManager.RenderWeld(weldingOrder).Wait(5000);
            }

            for (int i = 0; i < terrainSpecifications.Count; i++)
            {
                var specification = terrainSpecifications[i];
                var terrain       = terrains[i];

                CreateDebugObject(new DebugObjectSpecification()
                {
                    HeightTexture      = terrain.Texture,
                    HeightmapUv        = terrain.UvBase.ToVector4(),
                    HeightmapLodOffset = specification.LodLevel,
                    StartPos           = specification.QueryArea.DownLeftPoint,
                    MeshResolution     = specification.MeshResolution,
                    LocalScale         = new Vector3(5760 * terrain.UvBase.Width, 2300, 5760 * terrain.UvBase.Height)
                },
                                  weldTexture,
                                  specification.TerrainWeldUvs
                                  );
            }
        }
Example #3
0
        private void RunTest(DebugOneSideSpecification side1Specification, DebugOneSideSpecification side2Specification)
        {
            var dtt = new DebugTerrainTester(ComputeShaderContainer);

            dtt.Start(false, true);

            var ter1 = side1Specification.HeightTextureWithUvBase;

            if (ter1 == null)
            {
                var realTerrain = dtt.TerrainShapeDbProxy.Query(new TerrainDescriptionQuery()
                {
                    QueryArea = side1Specification.QueryArea,
                    RequestedElementDetails = new List <TerrainDescriptionQueryElementDetail>()
                    {
                        new TerrainDescriptionQueryElementDetail()
                        {
                            Type       = TerrainDescriptionElementTypeEnum.HEIGHT_ARRAY,
                            Resolution = TerrainCardinalResolution.MIN_RESOLUTION
                        }
                    }
                }).Result.GetElementOfType(TerrainDescriptionElementTypeEnum.HEIGHT_ARRAY);
                ter1 = new HeightTextureWithUvBase()
                {
                    Texture = realTerrain.TokenizedElement.DetailElement.Texture,
                    UvBase  = realTerrain.UvBase
                };
            }

            var ter2 = side2Specification.HeightTextureWithUvBase;

            if (ter2 == null)
            {
                var realTerrain = dtt.TerrainShapeDbProxy.Query(new TerrainDescriptionQuery()
                {
                    QueryArea = side2Specification.QueryArea,
                    RequestedElementDetails = new List <TerrainDescriptionQueryElementDetail>()
                    {
                        new TerrainDescriptionQueryElementDetail()
                        {
                            Type       = TerrainDescriptionElementTypeEnum.HEIGHT_ARRAY,
                            Resolution = TerrainCardinalResolution.MIN_RESOLUTION
                        }
                    }
                }).Result.GetElementOfType(TerrainDescriptionElementTypeEnum.HEIGHT_ARRAY);
                ter2 = new HeightTextureWithUvBase()
                {
                    Texture = realTerrain.TokenizedElement.DetailElement.Texture,
                    UvBase  = realTerrain.UvBase
                };
            }

            var weldTexture = new RenderTexture(1024, 1024, 0, RenderTextureFormat.RFloat);

            weldTexture.wrapMode          = TextureWrapMode.Clamp;
            weldTexture.enableRandomWrite = true;
            weldTexture.filterMode        = FilterMode.Point;
            weldTexture.Create();
            var weldTextureManager = new WeldingExecutor(ComputeShaderContainer,
                                                         new UnityThreadComputeShaderExecutorObject(), weldTexture);


            WeldTextureDrawingOrder weldingOrder = new WeldTextureDrawingOrder()
            {
                WeldOnTextureInfo = new WeldOnTextureInfo()
                {
                    ColumnIndex = 0,
                    WeldRange   = new IntVector2(0, 240),
                },
                FirstSideInfo = new WeldTextureDrawingSideInfo()
                {
                    ConstantCoord          = side1Specification.ConstantCoord,
                    FullLodSidePixelsRange = side1Specification.FullLodSidePixelsRange,
                    HeightTexture          = ter1.Texture,
                    LodLevel = side1Specification.LodLevel,
                    SideType = side1Specification.SideType,
                },
                SecondSideInfo = new WeldTextureDrawingSideInfo()
                {
                    ConstantCoord          = side2Specification.ConstantCoord,
                    FullLodSidePixelsRange = side2Specification.FullLodSidePixelsRange,
                    HeightTexture          = ter2.Texture,
                    LodLevel = side2Specification.LodLevel,
                    SideType = side2Specification.SideType,
                },
            };

            weldTextureManager.RenderWeld(weldingOrder).Wait(5000);

            CreateDebugObject(new DebugObjectSpecification()
            {
                HeightTexture      = ter1.Texture,
                HeightmapUv        = ter1.UvBase.ToVector4(),
                HeightmapLodOffset = side1Specification.LodLevel,
                StartPos           = side1Specification.QueryArea.DownLeftPoint,
                MeshResolution     = side1Specification.MeshResolution,
                LocalScale         = new Vector3(5760 * ter1.UvBase.Width, 2300, 5760 * ter1.UvBase.Height)
            },
                              weldTexture,
                              side1Specification.TerrainWeldUvs
                              );

            CreateDebugObject(new DebugObjectSpecification()
            {
                HeightTexture      = ter2.Texture,
                HeightmapUv        = ter2.UvBase.ToVector4(),
                HeightmapLodOffset = side2Specification.LodLevel,
                StartPos           = side2Specification.QueryArea.DownLeftPoint,
                MeshResolution     = side2Specification.MeshResolution,
                LocalScale         = new Vector3(5760 * ter2.UvBase.Width, 2300, 5760 * ter2.UvBase.Height)
            },
                              weldTexture,
                              side2Specification.TerrainWeldUvs
                              );
        }