Exemplo n.º 1
0
        private void RenderTexture_To_Texture2D(Texture2D tex)
        {
            if (!texture2D)
            {
                return;
            }

            var rt = renderTexture;

            TexMGMT.TryApplyBufferChangesTo(this);

            if (!rt && TexMGMT.imgMetaUsingRendTex == this)
            {
                rt = RenderTextureBuffersManager.GetDownscaledBigRt(width, height);
            }

            //Graphics.CopyTexture();

            if (!rt)
            {
                return;
            }

            tex.CopyFrom(rt);

            PixelsFromTexture2D(tex);

            var converted = false;

            if (PainterCamera.Inst.IsLinearColorSpace)
            {
                if (!tex.IsColorTexture())
                {
                    converted = true;
                    PixelsToLinear();
                }
            }

            if (converted)
            {
                SetAndApply();
            }
            else
            {
                texture2D.Apply(true);
            }
        }
Exemplo n.º 2
0
        public void RenderTexture_To_Texture2D(Texture2D tex)
        {
            if (!texture2D)
            {
                return;
            }

            var rt = renderTexture;

            TexMGMT.TryApplyBufferChangesTo(this);

            if (!rt && TexMGMT.imgMetaUsingRendTex == this)
            {
                rt = RenderTextureBuffersManager.GetDownscaledBigRt(width, height);
            }

            if (!rt)
            {
                return;
            }

            tex.CopyFrom(rt);

            PixelsFromTexture2D(tex);

            var converted = false;

            /* MAC:
             *      Linear Space
             *          Big RT
             *              Editor
             *                  Linear Texture = To Linear
             *                  sRGB Texture =
             *              Playtime
             *                  Linear Texture = To Linear
             *                  sRGB Texture =
             *          Exclusive
             *              Editor
             *                  Linear Texture =
             *                  sRGB Texture =
             *              Playtime
             *                  Linear Texture
             *                  sRGB Texture =
             *      Gamma Space
             *          Big RT
             *              Editor
             *                  Linear Texture =
             *                  sRGB Texture =
             *              Playtime
             *                  Linear Texture
             *                  sRGB Texture =
             *          Exclusive
             *              Editor
             *                  Linear Texture =
             *                  sRGB Texture =
             *              Playtime
             *                  Linear Texture =
             *                  sRGB Texture =
             */


            if (PainterCamera.Inst.IsLinearColorSpace)
            {
                if (!tex.IsColorTexture())
                {
                    converted = true;
                    PixelsToLinear();
                }

#if UNITY_2017
                if (renderTexture != null)
                {
                    PixelsToGamma();
                    converted = true;
                }
#endif
            }


            //if (!RenderTexturePainter.inst.isLinearColorSpace)
            //pixelsToLinear ();

            if (converted)
            {
                SetAndApply();
            }
            else
            {
                texture2D.Apply(true);
            }
            //
        }