Exemplo n.º 1
0
        public ForwardRenderer(ForwardRendererData data) : base(data)
        {
            Downsampling downsamplingMethod = LightweightRenderPipeline.asset.opaqueDownsampling;

            Material blitMaterial               = CoreUtils.CreateEngineMaterial(data.blitShader);
            Material copyDepthMaterial          = CoreUtils.CreateEngineMaterial(data.copyDepthShader);
            Material samplingMaterial           = CoreUtils.CreateEngineMaterial(data.samplingShader);
            Material screenspaceShadowsMaterial = CoreUtils.CreateEngineMaterial(data.screenSpaceShadowShader);
            Material ssDownSampleMaterial       = CoreUtils.CreateEngineMaterial("Hidden/Lightweight Render Pipeline/SSDownSample");

            // Note: Since all custom render passes inject first and we have stable sort,
            // we inject the builtin passes in the before events.
            m_MainLightShadowCasterPass        = new MainLightShadowCasterPass(RenderPassEvent.BeforeRenderingShadows);
            m_AdditionalLightsShadowCasterPass = new AdditionalLightsShadowCasterPass(RenderPassEvent.BeforeRenderingShadows);
            m_DepthPrepass = new DepthOnlyPass(RenderPassEvent.BeforeRenderingPrepasses, RenderQueueRange.all);
            m_ScreenSpaceShadowResolvePass = new ScreenSpaceShadowResolvePass(RenderPassEvent.BeforeRenderingPrepasses, screenspaceShadowsMaterial);
            m_SSSDownsamplePass            = new SSShadowDownSamplePass(RenderPassEvent.BeforeRenderingPrepasses, ssDownSampleMaterial);

            m_RenderOpaqueForwardPass = new RenderOpaqueForwardPass(RenderPassEvent.BeforeRenderingOpaques, RenderQueueRange.opaque, data.opaqueLayerMask);

            m_CopyDepthPass         = new CopyDepthPass(RenderPassEvent.BeforeRenderingOpaques, copyDepthMaterial);
            m_OpaquePostProcessPass = new PostProcessPass(RenderPassEvent.BeforeRenderingOpaques, true);
            m_DrawSkyboxPass        = new DrawSkyboxPass(RenderPassEvent.BeforeRenderingSkybox);
            m_CopyColorPass         = new CopyColorPass(RenderPassEvent.BeforeRenderingTransparents, samplingMaterial, downsamplingMethod);
            //m_RenderOpaqueDiscardAndBlendPass = new RenderOpaqueDiscardAndBlendPass(RenderPassEvent.BeforeRenderingTransparents , new RenderQueueRange(2350,2550), data.opaqueLayerMask);

            m_RenderTransparentForwardPass = new RenderTransparentForwardPass(RenderPassEvent.BeforeRenderingTransparents, RenderQueueRange.transparent, data.transparentLayerMask);

            //m_RenderObjectsPass = new RenderObjectsPass(RenderPassEvent.AfterRenderingTransparents, RenderQueueRange.all);

            m_PostProcessPass = new PostProcessPass(RenderPassEvent.BeforeRenderingPostProcessing);
            m_UICameraPass    = new UICameraPass(RenderPassEvent.AfterRendering, RenderQueueRange.transparent, data.transparentLayerMask);
            m_CapturePass     = new CapturePass(RenderPassEvent.AfterRendering);
            m_FinalBlitPass   = new FinalBlitPass(RenderPassEvent.AfterRendering, blitMaterial);

#if UNITY_EDITOR
            m_SceneViewDepthCopyPass = new SceneViewDepthCopyPass(RenderPassEvent.AfterRendering + 9, copyDepthMaterial);
#endif

            // RenderTexture format depends on camera and pipeline (HDR, non HDR, etc)
            // Samples (MSAA) depend on camera and pipeline
            m_CameraColorAttachment.Init("_CameraColorTexture");
            m_CameraDepthAttachment.Init("_CameraDepthAttachment");
            m_DepthTexture.Init("_CameraDepthTexture");
            m_OpaqueColor.Init("_CameraOpaqueTexture");

            //m_CameraNormalAttachment.Init("_CameraNormalAttachment");

            m_ForwardLights = new ForwardLights();
        }
Exemplo n.º 2
0
    private void Init()
    {
        if (m_Initialized)
        {
            return;
        }

        m_DepthOnlyPass                       = new DepthOnlyPass();
        m_MainLightShadowCasterPass           = new MainLightShadowCasterPass();
        m_AdditionalLightsShadowCasterPass    = new AdditionalLightsShadowCasterPass();
        m_SetupForwardRenderingPass           = new SetupForwardRenderingPass();
        m_ScreenSpaceShadowResolvePass        = new ScreenSpaceShadowResolvePass();
        m_CreateLightweightRenderTexturesPass = new CreateLightweightRenderTexturesPass();
        m_BeginXrRenderingPass                = new BeginXRRenderingPass();
        m_SetupLightweightConstants           = new SetupLightweightConstanstPass();
        m_RenderOpaqueForwardPass             = new RenderOpaqueForwardPass();
        m_OpaquePostProcessPass               = new OpaquePostProcessPass();
        m_DrawSkyboxPass                      = new DrawSkyboxPass();
        m_CopyDepthPass                       = new CopyDepthPass();
        m_CopyColorPass                       = new CopyColorPass();
        m_RenderTransparentForwardPass        = new RenderTransparentForwardPass();
        m_RenderTransparentForwardPass2       = new RenderTransparentForwardPass2();
        m_RenderTransparentForwardPass3       = new RenderTransparentForwardPass3();
        m_TransparentPostProcessPass          = new TransparentPostProcessPass();
        m_FinalBlitPass                       = new FinalBlitPass();
        m_EndXrRenderingPass                  = new EndXRRenderingPass();

#if UNITY_EDITOR
        m_SceneViewDepthCopyPass = new SceneViewDepthCopyPass();
#endif

        // RenderTexture format depends on camera and pipeline (HDR, non HDR, etc)
        // Samples (MSAA) depend on camera and pipeline
        ColorAttachment.Init("_CameraColorTexture");
        DepthAttachment.Init("_CameraDepthAttachment");
        DepthTexture.Init("_CameraDepthTexture");
        OpaqueColor.Init("_CameraOpaqueTexture");
        MainLightShadowmap.Init("_MainLightShadowmapTexture");
        AdditionalLightsShadowmap.Init("_AdditionalLightsShadowmapTexture");
        ScreenSpaceShadowmap.Init("_ScreenSpaceShadowmapTexture");

        m_Initialized = true;
    }