ScriptableRenderPass IAfterDepthPrePass.GetPassToEnqueue(RenderTextureDescriptor baseDescriptor, RenderTargetHandle depthAttachmentHandle)
    {
        var pass = new CopyDepthPass();

        pass.Setup(depthAttachmentHandle, afterDepth);
        return(pass);
    }
Beispiel #2
0
        public Renderer2D(Renderer2DData data) : base(data)
        {
            //创建pass需要的mat
            m_BlitMaterial      = CoreUtils.CreateEngineMaterial(data.blitShader);
            m_CopyDepthMaterial = CoreUtils.CreateEngineMaterial(data.URPShaders.copyDepthPS);
            m_SamplingMaterial  = CoreUtils.CreateEngineMaterial(data.URPShaders.samplingPS);

            m_ColorGradingLutPass  = new ColorGradingLutPass(RenderPassEvent.BeforeRenderingOpaques, data.postProcessData);
            m_Render2DLightingPass = new Render2DLightingPass(data);

            //
            m_CopyDepthPass = new CopyDepthPass(RenderPassEvent.AfterRenderingTransparents, m_CopyDepthMaterial);
            m_CopyColorPass = new CopyColorPass(RenderPassEvent.AfterRenderingTransparents, m_SamplingMaterial);
            // m_Render2DLightingPass = new Render2DLightingPass(data);
            //
            m_PostProcessPass      = new PostProcessPass(RenderPassEvent.BeforeRenderingPostProcessing, data.postProcessData, m_BlitMaterial);
            m_FinalPostProcessPass = new PostProcessPass(RenderPassEvent.AfterRenderingPostProcessing, data.postProcessData, m_BlitMaterial);
            m_FinalBlitPass        = new FinalBlitPass(RenderPassEvent.AfterRendering + 1, m_BlitMaterial);

#if POST_PROCESSING_STACK_2_0_0_OR_NEWER
            m_PostProcessPassCompat = new PostProcessPassCompat(RenderPassEvent.BeforeRenderingPostProcessing);
#endif

            m_UseDepthStencilBuffer = data.useDepthStencilBuffer;

            // We probably should declare these names in the base class,
            // as they must be the same across all ScriptableRenderer types for camera stacking to work.
            k_ColorTextureHandle.Init("_CameraColorTexture");
            k_DepthTextureHandle.Init("_CameraDepthAttachment");
            m_DepthTexture.Init("_2DCameraDepthTexture");
            m_OpaqueColor.Init("_2DCameraOpaqueTexture");
            k_AfterPostProcessColorHandle.Init("_AfterPostProcessTexture");
            k_ColorGradingLutHandle.Init("_InternalGradingLut");

            m_Renderer2DData = data;

            supportedRenderingFeatures = new RenderingFeatures()
            {
                cameraStacking = true,
            };

            //Render Feature 支持
            m_RenderFeaturePasses = new Render2DObjectPass[m_Renderer2DData.RenderFeatures.Count];
            for (int i = 0; i < m_Renderer2DData.RenderFeatures.Count; i++)
            {
                var rf = m_Renderer2DData.RenderFeatures[i];
                if (rf.filterSettings.PassNames.Length > 0)
                {
                    var pass = new Render2DObjectPass(data, rf.Event, rf.filterSettings.PassNames, rf.filterSettings.RenderQueueType, rf.filterSettings.LayerMask, rf.cameraSettings);
                    m_RenderFeaturePasses[i] = pass;
                }
            }
        }
Beispiel #3
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();
        }
        public ForwardRenderer(ForwardRendererData data) : base(data)
        {
            Material blitMaterial               = CoreUtils.CreateEngineMaterial(data.shaders.blitPS);
            Material copyDepthMaterial          = CoreUtils.CreateEngineMaterial(data.shaders.copyDepthPS);
            Material samplingMaterial           = CoreUtils.CreateEngineMaterial(data.shaders.samplingPS);
            Material screenspaceShadowsMaterial = CoreUtils.CreateEngineMaterial(data.shaders.screenSpaceShadowPS);

            StencilStateData stencilData = data.defaultStencilState;

            m_DefaultStencilState         = StencilState.defaultValue;
            m_DefaultStencilState.enabled = stencilData.overrideStencilState;
            m_DefaultStencilState.SetCompareFunction(stencilData.stencilCompareFunction);
            m_DefaultStencilState.SetPassOperation(stencilData.passOperation);
            m_DefaultStencilState.SetFailOperation(stencilData.failOperation);
            m_DefaultStencilState.SetZFailOperation(stencilData.zFailOperation);

            // Note: Since all custom render passes inject first and we have stable sort,
            // we inject the builtin passes in the before events.
            m_VolumeBlendingPass               = new VolumeBlendingPass(RenderPassEvent.BeforeRendering);
            m_MainLightShadowCasterPass        = new MainLightShadowCasterPass(RenderPassEvent.BeforeRenderingShadows);
            m_AdditionalLightsShadowCasterPass = new AdditionalLightsShadowCasterPass(RenderPassEvent.BeforeRenderingShadows);
            m_DepthPrepass = new DepthOnlyPass(RenderPassEvent.BeforeRenderingPrepasses, RenderQueueRange.opaque, data.opaqueLayerMask);
            m_ScreenSpaceShadowResolvePass = new ScreenSpaceShadowResolvePass(RenderPassEvent.BeforeRenderingPrepasses, screenspaceShadowsMaterial);
            m_ColorGradingLutPass          = new ColorGradingLutPass(RenderPassEvent.BeforeRenderingOpaques, data.postProcessData);
            m_RenderOpaqueForwardPass      = new DrawObjectsPass("Render Opaques", true, RenderPassEvent.BeforeRenderingOpaques, RenderQueueRange.opaque, data.opaqueLayerMask, m_DefaultStencilState, stencilData.stencilReference);
            m_CopyDepthPass  = new CopyDepthPass(RenderPassEvent.BeforeRenderingOpaques, copyDepthMaterial);
            m_DrawSkyboxPass = new DrawSkyboxPass(RenderPassEvent.BeforeRenderingSkybox);
            m_CopyColorPass  = new CopyColorPass(RenderPassEvent.BeforeRenderingTransparents, samplingMaterial);
            m_RenderTransparentForwardPass = new DrawObjectsPass("Render Transparents", false, RenderPassEvent.BeforeRenderingTransparents, RenderQueueRange.transparent, data.transparentLayerMask, m_DefaultStencilState, stencilData.stencilReference);
            m_PostProcessPass      = new PostProcessPass(RenderPassEvent.BeforeRenderingPostProcessing, data.postProcessData);
            m_FinalPostProcessPass = new PostProcessPass(RenderPassEvent.AfterRenderingPostProcessing, data.postProcessData);
            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_AfterPostProcessColor.Init("_AfterPostProcessTexture");
            m_ColorGradingLut.Init("_InternalGradingLut");
            m_ForwardLights = new ForwardLights();
        }
Beispiel #5
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;
    }
Beispiel #6
0
    public ShadowRenderer(ShadowRendererData data) : base(data)
    {
        Material blitMaterial               = CoreUtils.CreateEngineMaterial(data.shaders.blitPS);
        Material copyDepthMaterial          = CoreUtils.CreateEngineMaterial(data.shaders.copyDepthPS);
        Material samplingMaterial           = CoreUtils.CreateEngineMaterial(data.shaders.samplingPS);
        Material screenspaceShadowsMaterial = CoreUtils.CreateEngineMaterial(data.shaders.screenSpaceShadowPS);

        StencilStateData stencilData = data.defaultStencilState;

        m_DefaultStencilState         = StencilState.defaultValue;
        m_DefaultStencilState.enabled = stencilData.overrideStencilState;
        m_DefaultStencilState.SetCompareFunction(stencilData.stencilCompareFunction);
        m_DefaultStencilState.SetPassOperation(stencilData.passOperation);
        m_DefaultStencilState.SetFailOperation(stencilData.failOperation);
        m_DefaultStencilState.SetZFailOperation(stencilData.zFailOperation);

        // 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.opaque, LayerMask.GetMask("AR", "Tridify", "Outline"));
        m_ScreenSpaceShadowResolvePass = new ScreenSpaceShadowResolvePass(RenderPassEvent.BeforeRenderingPrepasses, screenspaceShadowsMaterial);
        m_CopyDepthPass = new CopyDepthPass(RenderPassEvent.BeforeRenderingOpaques, copyDepthMaterial);
        m_CopyColorPass = new CopyColorPass(RenderPassEvent.BeforeRenderingTransparents, samplingMaterial);
        m_CapturePass   = new CapturePassCopy(RenderPassEvent.AfterRendering);
        m_FinalBlitPass = new FinalBlitPass(RenderPassEvent.AfterRendering, blitMaterial);

#if UNITY_EDITOR
        m_SceneViewDepthCopyPass = new SceneViewDepthCopyPassCopy(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_ForwardLights = new ForwardLights();
    }