/// <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="configuration">Specific render configuration</param> public void Setup( RenderTextureDescriptor baseDescriptor, RenderTargetHandle colorAttachmentHandle, RenderTargetHandle depthAttachmentHandle, RendererConfiguration configuration, SampleCount samples) { this._ColorAttachmentHandle = colorAttachmentHandle; this._DepthAttachmentHandle = depthAttachmentHandle; _Descriptor = baseDescriptor; _RendererConfiguration = configuration; if ((int)samples > 1) { baseDescriptor.bindMS = false; baseDescriptor.msaaSamples = (int)samples; } baseDescriptor.colorFormat = RenderTextureFormat.ARGBHalf; baseDescriptor.depthBufferBits = 0; _DescriptorAC = baseDescriptor; baseDescriptor.colorFormat = SystemInfo.SupportsRenderTextureFormat(RenderTextureFormat.RHalf) ? RenderTextureFormat.RHalf : RenderTextureFormat.ARGBHalf; _DescriptorAA = baseDescriptor; _AccumColorHandle.Init("_AccumColor"); _AccumGIHandle.Init("_AccumGI"); _AccumAlphaHandle.Init("_AccumAlpha"); _AccumBinding = new RenderTargetBinding(new RenderTargetIdentifier[] { _AccumColorHandle.Identifier(), _AccumGIHandle.Identifier(), _AccumAlphaHandle.Identifier(), }, new RenderBufferLoadAction[] { RenderBufferLoadAction.DontCare, RenderBufferLoadAction.DontCare, RenderBufferLoadAction.DontCare, }, new RenderBufferStoreAction[] { RenderBufferStoreAction.Store, RenderBufferStoreAction.Store, RenderBufferStoreAction.Store, }, _DepthAttachmentHandle.Identifier(), RenderBufferLoadAction.Load, RenderBufferStoreAction.DontCare); }
private void Init() { if (m_Initialized) { return; } m_DepthOnlyPass = new DepthOnlyPass(); _CopyDepthForOITPass = new CopyDepthPass(); _OITDepthOnlyPass = new OITDepthOnlyPass(); m_DepthNormalsPass = new DepthNormalsPass(); m_MainLightShadowCasterPass = new MainLightShadowCasterPass(); m_MainCharacterShadowCasterPass = new MainCharacterShadowCasterPass(); m_AdditionalLightsShadowCasterPass = new AdditionalLightsShadowCasterPass(); _DeepShadowCasterPass = new DeepShadowCasterPass(); m_SetupForwardRenderingPass = new SetupForwardRenderingPass(); m_ScreenSpaceShadowResolvePass = new ScreenSpaceShadowResolvePass(); _ScreenSpaceDeepShadowMapsPass = new ScreenSpaceDeepShadowMapsPass(); 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(); //_RenderWeightedOITForwardPass = new RenderWeightedOITForwardPass(); _RenderMomentOITForwardPass = new RenderMomentOITForwardPass(); 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"); OITDepthTexture.Init("_OITDepthTexture"); OpaqueColor.Init("_CameraOpaqueTexture"); DepthNormalsTexture.Init("_CameraDepthNormalsTexture"); MainLightShadowmap.Init("_MainLightShadowmapTexture"); MainCharacterShadowmap.Init("_MainCharacterShadowmapTexture"); AdditionalLightsShadowmap.Init("_AdditionalLightsShadowmapTexture"); ScreenSpaceShadowmap.Init("_ScreenSpaceShadowmapTexture"); ScreenSpaceDeepShadowLut.Init("_DeepShadowLut"); m_Initialized = true; }
private void Init() { if (m_Initialized) { return; } m_DepthOnlyPass = new DepthOnlyPass(); m_DirectionalShadowPass = new DirectionalShadowsPass(); m_LocalShadowPass = new LocalShadowsPass(); m_SetupForwardRenderingPass = new SetupForwardRenderingPass(); m_ScreenSpaceShadowResovePass = 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_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 Color.Init("_CameraColorTexture"); DepthAttachment.Init("_CameraDepthAttachment"); DepthTexture.Init("_CameraDepthTexture"); OpaqueColor.Init("_CameraOpaqueTexture"); DirectionalShadowmap.Init("_DirectionalShadowmapTexture"); LocalShadowmap.Init("_LocalShadowmapTexture"); ScreenSpaceShadowmap.Init("_ScreenSpaceShadowMapTexture"); m_Initialized = true; }
public bool Setup(ScriptableRenderer renderer, RenderTextureDescriptor baseDescriptor, RenderTargetHandle destination, ref RenderingData renderingData) { //int shadowLightIndex = renderingData.lightData.mainLightIndex; //if (shadowLightIndex == -1) // return false; //VisibleLight shadowLight = renderingData.lightData.visibleLights[shadowLightIndex]; //Light light = shadowLight.light; //if (light.shadows == LightShadows.None) // return false; //if (shadowLight.lightType != LightType.Directional) //{ // Debug.LogWarning("Only directional lights are supported as main light."); //} //Bounds bounds; //if (!renderingData.cullResults.GetShadowCasterBounds(shadowLightIndex, out bounds)) // return false; //TODO : More branches _CountBuffer = renderer.GetBuffer(ComputeBufferHandle.DeepShadowMapsCount); _DataBuffer = renderer.GetBuffer(ComputeBufferHandle.DeepShadowMapsData); _Destination = destination; _Descriptor = baseDescriptor; _Descriptor.colorFormat = _ShadowLutFormat; _Descriptor.depthBufferBits = 0; _DeepShadowLut.Init("_DSMLut"); _DeepShadowTmp.Init("_DSMTmp"); _DeepShadowTest.Init("_DeepShadowTest"); return(true); }
/// <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="configuration">Specific render configuration</param> public bool Setup( RenderTextureDescriptor baseDescriptor, RenderTargetHandle colorAttachmentHandle, RenderTargetHandle depthAttachmentHandle, RendererConfiguration configuration, SampleCount samples, RenderingData renderingData) { if (!GetViewDepthMinMaxWithRenderQueue(renderingData.cameraData.camera, RenderQueueUtils.oit, out _ViewDepthMinMax)) { return(false); } this._ColorAttachmentHandle = colorAttachmentHandle; this._DepthAttachmentHandle = depthAttachmentHandle; _RendererConfiguration = configuration; if ((int)samples > 1) { baseDescriptor.bindMS = false; baseDescriptor.msaaSamples = (int)samples; } baseDescriptor.depthBufferBits = 0; _Descriptor = baseDescriptor; _MomentsPrecision = renderingData.cameraData.momentsPrecision; if (_MomentsPrecision == FloatPrecision._Single) { baseDescriptor.colorFormat = RenderTextureFormat.ARGBFloat; _DescriptorFloat4 = baseDescriptor; baseDescriptor.colorFormat = SystemInfo.SupportsRenderTextureFormat(RenderTextureFormat.RGFloat) ? RenderTextureFormat.RGFloat : RenderTextureFormat.ARGBFloat; _DescriptorFloat2 = baseDescriptor; baseDescriptor.colorFormat = SystemInfo.SupportsRenderTextureFormat(RenderTextureFormat.RFloat) ? RenderTextureFormat.RFloat : RenderTextureFormat.ARGBFloat; _DescriptorFloat = baseDescriptor; } else { baseDescriptor.colorFormat = RenderTextureFormat.ARGBHalf; _DescriptorFloat4 = baseDescriptor; baseDescriptor.colorFormat = SystemInfo.SupportsRenderTextureFormat(RenderTextureFormat.RGHalf) ? RenderTextureFormat.RGHalf : RenderTextureFormat.ARGBHalf; _DescriptorFloat2 = baseDescriptor; baseDescriptor.colorFormat = SystemInfo.SupportsRenderTextureFormat(RenderTextureFormat.RHalf) ? RenderTextureFormat.RHalf : RenderTextureFormat.ARGBHalf; _DescriptorFloat = baseDescriptor; } _B0Handle.Init("_B0"); _B1Handle.Init("_B1"); _B2Handle.Init("_B2"); _MomentsCount = (MomentsCount)renderingData.cameraData.momentsCount; if (MomentsCount._4 != _MomentsCount) { _GMBinding = new RenderTargetBinding( new RenderTargetIdentifier[] { _B0Handle.Identifier(), _B1Handle.Identifier(), _B2Handle.Identifier(), }, new RenderBufferLoadAction[] { RenderBufferLoadAction.DontCare, RenderBufferLoadAction.DontCare, RenderBufferLoadAction.DontCare, }, new RenderBufferStoreAction[] { RenderBufferStoreAction.Store, RenderBufferStoreAction.Store, RenderBufferStoreAction.Store, }, _DepthAttachmentHandle.Identifier(), RenderBufferLoadAction.Load, RenderBufferStoreAction.DontCare); } else { _GMBinding = new RenderTargetBinding( new RenderTargetIdentifier[] { _B0Handle.Identifier(), _B1Handle.Identifier(), }, new RenderBufferLoadAction[] { RenderBufferLoadAction.DontCare, RenderBufferLoadAction.DontCare, }, new RenderBufferStoreAction[] { RenderBufferStoreAction.Store, RenderBufferStoreAction.Store, }, _DepthAttachmentHandle.Identifier(), RenderBufferLoadAction.Load, RenderBufferStoreAction.DontCare); } _MOITHandle.Init("_MOIT"); _GIALHandle.Init("_GIAL"); _RMBinding = new RenderTargetBinding( new RenderTargetIdentifier[] { _MOITHandle.Identifier(), _GIALHandle.Identifier(), }, new RenderBufferLoadAction[] { RenderBufferLoadAction.DontCare, RenderBufferLoadAction.DontCare, }, new RenderBufferStoreAction[] { RenderBufferStoreAction.Store, RenderBufferStoreAction.Store, }, _DepthAttachmentHandle.Identifier(), RenderBufferLoadAction.Load, RenderBufferStoreAction.DontCare ); return(true); }