public void Setup(
            RenderTextureDescriptor baseDescriptor,
            MainLightShadowCasterPass mainLightShadowCasterPass,
            bool mainLightDynamicShadows)
        {
            m_RenderTextureDescriptor = baseDescriptor;
            m_RenderTextureDescriptor.autoGenerateMips  = false;
            m_RenderTextureDescriptor.useMipMap         = false;
            m_RenderTextureDescriptor.sRGB              = false;
            m_RenderTextureDescriptor.enableRandomWrite = true;
            m_RenderTextureDescriptor.depthBufferBits   = 0;
            m_RenderTextureDescriptor.colorFormat       = m_ColorFormat;

            this.mainLightShadowCasterPass = mainLightShadowCasterPass;
            this.mainLightDynamicShadows   = mainLightDynamicShadows;
        }
コード例 #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);

            // 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);
            m_ScreenSpaceShadowResolvePass = new ScreenSpaceShadowResolvePass(RenderPassEvent.BeforeRenderingPrepasses, screenspaceShadowsMaterial);
            m_FeedBackPass = new RenderFeedBackPass(RenderPassEvent.BeforeRenderingOpaques, RenderQueueRange.opaque, data.opaqueLayerMask);

            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_RenderTransparentForwardPass = new RenderTransparentForwardPass(RenderPassEvent.BeforeRenderingTransparents, RenderQueueRange.transparent, data.transparentLayerMask);
            m_PostProcessPass              = new PostProcessPass(RenderPassEvent.BeforeRenderingPostProcessing);
            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_ForwardLights = new ForwardLights();
        }