Пример #1
0
        /// <summary>
        /// 更新数据,在每次设置完值后需要手动调用;
        /// </summary>
        public void Updata()
        {
            int chunkWidth  = (int)Math.Round(LandformChunkInfo.ChunkWidth * textureSize);
            int chunkHeight = (int)Math.Round(LandformChunkInfo.ChunkHeight * textureSize);

            LandformDiffuseMap = new BakeTextureInfo(chunkWidth, chunkHeight, diffuseMapRatios, OutlineScale);
            LandformHeightMap  = new BakeTextureInfo(chunkWidth, chunkHeight, heightMapRatios, OutlineScale);
        }
Пример #2
0
        private Texture2D GetHeightMap(RenderTexture rt, TextureFormat format = TextureFormat.RGB24, bool mipmap = false)
        {
            BakeTextureInfo texInfo = Quality.LandformHeightMap;

            RenderTexture.active = rt;
            Texture2D diffuseTex = new Texture2D(texInfo.Width, texInfo.Height, format, mipmap);

            diffuseTex.ReadPixels(texInfo.ClippingRect, 0, 0, false);
            diffuseTex.wrapMode = TextureWrapMode.Clamp;
            diffuseTex.Apply();
            return(diffuseTex);
        }
Пример #3
0
        /// <summary>
        /// 烘培,仅在Unity线程调用;
        /// </summary>
        public LandformBakeResult Bake(LandformBakeRequest request)
        {
            BakeTextureInfo landformDiffuseInfo = Quality.LandformDiffuseMap;
            RenderTexture   diffuseRT           = RenderTexture.GetTemporary(landformDiffuseInfo.BakeWidth, landformDiffuseInfo.BakeHeight);

            BakeTextureInfo landformHeightInfo = Quality.LandformHeightMap;
            RenderTexture   heightRT           = RenderTexture.GetTemporary(landformHeightInfo.BakeWidth, landformHeightInfo.BakeHeight);

            PrepareBakeScene(request.ChunkCoord, request.BakePoints);
            CameraRender(request.ChunkCoord, diffuseRT);
            BoardsDisplayHeight(request.BakePoints);
            CameraRender(request.ChunkCoord, heightRT);

            LandformBakeResult result = new LandformBakeResult()
            {
                DiffuseMap = GetDiffuseMap(diffuseRT),
                HeightMap  = GetHeightMap(heightRT),
            };

            RenderTexture.ReleaseTemporary(diffuseRT);
            RenderTexture.ReleaseTemporary(heightRT);
            return(result);
        }
Пример #4
0
        /// <summary>
        /// 获取到临时烘焙高度贴图的 "RenderTexture";
        /// </summary>
        public RenderTexture GetHeightTemporaryRender()
        {
            BakeTextureInfo texInfo = quality.LandformHeightMap;

            return(RenderTexture.GetTemporary(texInfo.BakeWidth, texInfo.BakeHeight));
        }