示例#1
0
    void CreateRenderBuffer(ScriptableRenderContext context)
    {
        int bufferWidth  = Screen.width;
        int bufferHeight = Screen.height;

#if !UNITY_EDITOR
        bufferWidth  >>= 1;
        bufferHeight >>= 1;
#endif

        CmdBuff.GetTemporaryRT(RenderBuffer1ID, bufferWidth, bufferHeight, 0, FilterMode.Bilinear, RenderTextureFormat.DefaultHDR);
        CmdBuff.GetTemporaryRT(RenderBuffer2ID, bufferWidth, bufferHeight, 0, FilterMode.Bilinear, RenderTextureFormat.DefaultHDR);
        CmdBuff.GetTemporaryRT(DepthBufferID, bufferWidth, bufferHeight, 16, FilterMode.Point, RenderTextureFormat.Depth);
        CmdBuff.GetTemporaryRT(ShadowBufferID, (int)shadowMapSize, (int)shadowMapSize, 16, FilterMode.Bilinear, RenderTextureFormat.Shadowmap);

        if (renderBuffers == null)
        {
            renderBuffers = new RenderTargetIdentifier[4];
        }
        renderBuffers[0] = new RenderTargetIdentifier(RenderBuffer1ID);
        renderBuffers[1] = new RenderTargetIdentifier(RenderBuffer2ID);
        renderBuffers[2] = new RenderTargetIdentifier(DepthBufferID);
        renderBuffers[3] = new RenderTargetIdentifier(ShadowBufferID);

        context.ExecuteCommandBuffer(CmdBuff);
        CmdBuff.Clear();
    }