Exemplo n.º 1
0
        private IEnumerator <BakeResult> BakeInCoroutine(IBakeContent content, Quality quality, CancellationToken token)
        {
            token.ThrowIfCancellationRequested();

            RenderTexture diffuseRT = RenderTexture.GetTemporary(quality.DiffuseMapWidth, quality.DiffuseMapHeight);

            DisplayDiffuse();
            CameraRender(diffuseRT);
            var diffuseMap = CreateTexture(diffuseRT, quality.DiffuseMapWidth, quality.DiffuseMapHeight);

            RenderTexture.ReleaseTemporary(diffuseRT);

            yield return(default(BakeResult));

            if (token.IsCancellationRequested)
            {
                GameObject.Destroy(diffuseMap);
                throw new OperationCanceledException();
            }

            RenderTexture heightRT = RenderTexture.GetTemporary(quality.HeightMapWidth, quality.HeightMapHeight);

            DisplayHeight();
            CameraRender(heightRT);
            var heightMap = CreateTexture(heightRT, quality.HeightMapWidth, quality.HeightMapHeight);

            RenderTexture.ReleaseTemporary(heightRT);

            yield return(default(BakeResult));

            if (token.IsCancellationRequested)
            {
                GameObject.Destroy(diffuseMap);
                GameObject.Destroy(heightMap);
                throw new OperationCanceledException();
            }

            BakeResult result = new BakeResult()
            {
                DiffuseMap = diffuseMap,
                HeightMap  = heightMap,
            };

            yield return(result);
        }
Exemplo n.º 2
0
 public void SetValue(BakeResult value)
 {
     Renderer.SetDiffuseMap(value.DiffuseMap);
     Renderer.SetHeightMap(value.HeightMap);
     Collider.Update();
 }