public void Setup(
            RenderTextureDescriptor baseDescriptor,
            RenderTargetHandle colorAttachmentHandle)
        {
            this.colorAttachmentHandle = colorAttachmentHandle;

            baseDescriptor.depthBufferBits = 0;
            baseDescriptor.colorFormat     = m_ColorFormat;
            descriptor = baseDescriptor;
        }
 /// <summary>
 /// Configure the pass
 /// </summary>
 public void Setup(
     RenderTextureDescriptor baseDescriptor,
     RenderTargetHandle colorAttachmentHandle,
     RenderTargetHandle depthAttachmentHandle,
     SampleCount samples)
 {
     this.colorAttachmentHandle = colorAttachmentHandle;
     this.depthAttachmentHandle = depthAttachmentHandle;
     this.samples = samples;
     descriptor   = baseDescriptor;
 }
Пример #3
0
 /// <inheritdoc/>
 public override void FrameCleanup(CommandBuffer cmd)
 {
     if (cmd == null)
         throw new ArgumentNullException("cmd");
     
     if (destination != RenderTargetHandle.CameraTarget)
     {
         cmd.ReleaseTemporaryRT(destination.id);
         destination = RenderTargetHandle.CameraTarget;
     }
 }
Пример #4
0
 /// <summary>
 /// Configure the pass before execution
 /// </summary>
 /// <param name="baseDescriptor">Current target descriptor</param>
 /// <param name="colorAttachmentHandle">Color attachment to render into</param>
 /// <param name="depthAttachmentHandle">Depth attachment to render into</param>
 /// <param name="clearFlag">Camera clear flag</param>
 /// <param name="clearColor">Camera clear color</param>
 /// <param name="configuration">Specific render configuration</param>
 public void Setup(
     RenderTextureDescriptor baseDescriptor,
     RenderTargetHandle colorAttachmentHandle,
     RenderTargetHandle depthAttachmentHandle,
     ClearFlag clearFlag,
     Color clearColor,
     RendererConfiguration configuration)
 {
     this.colorAttachmentHandle = colorAttachmentHandle;
     this.depthAttachmentHandle = depthAttachmentHandle;
     this.clearColor            = CoreUtils.ConvertSRGBToActiveColorSpace(clearColor);
     this.clearFlag             = clearFlag;
     descriptor = baseDescriptor;
     this.rendererConfiguration = configuration;
 }
Пример #5
0
        /// <summary>
        /// Configure the pass
        /// </summary>
        public void Setup(
            RenderTextureDescriptor baseDescriptor,
            RenderTargetHandle depthAttachmentHandle,
            SampleCount samples)
        {
            this.depthAttachmentHandle     = depthAttachmentHandle;
            baseDescriptor.colorFormat     = RenderTextureFormat.Depth;
            baseDescriptor.depthBufferBits = kDepthBufferBits;

            if ((int)samples > 1)
            {
                baseDescriptor.bindMS      = false;
                baseDescriptor.msaaSamples = (int)samples;
            }

            descriptor = baseDescriptor;
        }
Пример #6
0
 /// <summary>
 /// Configure the pass with the source and destination to execute on.
 /// </summary>
 /// <param name="source">Source Render Target</param>
 /// <param name="destination">Destination Render Targt</param>
 public void Setup(RenderTargetHandle source, RenderTargetHandle destination)
 {
     this.source = source;
     this.destination = destination;
 }
Пример #7
0
 /// <summary>
 /// Configure the pass
 /// </summary>
 /// <param name="baseDescriptor"></param>
 /// <param name="colorAttachmentHandle"></param>
 public void Setup(RenderTextureDescriptor baseDescriptor, RenderTargetHandle colorAttachmentHandle)
 {
     this.colorAttachmentHandle = colorAttachmentHandle;
     this.descriptor            = baseDescriptor;
 }
Пример #8
0
        public void Setup(ScriptableRenderer renderer, ref RenderingData renderingData)
        {
            Init();

            Camera camera = renderingData.cameraData.camera;

            camera.GetComponents(m_BeforeRenderPasses);

            renderer.SetupPerObjectLightIndices(ref renderingData.cullResults, ref renderingData);
            RenderTextureDescriptor baseDescriptor   = ScriptableRenderer.CreateRenderTextureDescriptor(ref renderingData.cameraData);
            RenderTextureDescriptor shadowDescriptor = baseDescriptor;
            ClearFlag clearFlag = ScriptableRenderer.GetCameraClearFlag(renderingData.cameraData.camera);

            shadowDescriptor.dimension = TextureDimension.Tex2D;

            bool requiresRenderToTexture = ScriptableRenderer.RequiresIntermediateColorTexture(ref renderingData.cameraData, baseDescriptor) ||
                                           m_BeforeRenderPasses.Count != 0;

            RenderTargetHandle colorHandle = RenderTargetHandle.CameraTarget;
            RenderTargetHandle depthHandle = RenderTargetHandle.CameraTarget;

            if (requiresRenderToTexture)
            {
                colorHandle = ColorAttachment;
                depthHandle = DepthAttachment;

                var sampleCount = (SampleCount)renderingData.cameraData.msaaSamples;
                m_CreateRenderTexturesPass.Setup(baseDescriptor, colorHandle, depthHandle, sampleCount);
                renderer.EnqueuePass(m_CreateRenderTexturesPass);
            }

            foreach (var pass in m_BeforeRenderPasses)
            {
                renderer.EnqueuePass(pass.GetPassToEnqueue(baseDescriptor, colorHandle, depthHandle, clearFlag));
            }

            //if (renderingData.shadowData.supportsAdditionalLightShadows)
            {
                //bool additionalLightShadows = m_AdditionalLightsShadowCasterPass.Setup(AdditionalLightsShadowmap, ref renderingData, renderer.maxVisibleAdditionalLights);
                //if (additionalLightShadows)
                //    renderer.EnqueuePass(m_AdditionalLightsShadowCasterPass);
            }
            if (renderingData.shadowData.supportsLightShadows)
            {
                bool lightShadows = AtlasShadowsPass.Setup(LightsShadowmap, ref renderingData, renderingData.settings.MaxShadowLightsNum);
                if (lightShadows)
                {
                    renderer.EnqueuePass(AtlasShadowsPass);
                }
            }

            bool resolveShadowsInScreenSpace = true;// renderingData.shadowData.requiresScreenSpaceShadowResolve;
            bool requiresDepthPrepass        = resolveShadowsInScreenSpace || renderingData.cameraData.isSceneViewCamera ||
                                               (renderingData.cameraData.requiresDepthTexture && (!CanCopyDepth(ref renderingData.cameraData)));


            renderer.EnqueuePass(m_SetupForwardRenderingPass);

            if (requiresDepthPrepass)
            {
                m_DepthOnlyPass.Setup(baseDescriptor, DepthTexture, SampleCount.One);
                renderer.EnqueuePass(m_DepthOnlyPass);

                foreach (var pass in camera.GetComponents <IAfterDepthPrePass>())
                {
                    renderer.EnqueuePass(pass.GetPassToEnqueue(m_DepthOnlyPass.descriptor, DepthTexture));
                }
            }

            if (resolveShadowsInScreenSpace)
            {
                //m_ScreenSpaceShadowResolvePass.Setup(baseDescriptor, ScreenSpaceShadowmap);
                //renderer.EnqueuePass(m_ScreenSpaceShadowResolvePass);
            }


            RendererConfiguration rendererConfiguration = ScriptableRenderer.GetRendererConfiguration(0);

            m_SetupDoomSRPConstants.Setup(renderingData.settings, renderer.perObjectLightIndices);
            renderer.EnqueuePass(m_SetupDoomSRPConstants);

            // If a before all render pass executed we expect it to clear the color render target
            if (m_BeforeRenderPasses.Count != 0)
            {
                clearFlag = ClearFlag.None;
            }

            m_RenderOpaqueForwardPass.Setup(baseDescriptor, colorHandle, depthHandle, clearFlag, camera.backgroundColor, rendererConfiguration);
            renderer.EnqueuePass(m_RenderOpaqueForwardPass);
            foreach (var pass in camera.GetComponents <IAfterOpaquePass>())
            {
                renderer.EnqueuePass(pass.GetPassToEnqueue(baseDescriptor, colorHandle, depthHandle));
            }

            //if (renderingData.cameraData.postProcessEnabled &&
            //    renderingData.cameraData.postProcessLayer.HasOpaqueOnlyEffects(renderer.postProcessingContext))
            //{
            //    m_OpaquePostProcessPass.Setup(baseDescriptor, colorHandle);
            //    renderer.EnqueuePass(m_OpaquePostProcessPass);

            //    foreach (var pass in camera.GetComponents<IAfterOpaquePostProcess>())
            //        renderer.EnqueuePass(pass.GetPassToEnqueue(baseDescriptor, colorHandle, depthHandle));
            //}

            if (camera.clearFlags == CameraClearFlags.Skybox && RenderSettings.skybox != null)
            {
                m_DrawSkyboxPass.Setup(colorHandle, depthHandle);
                renderer.EnqueuePass(m_DrawSkyboxPass);
            }

            foreach (var pass in camera.GetComponents <IAfterSkyboxPass>())
            {
                renderer.EnqueuePass(pass.GetPassToEnqueue(baseDescriptor, colorHandle, depthHandle));
            }

            if (renderingData.cameraData.requiresDepthTexture && !requiresDepthPrepass)
            {
                m_CopyDepthPass.Setup(depthHandle, DepthTexture);
                renderer.EnqueuePass(m_CopyDepthPass);
            }

            if (renderingData.cameraData.requiresOpaqueTexture)
            {
                m_CopyColorPass.Setup(colorHandle, OpaqueColor);
                renderer.EnqueuePass(m_CopyColorPass);
            }

            //m_RenderTransparentForwardPass.Setup(baseDescriptor, colorHandle, depthHandle, rendererConfiguration);
            //renderer.EnqueuePass(m_RenderTransparentForwardPass);

            foreach (var pass in camera.GetComponents <IAfterTransparentPass>())
            {
                renderer.EnqueuePass(pass.GetPassToEnqueue(baseDescriptor, colorHandle, depthHandle));
            }

            if (colorHandle != RenderTargetHandle.CameraTarget)
            {
                m_FinalBlitPass.Setup(baseDescriptor, colorHandle);
                renderer.EnqueuePass(m_FinalBlitPass);
            }

            foreach (var pass in camera.GetComponents <IAfterRender>())
            {
                renderer.EnqueuePass(pass.GetPassToEnqueue());
            }


#if UNITY_EDITOR
            if (renderingData.cameraData.isSceneViewCamera)
            {
                m_SceneViewDepthCopyPass.Setup(DepthTexture);
                renderer.EnqueuePass(m_SceneViewDepthCopyPass);
            }
#endif
        }
Пример #9
0
 public void Setup(RenderTargetHandle source)
 {
     this.source = source;
 }
Пример #10
0
 public bool Equals(RenderTargetHandle other)
 {
     return(id == other.id);
 }
Пример #11
0
 /// <summary>
 /// Configure the color and depth passes to use when rendering the skybox
 /// </summary>
 /// <param name="colorHandle">Color buffer to use</param>
 /// <param name="depthHandle">Depth buffer to use</param>
 public void Setup(RenderTargetHandle colorHandle, RenderTargetHandle depthHandle)
 {
     this.colorAttachmentHandle = colorHandle;
     this.depthAttachmentHandle = depthHandle;
 }