public PostProcessPass(RenderPassEvent evt, bool renderOpaques = false) { m_IsOpaquePostProcessing = renderOpaques; m_TemporaryColorTexture = new RenderTargetHandle("_TemporaryColorTexture"); renderPassEvent = evt; }
//public void Setup(RenderTextureDescriptor baseDescriptor, RenderTargetHandle normalAttachmentHandle, RenderTargetHandle cameraColorAttachmentHandle, RenderTargetHandle cameraDepthAttachmentHandle) public void Setup(RenderTextureDescriptor baseDescriptor, RenderTargetHandle normalAttachmentHandle) { this.normalAttachmentHandle = normalAttachmentHandle; //this.cameraDepthAttachmentHandle = cameraDepthAttachmentHandle; //this.cameraColorAttachmentHandle = cameraColorAttachmentHandle; baseDescriptor.colorFormat = RenderTextureFormat.ARGB32; baseDescriptor.depthBufferBits = kDepthBufferBits; descriptor = baseDescriptor; }
/// <inheritdoc/> public override void FrameCleanup(CommandBuffer cmd) { if (cmd == null) { throw new ArgumentNullException("cmd"); } cmd.ReleaseTemporaryRT(destination.id); destination = RenderTargetHandle.CameraTarget; }
/// <summary> /// Configure the pass /// </summary> public void Setup( RenderTextureDescriptor baseDescriptor, RenderTargetHandle depthAttachmentHandle) { this.depthAttachmentHandle = depthAttachmentHandle; baseDescriptor.colorFormat = RenderTextureFormat.Depth; baseDescriptor.depthBufferBits = kDepthBufferBits; // Depth-Only pass don't use MSAA baseDescriptor.msaaSamples = 1; descriptor = baseDescriptor; }
public AdditionalLightsShadowCasterPass(RenderPassEvent evt) { renderPassEvent = evt; int maxLights = LightweightRenderPipeline.maxVisibleAdditionalLights; m_AdditionalLightShadowMatrices = new Matrix4x4[maxLights]; m_AdditionalLightSlices = new ShadowSliceData[maxLights]; m_AdditionalLightsShadowStrength = new float[maxLights]; AdditionalShadowsConstantBuffer._AdditionalLightsWorldToShadow = Shader.PropertyToID("_AdditionalLightsWorldToShadow"); AdditionalShadowsConstantBuffer._AdditionalShadowStrength = Shader.PropertyToID("_AdditionalShadowStrength"); AdditionalShadowsConstantBuffer._AdditionalShadowOffset0 = Shader.PropertyToID("_AdditionalShadowOffset0"); AdditionalShadowsConstantBuffer._AdditionalShadowOffset1 = Shader.PropertyToID("_AdditionalShadowOffset1"); AdditionalShadowsConstantBuffer._AdditionalShadowOffset2 = Shader.PropertyToID("_AdditionalShadowOffset2"); AdditionalShadowsConstantBuffer._AdditionalShadowOffset3 = Shader.PropertyToID("_AdditionalShadowOffset3"); AdditionalShadowsConstantBuffer._AdditionalShadowmapSize = Shader.PropertyToID("_AdditionalShadowmapSize"); m_AdditionalLightsShadowmap = new RenderTargetHandle("_AdditionalLightsShadowmapTexture"); }
public MainLightShadowCasterPass(RenderPassEvent evt) { renderPassEvent = evt; m_MainLightShadowMatrices = new Matrix4x4[k_MaxCascades + 1]; m_CascadeSlices = new ShadowSliceData[k_MaxCascades]; m_CascadeSplitDistances = new Vector4[k_MaxCascades]; MainLightShadowConstantBuffer._WorldToShadow = Shader.PropertyToID("_MainLightWorldToShadow"); MainLightShadowConstantBuffer._ShadowData = Shader.PropertyToID("_MainLightShadowData"); MainLightShadowConstantBuffer._CascadeShadowSplitSpheres0 = Shader.PropertyToID("_CascadeShadowSplitSpheres0"); MainLightShadowConstantBuffer._CascadeShadowSplitSpheres1 = Shader.PropertyToID("_CascadeShadowSplitSpheres1"); MainLightShadowConstantBuffer._CascadeShadowSplitSpheres2 = Shader.PropertyToID("_CascadeShadowSplitSpheres2"); MainLightShadowConstantBuffer._CascadeShadowSplitSpheres3 = Shader.PropertyToID("_CascadeShadowSplitSpheres3"); MainLightShadowConstantBuffer._CascadeShadowSplitSphereRadii = Shader.PropertyToID("_CascadeShadowSplitSphereRadii"); MainLightShadowConstantBuffer._ShadowOffset0 = Shader.PropertyToID("_MainLightShadowOffset0"); MainLightShadowConstantBuffer._ShadowOffset1 = Shader.PropertyToID("_MainLightShadowOffset1"); MainLightShadowConstantBuffer._ShadowOffset2 = Shader.PropertyToID("_MainLightShadowOffset2"); MainLightShadowConstantBuffer._ShadowOffset3 = Shader.PropertyToID("_MainLightShadowOffset3"); MainLightShadowConstantBuffer._ShadowmapSize = Shader.PropertyToID("_MainLightShadowmapSize"); m_MainLightShadowmap = new RenderTargetHandle("_MainLightShadowmapTexture"); }
public override void Setup(ScriptableRenderContext context, ref RenderingData renderingData) { Camera camera = renderingData.cameraData.camera; RenderTextureDescriptor cameraTargetDescriptor = renderingData.cameraData.cameraTargetDescriptor; bool mainLightShadows = m_MainLightShadowCasterPass.Setup(ref renderingData); bool additionalLightShadows = m_AdditionalLightsShadowCasterPass.Setup(ref renderingData); bool resolveShadowsInScreenSpace = mainLightShadows && renderingData.shadowData.requiresScreenSpaceShadowResolve; // Depth prepass is generated in the following cases: // - We resolve shadows in screen space // - Scene view camera always requires a depth texture. We do a depth pre-pass to simplify it and it shouldn't matter much for editor. // - If game or offscreen camera requires it we check if we can copy the depth from the rendering opaques pass and use that instead. bool requiresDepthPrepass = renderingData.cameraData.isSceneViewCamera || (renderingData.cameraData.requiresDepthTexture && (!CanCopyDepth(ref renderingData.cameraData))); requiresDepthPrepass |= resolveShadowsInScreenSpace; bool createColorTexture = RequiresIntermediateColorTexture(ref renderingData, cameraTargetDescriptor) || rendererFeatures.Count != 0; // If camera requires depth and there's no depth pre-pass we create a depth texture that can be read // later by effect requiring it. bool createDepthTexture = renderingData.cameraData.requiresDepthTexture && !requiresDepthPrepass; bool postProcessEnabled = renderingData.cameraData.postProcessEnabled; bool hasOpaquePostProcess = postProcessEnabled && renderingData.cameraData.postProcessLayer.HasOpaqueOnlyEffects(RenderingUtils.postProcessRenderContext); m_ActiveCameraColorAttachment = (createColorTexture) ? m_CameraColorAttachment : RenderTargetHandle.CameraTarget; m_ActiveCameraDepthAttachment = (createDepthTexture) ? m_CameraDepthAttachment : RenderTargetHandle.CameraTarget; if (createColorTexture || createDepthTexture) { CreateCameraRenderTarget(context, ref renderingData.cameraData); } CreateFeedBackRenderTarget(context, ref renderingData.cameraData); m_FeedBackPass.ConfigureTarget(m_FeedBackBufferAttachment); ConfigureCameraTarget(m_ActiveCameraColorAttachment.Identifier(), m_ActiveCameraDepthAttachment.Identifier()); for (int i = 0; i < rendererFeatures.Count; ++i) { rendererFeatures[i].AddRenderPasses(this, ref renderingData); } int count = activeRenderPassQueue.Count; for (int i = count - 1; i >= 0; i--) { if (activeRenderPassQueue[i] == null) { activeRenderPassQueue.RemoveAt(i); } } bool hasAfterRendering = activeRenderPassQueue.Find(x => x.renderPassEvent == RenderPassEvent.AfterRendering) != null; if (mainLightShadows) { EnqueuePass(m_MainLightShadowCasterPass); } if (additionalLightShadows) { EnqueuePass(m_AdditionalLightsShadowCasterPass); } if (requiresDepthPrepass) { m_DepthPrepass.Setup(cameraTargetDescriptor, m_DepthTexture); EnqueuePass(m_DepthPrepass); } if (resolveShadowsInScreenSpace) { m_ScreenSpaceShadowResolvePass.Setup(cameraTargetDescriptor); EnqueuePass(m_ScreenSpaceShadowResolvePass); } EnqueuePass(m_FeedBackPass); EnqueuePass(m_RenderOpaqueForwardPass); if (hasOpaquePostProcess) { m_OpaquePostProcessPass.Setup(cameraTargetDescriptor, m_ActiveCameraColorAttachment, m_ActiveCameraColorAttachment); } if (camera.clearFlags == CameraClearFlags.Skybox && RenderSettings.skybox != null) { EnqueuePass(m_DrawSkyboxPass); } // If a depth texture was created we necessarily need to copy it, otherwise we could have render it to a renderbuffer if (createDepthTexture) { m_CopyDepthPass.Setup(m_ActiveCameraDepthAttachment, m_DepthTexture); EnqueuePass(m_CopyDepthPass); } if (renderingData.cameraData.requiresOpaqueTexture) { m_CopyColorPass.Setup(m_ActiveCameraColorAttachment.Identifier(), m_OpaqueColor); EnqueuePass(m_CopyColorPass); } EnqueuePass(m_RenderTransparentForwardPass); bool afterRenderExists = renderingData.cameraData.captureActions != null || hasAfterRendering; // if we have additional filters // we need to stay in a RT if (afterRenderExists) { // perform post with src / dest the same if (postProcessEnabled) { m_PostProcessPass.Setup(cameraTargetDescriptor, m_ActiveCameraColorAttachment, m_ActiveCameraColorAttachment); EnqueuePass(m_PostProcessPass); } //now blit into the final target if (m_ActiveCameraColorAttachment != RenderTargetHandle.CameraTarget) { if (renderingData.cameraData.captureActions != null) { m_CapturePass.Setup(m_ActiveCameraColorAttachment); EnqueuePass(m_CapturePass); } m_FinalBlitPass.Setup(cameraTargetDescriptor, m_ActiveCameraColorAttachment); EnqueuePass(m_FinalBlitPass); } } else { if (postProcessEnabled) { m_PostProcessPass.Setup(cameraTargetDescriptor, m_ActiveCameraColorAttachment, RenderTargetHandle.CameraTarget); EnqueuePass(m_PostProcessPass); } else if (m_ActiveCameraColorAttachment != RenderTargetHandle.CameraTarget) { m_FinalBlitPass.Setup(cameraTargetDescriptor, m_ActiveCameraColorAttachment); EnqueuePass(m_FinalBlitPass); } } #if UNITY_EDITOR if (renderingData.cameraData.isSceneViewCamera) { m_SceneViewDepthCopyPass.Setup(m_DepthTexture); EnqueuePass(m_SceneViewDepthCopyPass); } #endif }
/// <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 Target</param> public void Setup(RenderTargetIdentifier source, RenderTargetHandle destination) { this.source = source; this.destination = destination; }
public bool Equals(RenderTargetHandle other) { return(id == other.id); }
public void Setup(RenderTargetHandle rtHandle) { m_RenderTargetHandle = rtHandle; }
public ScreenSpaceShadowResolvePass(RenderPassEvent evt, Material screenspaceShadowsMaterial) { m_ScreenSpaceShadowsMaterial = screenspaceShadowsMaterial; m_ScreenSpaceShadowmap = new RenderTargetHandle("_ScreenSpaceShadowmapTexture"); renderPassEvent = evt; }
public void Setup(RenderTargetIdentifier source, RenderTargetHandle destination, bool createTempDstRT = false) { this.source = source; this.destination = destination; createTemporaryDst = createTempDstRT; }
public bool Equals(RenderTargetHandle other) { return(id == other.id && m_colorHandle == other.m_colorHandle); }
/// <summary> /// Setup the pass /// </summary> /// <param name="baseDescriptor"></param> /// <param name="sourceHandle">Source of rendering to execute the post on</param> /// <param name="destinationHandle">Destination target for the final blit</param> public void Setup(RenderTextureDescriptor baseDescriptor, RenderTargetHandle sourceHandle, RenderTargetHandle destinationHandle) { m_Descriptor = baseDescriptor; m_Source = sourceHandle; m_Destination = destinationHandle; }
/// <summary> /// Setup the pass /// </summary> /// <param name="sourceHandle">Source of rendering to execute the post on</param> public void Setup(RenderTargetHandle sourceHandle) { m_Source = sourceHandle; }
/// <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 Target</param> public void Setup(RenderTargetIdentifier source, RenderTargetHandle destination, Downsampling downsampling) { this.source = source; this.destination = destination; m_DownsamplingMethod = downsampling; }