Exemplo n.º 1
0
    // --------------------------------------------------------------------
    public void Render(ScriptableRenderContext context, Camera camera, L2DLDirectLights directLights)
    {
        if (!m_directLightData.Enabled)
        {
            return;
        }

        m_context = context;
        m_camera  = camera;

        // Encapsulate in frame debugger
        L2DLRenderHelpers.BeginSample(m_context, m_directLightRenderingBuffer);
        {
            CoreUtils.SetRenderTarget(m_clearBuffer, L2DLPipelineData.s_cameraDirectLightResultTextureId, L2DLPipelineData.s_cameraDepthTextureId, ClearFlag.Color);
            L2DLRenderHelpers.ExecuteBuffer(m_context, m_clearBuffer);

            // Directional Lights
            L2DLRenderHelpers.BeginSample(m_context, m_directionalLightsBuffer);
            foreach (L2DLDirectionalLight directionalLight in directLights.m_directionalLights)
            {
                GetOcclusionTextures((int)directionalLight.ShadowMapSize); // Probably don't need to do this every time?
                RenderOcclusionMapForLight(directionalLight);
                RunDirectionalLightOcclusionMapTrace(directionalLight);
                RunDirectionalLightRendering(directionalLight);
                ReleaseOcclusionTextures();
            }
            L2DLRenderHelpers.EndSample(m_context, m_directionalLightsBuffer);

            // Point Lights
            L2DLRenderHelpers.BeginSample(m_context, m_pointLightsBuffer);
            foreach (L2DLPointLight pointLight in directLights.m_pointLights)
            {
                GetOcclusionTextures((int)pointLight.ShadowMapSize);
                RenderOcclusionMapForLight(pointLight);
                RunPointLightOcclusionMapTrace(pointLight);
                RunPointLightRendering(pointLight);
                ReleaseOcclusionTextures();
            }
            L2DLRenderHelpers.EndSample(m_context, m_pointLightsBuffer);

            // Spot Lights
            L2DLRenderHelpers.BeginSample(m_context, m_spotLightsBuffer);
            foreach (L2DLSpotLight spotLight in directLights.m_spotLights)
            {
                GetOcclusionTextures((int)spotLight.ShadowMapSize);
                RenderOcclusionMapForLight(spotLight);
                RunSpotLightOcclusionMapTrace(spotLight);
                RunSpotLightRendering(spotLight);
                ReleaseOcclusionTextures();
            }
            L2DLRenderHelpers.EndSample(m_context, m_spotLightsBuffer);

            // Reset
            m_context.SetupCameraProperties(m_camera);
        }
        L2DLRenderHelpers.EndSample(m_context, m_directLightRenderingBuffer);
    }
Exemplo n.º 2
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.º 3
0
    // --------------------------------------------------------------------
    public void Render(ScriptableRenderContext context, Camera camera)
    {
        if (!m_indirectLightData.Enabled)
        {
            return;
        }

        m_context = context;
        m_camera  = camera;

        // Encapsulate in frame debugger
        L2DLRenderHelpers.BeginSample(m_context, m_indirectLightRenderingBuffer);
        {
            m_indirectLightData.IndirectLightCalculator?.CalculateIndirectLight(
                m_context,
                m_indirectLightRenderingBuffer,
                m_camera,
                L2DLPipelineData.s_cameraEmissionTextureId,
                L2DLPipelineData.s_cameraOcclusionTextureId,
                L2DLPipelineData.s_cameraIndirectLightResultTextureId);
        }
        L2DLRenderHelpers.EndSample(m_context, m_indirectLightRenderingBuffer);
    }
Exemplo n.º 4
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);
    }