Esempio n. 1
0
        public override void Execute(ScriptableRenderer renderer, ScriptableRenderContext context, ref RenderingData renderingData)
        {
            if (renderer == null)
            {
                throw new ArgumentNullException("renderer");
            }

            m_CopyResult.Setup(RenderTargetHandle.CameraTarget, afterAll);
            m_CopyResult.Execute(renderer, context, ref renderingData);

            Material material = renderer.GetMaterial(MaterialHandle.Blit);

            CommandBuffer cmd = CommandBufferPool.Get("Blit Pass");

            cmd.SetRenderTarget(BuiltinRenderTextureType.CameraTarget);
            cmd.SetViewProjectionMatrices(Matrix4x4.identity, Matrix4x4.identity);

            cmd.SetViewport(new Rect(0, renderingData.cameraData.camera.pixelRect.height / 2.0f, renderingData.cameraData.camera.pixelRect.width / 3.0f, renderingData.cameraData.camera.pixelRect.height / 2.0f));
            cmd.SetGlobalTexture("_BlitTex", afterDepth.Identifier());
            ScriptableRenderer.RenderFullscreenQuad(cmd, material);

            cmd.SetViewport(new Rect(renderingData.cameraData.camera.pixelRect.width / 3.0f, renderingData.cameraData.camera.pixelRect.height / 2.0f, renderingData.cameraData.camera.pixelRect.width / 3.0f, renderingData.cameraData.camera.pixelRect.height / 2.0f));
            cmd.SetGlobalTexture("_BlitTex", afterOpaque.Identifier());
            ScriptableRenderer.RenderFullscreenQuad(cmd, material);

            cmd.SetViewport(new Rect(renderingData.cameraData.camera.pixelRect.width / 3.0f * 2.0f, renderingData.cameraData.camera.pixelRect.height / 2.0f, renderingData.cameraData.camera.pixelRect.width / 3.0f, renderingData.cameraData.camera.pixelRect.height / 2.0f));
            cmd.SetGlobalTexture("_BlitTex", afterOpaquePost.Identifier());
            ScriptableRenderer.RenderFullscreenQuad(cmd, material);

            cmd.SetViewport(new Rect(0f, 0f, renderingData.cameraData.camera.pixelRect.width / 3.0f, renderingData.cameraData.camera.pixelRect.height / 2.0f));
            cmd.SetGlobalTexture("_BlitTex", afterSkybox.Identifier());
            ScriptableRenderer.RenderFullscreenQuad(cmd, material);

            cmd.SetViewport(new Rect(renderingData.cameraData.camera.pixelRect.width / 3.0f, 0f, renderingData.cameraData.camera.pixelRect.width / 3.0f, renderingData.cameraData.camera.pixelRect.height / 2.0f));
            cmd.SetGlobalTexture("_BlitTex", afterTransparent.Identifier());
            ScriptableRenderer.RenderFullscreenQuad(cmd, material);


            //TODO: Upsidown UV trash, ignore this for now
            // Need to flip UV as we come from a framebuffer.

            /*cmd.SetViewport(new Rect(renderingData.cameraData.camera.pixelRect.width / 3.0f * 2.0f, 0f, renderingData.cameraData.camera.pixelRect.width / 3.0f, renderingData.cameraData.camera.pixelRect.height / 2.0f));
             * cmd.SetGlobalTexture("_BlitTex", afterAll.Identifier());
             * cmd.EnableShaderKeyword("FLIP_VERTICAL_UV");
             * LightweightPipeline.DrawFullScreen(cmd, material);
             * cmd.DisableShaderKeyword("FLIP_VERTICAL_UV");*/

            context.ExecuteCommandBuffer(cmd);
            CommandBufferPool.Release(cmd);
        }
Esempio n. 2
0
    public override void Execute(ScriptableRenderer renderer, ScriptableRenderContext context, ref RenderingData renderingData)
    {
        Material material = renderer.GetMaterial(MaterialHandles.Blit);
        RenderTargetIdentifier sourceRT = colorAttachmentHandle.Identifier();

        CommandBuffer cmd = commandBufferPool.Get(k_FinalBlitTag);

        cmd.SetGlobalTexture("_BlitTex", sourceRT);

        //if(!renderingData.cameraData.isDefaultViewport)

        cmd.Blit(colorAttachmentHandle.Identifier(), BuiltinRenderTextureType.CameraTarget, material);

        context.ExecuteCommandBuffer(cmd);
        commandBufferPool.Release(cmd);
    }
Esempio n. 3
0
        public override void Execute(ScriptableRenderer renderer, ScriptableRenderContext context, ref RenderingData renderingData)
        {
            if (renderer == null)
            {
                throw new ArgumentNullException("renderer");
            }

            var pass = new CopyColorPass();

            pass.Setup(colorHandle, afterAll);
            pass.Execute(renderer, context, ref renderingData);

            Material material = renderer.GetMaterial(MaterialHandle.Blit);

            CommandBuffer cmd = CommandBufferPool.Get("Blit Pass");

            cmd.SetRenderTarget(colorHandle.id, depthHandle.id);
            cmd.SetViewProjectionMatrices(Matrix4x4.identity, Matrix4x4.identity);

            cmd.SetViewport(new Rect(0, renderingData.cameraData.camera.pixelRect.height / 2.0f, renderingData.cameraData.camera.pixelRect.width / 3.0f, renderingData.cameraData.camera.pixelRect.height / 2.0f));
            cmd.SetGlobalTexture("_BlitTex", afterDepth.Identifier());
            ScriptableRenderer.RenderFullscreenQuad(cmd, material);

            cmd.SetViewport(new Rect(renderingData.cameraData.camera.pixelRect.width / 3.0f, renderingData.cameraData.camera.pixelRect.height / 2.0f, renderingData.cameraData.camera.pixelRect.width / 3.0f, renderingData.cameraData.camera.pixelRect.height / 2.0f));
            cmd.SetGlobalTexture("_BlitTex", afterOpaque.Identifier());
            ScriptableRenderer.RenderFullscreenQuad(cmd, material);

            cmd.SetViewport(new Rect(renderingData.cameraData.camera.pixelRect.width / 3.0f * 2.0f, renderingData.cameraData.camera.pixelRect.height / 2.0f, renderingData.cameraData.camera.pixelRect.width / 3.0f, renderingData.cameraData.camera.pixelRect.height / 2.0f));
            cmd.SetGlobalTexture("_BlitTex", afterOpaquePost.Identifier());
            ScriptableRenderer.RenderFullscreenQuad(cmd, material);

            cmd.SetViewport(new Rect(0f, 0f, renderingData.cameraData.camera.pixelRect.width / 3.0f, renderingData.cameraData.camera.pixelRect.height / 2.0f));
            cmd.SetGlobalTexture("_BlitTex", afterSkybox.Identifier());
            ScriptableRenderer.RenderFullscreenQuad(cmd, material);

            cmd.SetViewport(new Rect(renderingData.cameraData.camera.pixelRect.width / 3.0f, 0f, renderingData.cameraData.camera.pixelRect.width / 3.0f, renderingData.cameraData.camera.pixelRect.height / 2.0f));
            cmd.SetGlobalTexture("_BlitTex", afterTransparent.Identifier());
            ScriptableRenderer.RenderFullscreenQuad(cmd, material);

            cmd.SetViewport(new Rect(renderingData.cameraData.camera.pixelRect.width / 3.0f * 2.0f, 0f, renderingData.cameraData.camera.pixelRect.width / 3.0f, renderingData.cameraData.camera.pixelRect.height / 2.0f));
            cmd.SetGlobalTexture("_BlitTex", afterAll.Identifier());
            ScriptableRenderer.RenderFullscreenQuad(cmd, material);

            context.ExecuteCommandBuffer(cmd);
            CommandBufferPool.Release(cmd);
        }
Esempio n. 4
0
    public override void Execute(ScriptableRenderer renderer, ScriptableRenderContext context, ref RenderingData renderingData)
    {
        var cmd = commandBufferPool.Get(k_blurTag);

        m_Material = renderer.GetMaterial(MaterialHandles.Blur);
        int res = renderingData.shadowData.directionalShadowAltasRes / downSample;

        cmd.GetTemporaryRT(destination.id, res, res, 0, FilterMode.Bilinear, RenderTextureFormat.RG32);

        RenderTexture buffer0 = RenderTexture.GetTemporary(res, res, 0, RenderTextureFormat.RG32, RenderTextureReadWrite.Linear);

        cmd.Blit(source.Identifier(), buffer0);



        for (int i = 0; i < iteration; i++)
        {
            m_Material.SetFloat("_BlurSize", 1.0f + i * blurSpread);
            RenderTexture buffer1 = RenderTexture.GetTemporary(res, res, 0, RenderTextureFormat.RG32, RenderTextureReadWrite.Linear);

            cmd.Blit(buffer0, buffer1, m_Material, 0);

            RenderTexture.ReleaseTemporary(buffer0);
            buffer0 = buffer1;
            buffer1 = RenderTexture.GetTemporary(res, res, 0, RenderTextureFormat.RG32, RenderTextureReadWrite.Linear);

            cmd.Blit(buffer0, buffer1, m_Material, 1);

            RenderTexture.ReleaseTemporary(buffer0);
            buffer0 = buffer1;
            context.ExecuteCommandBuffer(cmd);
            cmd.Clear();
        }

        cmd.GetTemporaryRT(destination.id, res, res, 0, FilterMode.Bilinear, RenderTextureFormat.RG32);
        cmd.Blit(buffer0, destination.Identifier());
        RenderTexture.ReleaseTemporary(buffer0);

        context.ExecuteCommandBuffer(cmd);
        commandBufferPool.Release(cmd);
    }
Esempio n. 5
0
    public override void Execute(ScriptableRenderer renderer, ScriptableRenderContext context, ref RenderingData renderingData)
    {
        if (renderingData.lightData.mainLightIndex == -1)
        {
            return;
        }

        var cmd = commandBufferPool.Get(k_CollectShadowTag);

        cmd.GetTemporaryRT(colorAttachmentHandle.id, desc, FilterMode.Bilinear);

        VisibleLight shadowLight = renderingData.lightData.visibleLights[renderingData.lightData.mainLightIndex];

        SetShadowCollectPassKeywords(cmd, ref shadowLight, ref renderingData.shadowData);

        RenderTargetIdentifier screenSpaceOcclusionTexture = colorAttachmentHandle.Identifier();

        SetRenderTarget(cmd, screenSpaceOcclusionTexture, RenderBufferLoadAction.DontCare, RenderBufferStoreAction.Store,
                        ClearFlag.All, Color.white, desc.dimension);
        cmd.Blit(screenSpaceOcclusionTexture, screenSpaceOcclusionTexture, renderer.GetMaterial(MaterialHandles.ScreenSpacceShadow));

        context.ExecuteCommandBuffer(cmd);
        commandBufferPool.Release(cmd);
    }