Exemplo n.º 1
0
    // --------------------------------------------------------------------
    void RenderOcclusionMapForLight(IL2DLDirectLight directLight)
    {
        L2DLRenderHelpers.BeginSample(m_context, m_occlusionMapRenderingBuffer);
        {
            m_context.SetupCameraProperties(directLight.ShadowCamera);

            if (!directLight.ShadowCamera.TryGetCullingParameters(out m_cullingParameters))
            {
                return;
            }
            m_cullingResults = m_context.Cull(ref m_cullingParameters);

            CoreUtils.SetRenderTarget(m_clearBuffer, new RenderTargetIdentifier[] { m_directLightDummyTextureId, m_directLightOcclusionMapId }, m_directLightDepthTextureId, ClearFlag.All);
            L2DLRenderHelpers.ExecuteBuffer(m_context, m_clearBuffer);

            L2DLRenderHelpers.DrawAllRenderers(m_context, m_cullingResults);
        }
        L2DLRenderHelpers.EndSample(m_context, m_occlusionMapRenderingBuffer);
    }
Exemplo n.º 2
0
    // --------------------------------------------------------------------
    public void Render(ScriptableRenderContext context, Camera camera)
    {
        m_context = context;
        m_camera  = camera;

        // Sample to encapsulate all used buffers under one heading in the frame debugger
        L2DLRenderHelpers.BeginSample(m_context, m_sceneDataRenderBuffer);
        {
            m_context.SetupCameraProperties(m_camera);

            // MUST go before culling so that in world UI is setup pre-cull
            L2DLRenderHelpers.PrepareCameraForSceneWindow(m_camera);

            if (!m_camera.TryGetCullingParameters(out m_cullingParameters))
            {
                return;
            }
            m_cullingResults = m_context.Cull(ref m_cullingParameters);

            //Clear the main output textures
            m_clearTexturebuffer.SetRenderTarget(new RenderTargetIdentifier[]
            {
                L2DLPipelineData.s_cameraColorTextureId
            },
                                                 L2DLPipelineData.s_cameraDepthTextureId);
            if (m_camera.cameraType == CameraType.SceneView)
            {
                // The scene m_camera's settings aren't always set to clear things, it's quite odd so hard code it to clear
                m_clearTexturebuffer.ClearRenderTarget(true, true, m_camera.backgroundColor.linear);
            }
            else
            {
                m_clearTexturebuffer.ClearRenderTarget(m_camera.clearFlags <= CameraClearFlags.Depth, m_camera.clearFlags == CameraClearFlags.Color, m_camera.clearFlags == CameraClearFlags.Color ? m_camera.backgroundColor.linear : Color.clear);
            }

            //Clear the buffer textures
            m_clearTexturebuffer.SetRenderTarget(new RenderTargetIdentifier[]
            {
                L2DLPipelineData.s_cameraOcclusionTextureId,
                L2DLPipelineData.s_cameraEmissionTextureId,
                L2DLPipelineData.s_cameraAdditionalDataTextureId
            },
                                                 L2DLPipelineData.s_cameraDepthTextureId);
            m_clearTexturebuffer.ClearRenderTarget(false, true, Color.clear);
            L2DLRenderHelpers.ExecuteBuffer(m_context, m_clearTexturebuffer);

            // Set render targets for rendering
            m_sceneDataRenderBuffer.SetRenderTarget(new RenderTargetIdentifier[]
            {
                L2DLPipelineData.s_cameraColorTextureId,
                L2DLPipelineData.s_cameraOcclusionTextureId,
                L2DLPipelineData.s_cameraEmissionTextureId,
                L2DLPipelineData.s_cameraAdditionalDataTextureId
            },
                                                    L2DLPipelineData.s_cameraDepthTextureId);
            L2DLRenderHelpers.ExecuteBuffer(m_context, m_sceneDataRenderBuffer);

            L2DLRenderHelpers.DrawAllRenderers(m_context, m_cullingResults);
        }
        L2DLRenderHelpers.EndSample(m_context, m_sceneDataRenderBuffer);

        // Editor Only
        L2DLRenderHelpers.DrawUnsupportedShaders(m_context, m_cullingResults);
    }