public override void Configure(CommandBuffer cmd, RenderTextureDescriptor cameraTextureDescriptor) { RenderTargetHandle[] gbufferAttachments = m_DeferredLights.GbufferAttachments; // Create and declare the render targets used in the pass for (int i = 0; i < gbufferAttachments.Length; ++i) { // Lighting buffer has already been declared with line ConfigureCameraTarget(m_ActiveCameraColorAttachment.Identifier(), ...) in DeferredRenderer.Setup if (i == m_DeferredLights.GBufferLightingIndex) { continue; } if (i == m_DeferredLights.GBufferNormalSmoothnessIndex && m_DeferredLights.HasNormalPrepass) { continue; } RenderTextureDescriptor gbufferSlice = cameraTextureDescriptor; gbufferSlice.depthBufferBits = 0; // make sure no depth surface is actually created gbufferSlice.stencilFormat = GraphicsFormat.None; gbufferSlice.graphicsFormat = m_DeferredLights.GetGBufferFormat(i); cmd.GetTemporaryRT(m_DeferredLights.GbufferAttachments[i].id, gbufferSlice); } ConfigureTarget(m_DeferredLights.GbufferAttachmentIdentifiers, m_DeferredLights.DepthAttachmentIdentifier); // We must explicitely specify we don't want any clear to avoid unwanted side-effects. // ScriptableRenderer may still implicitely force a clear the first time the camera color/depth targets are bound. ConfigureClear(ClearFlag.None, Color.black); }
public override void Configure(CommandBuffer cmd, RenderTextureDescriptor cameraTextureDescriptor) { // Create and declare the render targets used in the pass for (int i = 0; i < m_DeferredLights.GBufferSliceCount; ++i) { // Lighting buffer has already been declared with line ConfigureCameraTarget(m_ActiveCameraColorAttachment.Identifier(), ...) in DeferredRenderer.Setup if (i != m_DeferredLights.GBufferLightingIndex) { RenderTextureDescriptor gbufferSlice = cameraTextureDescriptor; gbufferSlice.graphicsFormat = m_DeferredLights.GetGBufferFormat(i); cmd.GetTemporaryRT(m_ColorAttachments[i].id, gbufferSlice); } } RenderTargetIdentifier[] colorAttachmentIdentifiers = new RenderTargetIdentifier[m_DeferredLights.GBufferSliceCount]; for (int i = 0; i < colorAttachmentIdentifiers.Length; ++i) { colorAttachmentIdentifiers[i] = m_ColorAttachments[i].Identifier(); } ConfigureTarget(colorAttachmentIdentifiers, m_DepthBufferAttachment.Identifier()); // If depth-prepass exists, do not clear depth here or we will lose it. // Lighting buffer is cleared independently regardless of what we ask for here. ConfigureClear(m_HasDepthPrepass ? ClearFlag.None : ClearFlag.Depth, Color.black); }
public override void Configure(CommandBuffer cmd, RenderTextureDescriptor cameraTextureDescriptor) { RTHandle[] gbufferAttachments = m_DeferredLights.GbufferAttachments; if (cmd != null) { var allocateGbufferDepth = true; if (m_DeferredLights.UseRenderPass && (m_DeferredLights.DepthCopyTexture != null && m_DeferredLights.DepthCopyTexture.rt != null)) { m_DeferredLights.GbufferAttachments[m_DeferredLights.GbufferDepthIndex] = m_DeferredLights.DepthCopyTexture; allocateGbufferDepth = false; } // Create and declare the render targets used in the pass for (int i = 0; i < gbufferAttachments.Length; ++i) { // Lighting buffer has already been declared with line ConfigureCameraTarget(m_ActiveCameraColorAttachment.Identifier(), ...) in DeferredRenderer.Setup if (i == m_DeferredLights.GBufferLightingIndex) { continue; } // Normal buffer may have already been created if there was a depthNormal prepass before. // DepthNormal prepass is needed for forward-only materials when SSAO is generated between gbuffer and deferred lighting pass. if (i == m_DeferredLights.GBufferNormalSmoothnessIndex && m_DeferredLights.HasNormalPrepass) { continue; } if (i == m_DeferredLights.GbufferDepthIndex && !allocateGbufferDepth) { continue; } // No need to setup temporaryRTs if we are using input attachments as they will be Memoryless if (m_DeferredLights.UseRenderPass && i != m_DeferredLights.GBufferShadowMask && i != m_DeferredLights.GBufferRenderingLayers && (i != m_DeferredLights.GbufferDepthIndex && !m_DeferredLights.HasDepthPrepass)) { continue; } RenderTextureDescriptor gbufferSlice = cameraTextureDescriptor; gbufferSlice.depthBufferBits = 0; // make sure no depth surface is actually created gbufferSlice.stencilFormat = GraphicsFormat.None; gbufferSlice.graphicsFormat = m_DeferredLights.GetGBufferFormat(i); RenderingUtils.ReAllocateIfNeeded(ref m_DeferredLights.GbufferAttachments[i], gbufferSlice, FilterMode.Point, TextureWrapMode.Clamp, name: DeferredLights.k_GBufferNames[i]); cmd.SetGlobalTexture(m_DeferredLights.GbufferAttachments[i].name, m_DeferredLights.GbufferAttachments[i].nameID); } } if (m_DeferredLights.UseRenderPass) { m_DeferredLights.UpdateDeferredInputAttachments(); } ConfigureTarget(m_DeferredLights.GbufferAttachments, m_DeferredLights.DepthAttachment, m_DeferredLights.GbufferFormats); // We must explicitly specify we don't want any clear to avoid unwanted side-effects. // ScriptableRenderer will implicitly force a clear the first time the camera color/depth targets are bound. ConfigureClear(ClearFlag.None, Color.black); }
public override void Configure(CommandBuffer cmd, RenderTextureDescriptor cameraTextureDescriptor) { RenderTargetHandle[] gbufferAttachments = m_DeferredLights.GbufferAttachments; if (cmd != null) { // Create and declare the render targets used in the pass for (int i = 0; i < gbufferAttachments.Length; ++i) { // Lighting buffer has already been declared with line ConfigureCameraTarget(m_ActiveCameraColorAttachment.Identifier(), ...) in DeferredRenderer.Setup if (i == m_DeferredLights.GBufferLightingIndex) { continue; } // Normal buffer may have already been created if there was a depthNormal prepass before. // DepthNormal prepass is needed for forward-only materials when SSAO is generated between gbuffer and deferred lighting pass. if (i == m_DeferredLights.GBufferNormalSmoothnessIndex && m_DeferredLights.HasNormalPrepass) { continue; } // No need to setup temporaryRTs if we are using input attachments as they will be Memoryless if (m_DeferredLights.UseRenderPass && i != m_DeferredLights.GBufferShadowMask && i != m_DeferredLights.GBufferRenderingLayers) { continue; } RenderTextureDescriptor gbufferSlice = cameraTextureDescriptor; gbufferSlice.depthBufferBits = 0; // make sure no depth surface is actually created gbufferSlice.stencilFormat = GraphicsFormat.None; gbufferSlice.graphicsFormat = m_DeferredLights.GetGBufferFormat(i); cmd.GetTemporaryRT(m_DeferredLights.GbufferAttachments[i].id, gbufferSlice); } } ConfigureTarget(m_DeferredLights.GbufferAttachmentIdentifiers, m_DeferredLights.DepthAttachmentIdentifier, m_DeferredLights.GbufferFormats); // We must explicitely specify we don't want any clear to avoid unwanted side-effects. // ScriptableRenderer will implicitely force a clear the first time the camera color/depth targets are bound. ConfigureClear(ClearFlag.None, Color.black); }