Esempio n. 1
0
        public void OnRenderImage(RenderTexture src, RenderTexture dest)
        {
            if (asProxyOf != null)
            {
                asProxyOf.OnRenderImage(src, dest);
                return;
            }

            var matCnt = EnabledMaterials().Count();

            if (matCnt == 0)
            {
                Graphics.Blit(src, dest);
                return;
            }

            if (matCnt == 1)
            {
                var mat = EnabledMaterials().First();
                Graphics.Blit(src, dest, mat);
                return;
            }

            // double buffer pattern
            RenderTexture[] buffers = { RenderTexture.GetTemporary(src.descriptor), dest };
            // dest might be null
            // for matCnt == 2, src -> buffers[0] -> dest, fine
            // issue will occur when matCnt >= 3
            var destUseTmp = dest == null && matCnt >= 3;

            if (destUseTmp)
            {
                buffers[1] = RenderTexture.GetTemporary(src.descriptor);
            }

            // the final result is in buffers[1]
            var from  = matCnt % 2;
            var first = true;

            foreach (var mat in EnabledMaterials())
            {
                if (first)
                {
                    Graphics.Blit(src, buffers[from], mat);
                    first = false;
                    continue;
                }

                Graphics.Blit(buffers[from], buffers[1 - from], mat);
                from = 1 - from;
            }

            if (destUseTmp)
            {
                Graphics.Blit(buffers[1], dest);
                RenderTexture.ReleaseTemporary(buffers[1]);
            }

            RenderTexture.ReleaseTemporary(buffers[0]);
        }
Esempio n. 2
0
 static int OnRenderImage(IntPtr L)
 {
     try
     {
         ToLua.CheckArgsCount(L, 3);
         Nova.PostProcessing       obj  = (Nova.PostProcessing)ToLua.CheckObject <Nova.PostProcessing>(L, 1);
         UnityEngine.RenderTexture arg0 = (UnityEngine.RenderTexture)ToLua.CheckObject <UnityEngine.RenderTexture>(L, 2);
         UnityEngine.RenderTexture arg1 = (UnityEngine.RenderTexture)ToLua.CheckObject <UnityEngine.RenderTexture>(L, 3);
         obj.OnRenderImage(arg0, arg1);
         return(0);
     }
     catch (Exception e)
     {
         return(LuaDLL.toluaL_exception(L, e));
     }
 }