Пример #1
0
        protected void CreateCopyRT(RenderTextureContainer rtc, VectorInt2 rtSize, int rtDepth, bool rtUseMipMap, RenderTextureFormat rtFormat, FilterMode rtFilterMode = FilterMode.Point, RenderTextureReadWrite rtReadWrite = RenderTextureReadWrite.Default, TextureWrapMode rtWrapMode = TextureWrapMode.Clamp, string rtName = "RenderTexture")
        {
            RenderTexture tempRT = null;

            try {
                RenderTexture rt            = rtc;
                var           hasPreviousRT = rt != null && rt.IsCreated();
                if (hasPreviousRT)
                {
                    var tempRTReadWrite = rt.sRGB ? RenderTextureReadWrite.sRGB : RenderTextureReadWrite.Linear;
                    tempRT            = RenderTexture.GetTemporary(rt.width, rt.height, rt.depth, rt.format, tempRTReadWrite, rt.antiAliasing);
                    tempRT.filterMode = rt.filterMode;
                    Graphics.Blit(rtc, tempRT);
                }

                CreateRT(rtc, rtSize, rtDepth, rtUseMipMap, rtFormat, rtFilterMode, rtReadWrite, rtWrapMode, rtName);

                if (hasPreviousRT)
                {
                    Graphics.Blit(tempRT, rtc);
                }
            } finally {
                if (tempRT != null)
                {
                    RenderTexture.ReleaseTemporary(tempRT);
                }
            }
        }
Пример #2
0
        protected void CreateRT(RenderTextureContainer rtc, VectorInt2 rtSize, int rtDepth, bool rtUseMipMap, RenderTextureFormat rtFormat, FilterMode rtFilterMode = FilterMode.Point, RenderTextureReadWrite rtReadWrite = RenderTextureReadWrite.Default, TextureWrapMode rtWrapMode = TextureWrapMode.Clamp, string rtName = "RenderTexture")
        {
            RenderTexture rt = rtc;

            if (rt == null ||          // if at least one difference, release old texture and create a new one:
                rtSize != new VectorInt2(rt.width, rt.height) ||
                rtDepth != rt.depth ||
                rtUseMipMap != rt.useMipMap ||
                rtFormat != rt.format ||
                rtFilterMode != rt.filterMode
                //	|| rtReadWrite  != (rt.sRGB ? RenderTextureReadWrite.sRGB : RenderTextureReadWrite.Linear)
                || rtWrapMode != rt.wrapMode ||
                rtName != rt.name ||
                false
                )
            {
                // if at least one difference, release old texture and create a new one:
                //	if (rt != null && rt.IsCreated()) {
                //		rt.Release();
                //	}
                rtc.setRT(new RenderTexture(Math.Max(1, rtSize.x), Math.Max(1, rtSize.y), rtDepth, rtFormat, rtReadWrite)
                {
                    filterMode       = rtFilterMode,
                    wrapMode         = rtWrapMode,
                    useMipMap        = rtUseMipMap,
                    autoGenerateMips = false,
                    antiAliasing     = 1,
                    name             = rtName
                });
            }
            m_OldRenderTextures.Remove(rtc);
            m_RenderTextures.Add(rtc);
        }
Пример #3
0
 protected void CreateCopyRT(RenderTextureContainer rtc, VectorInt2 rtSize, RenderTextureFormat rtFormat, FilterMode rtFilterMode = FilterMode.Point, RenderTextureReadWrite rtReadWrite = RenderTextureReadWrite.Default, TextureWrapMode rtWrapMode = TextureWrapMode.Clamp, string rtName = "RenderTexture")
 {
     CreateCopyRT(rtc, rtSize, 0, rtFormat, rtFilterMode, rtReadWrite, rtWrapMode, rtName);
 }