예제 #1
0
    private void Init()
    {
        if (m_Inited)
        {
            return;
        }

        m_RenderOpaqueForwardPass   = new RenderOpaqueForwardPass();
        m_DirectionalShadowPass     = new DirectionalShadowPass();
        m_ScreenSpaceShadowPass     = new ScreenSpaceShadowResolvePass();
        m_DepthOnlyPass             = new DepthOnlyPass();
        m_SetupForwardRenderingPass = new SetupForwardRenderingPass();
        m_SetupLWDConstants         = new SetupLWDConstantsPass();
        m_FinalBlitPass             = new FinalBlitPass();
        m_BlurPass = new BlurPass();

        ColorAttachment.Init("_CameraColorTexture");
        DepthAttachment.Init("_CameraDepthAttachment");
        DepthTexture.Init("_CameraDepthTexture");
        OpaqueColor.Init("_CameraOpaqueTexture");
        DirectionalShadowmap.Init("_DirectionalShadowmapTexture");
        BluredDirectionalShadowmap.Init("_BluredDirectionalShadowmapTexture");
        ScreenSpaceShadowmap.Init("_ScreenSpaceShadowmapTexture");

        m_Inited = true;
    }
예제 #2
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();
        }
예제 #3
0
        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();
        }
예제 #4
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;
    }
예제 #5
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();
    }