Пример #1
0
    public void RenderBloomTexture(RenderTexture source, RenderTexture dest)
    {
        RenderTexture curRenderTex = RenderTextureManager.Instance.RequestRenderTexture(source.width, source.height, source.depth, source.format);

        //Prepare by extracting blooming pixels
        Graphics.Blit(source, curRenderTex, Mat, 0);  //Is it ok to extract blooming pixels at 1/4 res??????

        //Downsample & blur
        for (int i = 1; i <= bloomSamples; i++)
        {
            float curSpread = Mathf.Lerp(1f, 2f, (float)(i - 1) / (float)(bloomSamples));

#if FXPRO_EFFECT
            RenderTextureManager.Instance.SafeAssign(ref curRenderTex, CameraEffect.DownsampleTex(curRenderTex, 2f));
#elif BLOOMPRO_EFFECT
            RenderTextureManager.Instance.SafeAssign(ref curRenderTex, BloomPro.DownsampleTex(curRenderTex, 2f));
#elif DOFPRO_EFFECT
            RenderTextureManager.Instance.SafeAssign(ref curRenderTex, DOFPro.DownsampleTex(curRenderTex, 2f));
#endif

            RenderTextureManager.Instance.SafeAssign(ref curRenderTex, BlurTex(curRenderTex, curSpread));

            //Set blurred bloom texture
            Mat.SetTexture("_DsTex" + i, curRenderTex);
        }

        //Bloom composite pass
        Graphics.Blit(null, dest, Mat, 1);

        RenderTextureManager.Instance.ReleaseRenderTexture(curRenderTex);
    }