Exemplo 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);
        }
Exemplo n.º 2
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);
        }
Exemplo n.º 3
0
        public override void Execute(ScriptableRenderer renderer, ScriptableRenderContext context, ref RenderingData renderingData)
        {
            if (m_WaterCausticMaterial == null)
            {
                Debug.LogErrorFormat("Missing caustic material}. {0} render pass will not execute. Check for missing reference in the renderer resources.", GetType().Name);
                return;
            }
            CommandBuffer cmd = CommandBufferPool.Get(k_RenderWaterCausticsTag);

            m_view = renderingData.cameraData.camera.worldToCameraMatrix;
            m_proj = renderingData.cameraData.camera.projectionMatrix;

            cmd.SetViewProjectionMatrices(Matrix4x4.identity, Matrix4x4.identity);
            ScriptableRenderer.RenderFullscreenQuad(cmd, m_WaterCausticMaterial);
            context.ExecuteCommandBuffer(cmd);

            cmd.Clear();

            cmd.SetViewProjectionMatrices(m_view, m_proj);
            context.ExecuteCommandBuffer(cmd);
            CommandBufferPool.Release(cmd);
        }