Exemplo n.º 1
0
 public CustomRenderPipeline(CustomRenderPipelineAsset asset)
 {
     RTHandles.Initialize(1, 1, false, MSAASamples.None);
     CreateSharedBuffer();
     CreateGBuffers();
     m_LightCullingPass    = new LightCullingPass();
     m_DeferredLightingMat = CoreUtils.CreateEngineMaterial(Shader.Find("CustomSRP/DeferredLighting"));
     m_DebugLightCountMat  = CoreUtils.CreateEngineMaterial(Shader.Find("Hidden/DebugLightCountShader"));
     m_NumberCharts        = asset.NumberChartTexture;
     m_DebugTileCount      = asset.DebugTileCount;
 }
Exemplo n.º 2
0
    public StochasticRasterizerInstance()
    {
        m_PostProcessRenderContext = new PostProcessRenderContext();

        int w = Screen.width; int h = Screen.height;

        // Initial state of the RTHandle system.
        // Tells the system that we will require MSAA or not so that we can avoid wasteful render texture allocation.
        // TODO: Might want to initialize to at least the window resolution to avoid un-necessary re-alloc in the player
        RTHandles.Initialize(1, 1, true, (MSAASamples)k_MSAASamples);
        RTHandles.SetReferenceSize(w, h, (MSAASamples)k_MSAASamples);

        InitializeBuffers();

        m_FinalPass = CoreUtils.CreateEngineMaterial(Shader.Find("Hidden/StochasticRasterizer/FinalPass"));
    }
        protected override void Render(ScriptableRenderContext RenderContext, Camera[] Views)
        {
            //Init FrameContext
            GPUScene.Gather(GetWorld().GetMeshBatchColloctor(), true);
            //Debug.Log("X : " + Screen.width + "__" + "Y : " + Screen.height);
            RTHandles.Initialize(Screen.width, Screen.height, false, MSAASamples.None);

            //Render Pipeline
            BeginFrameRendering(RenderContext, Views);
            for (int ViewIndex = 0; ViewIndex < Views.Length; ViewIndex++)
            {
                //Init View
                Camera          View      = Views[ViewIndex];
                CommandBuffer   CmdBuffer = CommandBufferPool.Get("");
                CameraComponent HDView    = View.GetComponent <CameraComponent>();

                //Render View
                BeginCameraRendering(RenderContext, View);
                {
                    using (new ProfilingScope(CmdBuffer, HDView ? HDView.ViewProfiler : ProfilingSampler.Get(ERGProfileId.InfinityRenderer)))
                    {
                        #region InitViewContext
                        bool bSceneView    = View.cameraType == CameraType.SceneView;
                        bool bRendererView = View.cameraType == CameraType.Game || View.cameraType == CameraType.Reflection || View.cameraType == CameraType.SceneView;

                            #if UNITY_EDITOR
                        if (bSceneView)
                        {
                            ScriptableRenderContext.EmitWorldGeometryForSceneView(View);
                        }
                            #endif

                        VFXManager.PrepareCamera(View);
                        ViewUnifrom.UnpateBufferData(false, View);
                        ViewUnifrom.BindGPUParameter(CmdBuffer);
                        RenderContext.SetupCameraProperties(View);
                        VFXManager.ProcessCameraCommand(View, CmdBuffer);

                        //Culling Context
                        FCullingData CullingData = new FCullingData();
                        { CullingData.bRendererView = bRendererView; }
                        ScriptableCullingParameters CullingParameters;
                        View.TryGetCullingParameters(out CullingParameters);
                        CullingResults CullingResult = RenderContext.Cull(ref CullingParameters);     //Unity Culling
                        RenderContext.DispatchCull(GPUScene, ref CullingParameters, ref CullingData); //Infinity Culling
                        #endregion                                                                    //InitViewContext

                        #region InitViewCommand
                        RenderOpaqueDepth(View, CullingData, CullingResult);
                        RenderOpaqueGBuffer(View, CullingData, CullingResult);
                        RenderOpaqueMotion(View, CullingData, CullingResult);
                        RenderOpaqueForward(View, CullingData, CullingResult);
                        RenderSkyBox(View);
                        RenderGizmo(View, GizmoSubset.PostImageEffects);
                        RenderPresentView(View, GraphBuilder.ScopeTexture(InfinityShaderIDs.DiffuseBuffer), View.targetTexture);
                        #endregion //InitViewCommand

                        #region ExecuteViewRender
                        GraphBuilder.Execute(RenderContext, GetWorld(), CmdBuffer, ViewUnifrom.FrameIndex);
                        #endregion //ExecuteViewRender

                        #region ReleaseViewContext
                        CullingData.Release();
                        ViewUnifrom.UnpateBufferData(true, View);
                        #endregion //ReleaseViewContext
                    }
                }
                EndCameraRendering(RenderContext, View);

                //Submit View
                RenderContext.ExecuteCommandBuffer(CmdBuffer);
                CommandBufferPool.Release(CmdBuffer);
                RenderContext.Submit();
            }
            EndFrameRendering(RenderContext, Views);

            //Release FrameContext
            GPUScene.Release();
        }