コード例 #1
0
        public override void Execute(ScriptableRenderer renderer, ScriptableRenderContext context, ref RenderingData renderingData)
        {
            CommandBuffer cmd          = CommandBufferPool.Get(k_CopyColorTag);
            Downsampling  downsampling = renderingData.cameraData.opaqueTextureDownsampling;
            float         opaqueScaler = m_OpaqueScalerValues[(int)downsampling];

            RenderTextureDescriptor opaqueDesc    = ScriptableRenderer.CreateRenderTextureDescriptor(ref renderingData.cameraData, opaqueScaler);
            RenderTargetIdentifier  colorRT       = source.Identifier();
            RenderTargetIdentifier  opaqueColorRT = destination.Identifier();

            cmd.GetTemporaryRT(destination.id, opaqueDesc, renderingData.cameraData.opaqueTextureDownsampling == Downsampling.None ? FilterMode.Point : FilterMode.Bilinear);
            switch (downsampling)
            {
            case Downsampling.None:
                cmd.Blit(colorRT, opaqueColorRT);
                break;

            case Downsampling._2xBilinear:
                cmd.Blit(colorRT, opaqueColorRT);
                break;

            case Downsampling._4xBox:
                Material samplingMaterial = renderer.GetMaterial(MaterialHandles.Sampling);
                samplingMaterial.SetFloat(m_SampleOffsetShaderHandle, 2);
                cmd.Blit(colorRT, opaqueColorRT, samplingMaterial, 0);
                break;

            case Downsampling._4xBilinear:
                cmd.Blit(colorRT, opaqueColorRT);
                break;
            }

            context.ExecuteCommandBuffer(cmd);
            CommandBufferPool.Release(cmd);
        }
コード例 #2
0
        /// <inheritdoc/>
        public override void Execute(ScriptableRenderer renderer, ScriptableRenderContext context, ref RenderingData renderingData)
        {
            Material material = renderingData.cameraData.isStereoEnabled ? null : renderer.GetMaterial(MaterialHandles.Blit);
            RenderTargetIdentifier sourceRT = colorAttachmentHandle.Identifier();

            CommandBuffer cmd = CommandBufferPool.Get(k_FinalBlitTag);

            cmd.SetGlobalTexture("_BlitTex", sourceRT);

            // We need to handle viewport on a RT. We do it by rendering a fullscreen quad + viewport
            if (!renderingData.cameraData.isDefaultViewport)
            {
                SetRenderTarget(
                    cmd,
                    BuiltinRenderTextureType.CameraTarget,
                    RenderBufferLoadAction.DontCare,
                    RenderBufferStoreAction.Store,
                    ClearFlag.None,
                    Color.black,
                    descriptor.dimension);

                cmd.SetViewProjectionMatrices(Matrix4x4.identity, Matrix4x4.identity);
                cmd.SetViewport(renderingData.cameraData.camera.pixelRect);
                ScriptableRenderer.RenderFullscreenQuad(cmd, material);
            }
            else
            {
                cmd.Blit(colorAttachmentHandle.Identifier(), BuiltinRenderTextureType.CameraTarget, material);
            }

            context.ExecuteCommandBuffer(cmd);
            CommandBufferPool.Release(cmd);
        }
コード例 #3
0
        public override void Execute(ScriptableRenderer renderer, ScriptableRenderContext context, ref RenderingData renderingData)
        {
            // Restore Render target for additional editor rendering.
            // Note: Scene view camera always perform depth prepass
            CommandBuffer cmd = CommandBufferPool.Get(k_CopyDepthToCameraTag);

            CoreUtils.SetRenderTarget(cmd, BuiltinRenderTextureType.CameraTarget);
            cmd.SetGlobalTexture("_CameraDepthAttachment", source.Identifier());
            cmd.EnableShaderKeyword(LightweightKeywordStrings.DepthNoMsaa);
            cmd.DisableShaderKeyword(LightweightKeywordStrings.DepthMsaa2);
            cmd.DisableShaderKeyword(LightweightKeywordStrings.DepthMsaa4);
            cmd.Blit(source.Identifier(), BuiltinRenderTextureType.CameraTarget, renderer.GetMaterial(MaterialHandles.DepthCopy));
            context.ExecuteCommandBuffer(cmd);
            CommandBufferPool.Release(cmd);
        }
コード例 #4
0
        /// <inheritdoc/>
        public override void Execute(ScriptableRenderer renderer, ScriptableRenderContext context, ref RenderingData renderingData)
        {
            if (renderer == null)
            {
                throw new ArgumentNullException("renderer");
            }

            CommandBuffer          cmd              = CommandBufferPool.Get(k_DepthCopyTag);
            RenderTargetIdentifier depthSurface     = source.Identifier();
            RenderTargetIdentifier copyDepthSurface = destination.Identifier();
            Material depthCopyMaterial              = renderer.GetMaterial(MaterialHandle.CopyDepth);

            RenderTextureDescriptor descriptor = ScriptableRenderer.CreateRenderTextureDescriptor(ref renderingData.cameraData);

            descriptor.colorFormat     = RenderTextureFormat.Depth;
            descriptor.depthBufferBits = 32; //TODO: fix this ;
            descriptor.msaaSamples     = 1;
            descriptor.bindMS          = false;
            cmd.GetTemporaryRT(destination.id, descriptor, FilterMode.Point);

            cmd.SetGlobalTexture("_CameraDepthAttachment", source.Identifier());
            cmd.SetGlobalTexture("_CameraDepthTexture", source.Identifier());

            if (renderingData.cameraData.msaaSamples > 1)
            {
                cmd.DisableShaderKeyword(ShaderKeywordStrings.DepthNoMsaa);
                if (renderingData.cameraData.msaaSamples == 4)
                {
                    cmd.DisableShaderKeyword(ShaderKeywordStrings.DepthMsaa2);
                    cmd.EnableShaderKeyword(ShaderKeywordStrings.DepthMsaa4);
                }
                else
                {
                    cmd.EnableShaderKeyword(ShaderKeywordStrings.DepthMsaa2);
                    cmd.DisableShaderKeyword(ShaderKeywordStrings.DepthMsaa4);
                }
                cmd.Blit(depthSurface, copyDepthSurface, depthCopyMaterial);
            }
            else
            {
                cmd.EnableShaderKeyword(ShaderKeywordStrings.DepthNoMsaa);
                cmd.DisableShaderKeyword(ShaderKeywordStrings.DepthMsaa2);
                cmd.DisableShaderKeyword(ShaderKeywordStrings.DepthMsaa4);
                ScriptableRenderer.CopyTexture(cmd, depthSurface, copyDepthSurface, depthCopyMaterial);
            }
            context.ExecuteCommandBuffer(cmd);
            CommandBufferPool.Release(cmd);
        }
コード例 #5
0
        /// <inheritdoc/>
        public override void Execute(ScriptableRenderer renderer, ScriptableRenderContext context, ref RenderingData renderingData)
        {
            if (renderer == null)
            {
                throw new ArgumentNullException("renderer");
            }

            CommandBuffer cmd          = CommandBufferPool.Get(k_Tag);
            Downsampling  downsampling = renderingData.cameraData.opaqueTextureDownsampling;
            float         opaqueScaler = m_OpaqueScalerValues[(int)downsampling];

            RenderTextureDescriptor opaqueDesc    = ScriptableRenderer.CreateRenderTextureDescriptor(ref renderingData.cameraData, opaqueScaler);
            RenderTargetIdentifier  colorRT       = source.Identifier();
            RenderTargetIdentifier  opaqueColorRT = destination.Identifier();

            cmd.GetTemporaryRT(destination.id, opaqueDesc, renderingData.cameraData.opaqueTextureDownsampling == Downsampling.None ? FilterMode.Point : FilterMode.Bilinear);
            switch (downsampling)
            {
            case Downsampling.None:
                cmd.Blit(colorRT, opaqueColorRT);
                break;

            case Downsampling._2xBilinear:
                cmd.Blit(colorRT, opaqueColorRT);
                break;

            case Downsampling._4xBox:
                Material samplingMaterial = renderer.GetMaterial(MaterialHandle.Sampling);
                samplingMaterial.SetFloat(m_SampleOffsetShaderHandle, 2);
                cmd.Blit(colorRT, opaqueColorRT, samplingMaterial, 0);
                break;

            case Downsampling._4xBilinear:
                cmd.Blit(colorRT, opaqueColorRT);
                break;
            }

            //resume render target
            RenderBufferLoadAction  loadOp  = RenderBufferLoadAction.Load;
            RenderBufferStoreAction storeOp = RenderBufferStoreAction.Store;

            SetRenderTarget(cmd, source.Identifier(), loadOp, storeOp,
                            depth.Identifier(), loadOp, storeOp, ClearFlag.None, Color.black, baseDescriptor.dimension);

            context.ExecuteCommandBuffer(cmd);
            CommandBufferPool.Release(cmd);
        }
コード例 #6
0
        protected void RenderObjectsWithError(ScriptableRenderer renderer, ref ScriptableRenderContext context, ref CullResults cullResults, Camera camera, FilterRenderersSettings filterSettings, SortFlags sortFlags)
        {
            Material errorMaterial = renderer.GetMaterial(MaterialHandles.Error);

            if (errorMaterial != null)
            {
                DrawRendererSettings errorSettings = new DrawRendererSettings(camera, m_LegacyShaderPassNames[0]);
                for (int i = 1; i < m_LegacyShaderPassNames.Count; ++i)
                {
                    errorSettings.SetShaderPassName(i, m_LegacyShaderPassNames[i]);
                }

                errorSettings.sorting.flags         = sortFlags;
                errorSettings.rendererConfiguration = RendererConfiguration.None;
                errorSettings.SetOverrideMaterial(errorMaterial, 0);
                context.DrawRenderers(cullResults.visibleRenderers, ref errorSettings, filterSettings);
            }
        }
        /// <inheritdoc/>
        public override void Execute(ScriptableRenderer renderer, ScriptableRenderContext context, ref RenderingData renderingData)
        {
            if (renderer == null)
            {
                throw new ArgumentNullException("renderer");
            }

            if (renderingData.lightData.mainLightIndex == -1)
            {
                return;
            }

            CommandBuffer cmd = CommandBufferPool.Get(k_CollectShadowsTag);

            cmd.GetTemporaryRT(colorAttachmentHandle.id, descriptor, FilterMode.Bilinear);

            VisibleLight shadowLight = renderingData.lightData.visibleLights[renderingData.lightData.mainLightIndex];

            SetShadowCollectPassKeywords(cmd, ref shadowLight, ref renderingData.shadowData);

            // Note: The source isn't actually 'used', but there's an engine peculiarity (bug) that
            // doesn't like null sources when trying to determine a stereo-ized blit.  So for proper
            // stereo functionality, we use the screen-space shadow map as the source (until we have
            // a better solution).
            // An alternative would be DrawProcedural, but that would require further changes in the shader.
            RenderTargetIdentifier screenSpaceOcclusionTexture = colorAttachmentHandle.Identifier();

            SetRenderTarget(cmd, screenSpaceOcclusionTexture, RenderBufferLoadAction.DontCare, RenderBufferStoreAction.Store,
                            ClearFlag.Color | ClearFlag.Depth, Color.white, descriptor.dimension);
            cmd.Blit(screenSpaceOcclusionTexture, screenSpaceOcclusionTexture, renderer.GetMaterial(MaterialHandle.ScreenSpaceShadow));

            if (renderingData.cameraData.isStereoEnabled)
            {
                Camera camera = renderingData.cameraData.camera;
                context.StartMultiEye(camera);
                context.ExecuteCommandBuffer(cmd);
                context.StopMultiEye(camera);
            }
            else
            {
                context.ExecuteCommandBuffer(cmd);
            }
            CommandBufferPool.Release(cmd);
        }
コード例 #8
0
        /// <inheritdoc/>
        public override void Execute(ScriptableRenderer renderer, ScriptableRenderContext context, ref RenderingData renderingData)
        {
            if (renderer == null)
            {
                throw new ArgumentNullException("renderer");
            }

            var cmd = CommandBufferPool.Get(k_Tag);

            var colorRT       = source.Identifier();
            var opaqueColorRT = destination.Identifier();

            var inter = intermediate.Identifier();

            if (SystemInfo.graphicsUVStartsAtTop)
            {
                var colorDescriptor = descriptor;
                colorDescriptor.depthBufferBits = 0;
                colorDescriptor.msaaSamples     = (int)sampleCount;
                cmd.GetTemporaryRT(intermediate.id, colorDescriptor, FilterMode.Point);
                cmd.SetGlobalVector(UVTransformID, new Vector4(1.0f, -1.0f, 0.0f, 1.0f));
                var mat = renderer.GetMaterial(MaterialHandle.BlitFlip);
                cmd.Blit(colorRT, inter);
                cmd.SetGlobalTexture("_MainTex", inter);
                cmd.Blit(inter, opaqueColorRT, mat);

                if (Status.Valid)
                {
                    Status.CodePath = "Flip";
                    cmd.Blit(colorRT, Status.Blit0.texture);
                    cmd.Blit(inter, Status.Blit1.texture);
                    cmd.Blit(opaqueColorRT, Status.Blit2.texture);
                }
            }
            else
            {
                if (sampleCount == SampleCount.One)
                {
                    cmd.Blit(colorRT, opaqueColorRT);

                    if (Status.Valid)
                    {
                        Status.CodePath = "Direct";
                        cmd.Blit(colorRT, Status.Blit0.texture);
                        cmd.Blit(opaqueColorRT, Status.Blit2.texture);
                    }
                }
                else
                {
                    var colorDescriptor = descriptor;
                    colorDescriptor.depthBufferBits = 0;
                    colorDescriptor.msaaSamples     = 1;
                    cmd.GetTemporaryRT(intermediate.id, colorDescriptor, FilterMode.Point);
                    cmd.Blit(colorRT, inter);
                    cmd.SetGlobalTexture("_MainTex", inter);
                    cmd.Blit(inter, opaqueColorRT);

                    if (Status.Valid)
                    {
                        Status.CodePath = "MSAA";
                        cmd.Blit(colorRT, Status.Blit0.texture);
                        cmd.Blit(inter, Status.Blit1.texture);
                        cmd.Blit(opaqueColorRT, Status.Blit2.texture);
                    }
                }
            }
            cmd.ReleaseTemporaryRT(intermediate.id);

            context.ExecuteCommandBuffer(cmd);
            CommandBufferPool.Release(cmd);
        }
コード例 #9
0
        public override void Execute(ScriptableRenderer renderer, ScriptableRenderContext context, ref RenderingData renderingData)
        {
            if (renderer == null)
            {
                throw new ArgumentNullException("renderer");
            }

            CommandBuffer cmd = CommandBufferPool.Get(_kRenderOITTag);

            using (new ProfilingSample(cmd, _kRenderOITTag))
            {
                cmd.GetTemporaryRT(_AccumColorHandle.id, _DescriptorAC);
                cmd.GetTemporaryRT(_AccumGIHandle.id, _DescriptorAC);
                cmd.GetTemporaryRT(_AccumAlphaHandle.id, _DescriptorAA);

                cmd.SetRenderTarget(_AccumBinding);
                cmd.ClearRenderTarget(false, true, Color.black);

                context.ExecuteCommandBuffer(cmd);
                cmd.Clear();

                Camera camera       = renderingData.cameraData.camera;
                var    drawSettings = CreateDrawRendererSettings(camera, SortFlags.None, _RendererConfiguration, renderingData.supportsDynamicBatching);
                context.DrawRenderers(renderingData.cullResults.visibleRenderers, ref drawSettings, _OITFilterSettings);

                // Render objects that did not match any shader pass with error shader
                renderer.RenderObjectsWithError(context, ref renderingData.cullResults, camera, _OITFilterSettings, SortFlags.None);
                context.ExecuteCommandBuffer(cmd);
                cmd.Clear();

                //cmd.SetGlobalTexture("_AccumColor", _AccumColorHandle.Identifier());
                //cmd.SetGlobalTexture("_AccumAlpha", _AccumAlphaHandle.Identifier());

                RenderBufferLoadAction  loadOp  = RenderBufferLoadAction.Load;
                RenderBufferStoreAction storeOp = RenderBufferStoreAction.Store;
                SetRenderTarget(cmd, _ColorAttachmentHandle.Identifier(), loadOp, storeOp,
                                _DepthAttachmentHandle.Identifier(), loadOp, storeOp, ClearFlag.None, Color.black, _Descriptor.dimension);
                cmd.Blit(_ColorAttachmentHandle.Identifier(), _ColorAttachmentHandle.Identifier(), renderer.GetMaterial(MaterialHandle.OITComposite));
            }

            context.ExecuteCommandBuffer(cmd);
            CommandBufferPool.Release(cmd);
        }
コード例 #10
0
        public override void Execute(ScriptableRenderer renderer, ScriptableRenderContext context, ref RenderingData renderingData)
        {
            if (renderer == null)
            {
                throw new ArgumentNullException("renderer");
            }

            CommandBuffer cmd = CommandBufferPool.Get(_kRenderOITTag);

            using (new ProfilingSample(cmd, _kRenderOITTag))
            {
                cmd.GetTemporaryRT(_B0Handle.id, _DescriptorFloat);
                cmd.GetTemporaryRT(_B1Handle.id, _DescriptorFloat4);
                if (MomentsCount._8 == _MomentsCount)
                {
                    cmd.GetTemporaryRT(_B2Handle.id, _DescriptorFloat4);
                }
                else if (MomentsCount._6 == _MomentsCount)
                {
                    cmd.GetTemporaryRT(_B2Handle.id, _DescriptorFloat2);
                }
                CoreUtils.SetKeyword(cmd, "_MOMENT6", MomentsCount._6 == _MomentsCount);
                CoreUtils.SetKeyword(cmd, "_MOMENT8", MomentsCount._8 == _MomentsCount);
                CoreUtils.SetKeyword(cmd, "_MOMENT_HALF_PRECISION", FloatPrecision._Half == _MomentsPrecision);
                CoreUtils.SetKeyword(cmd, "_TRIGONOMETRIC", _Trigonometric);

                cmd.SetRenderTarget(_GMBinding);
                cmd.ClearRenderTarget(false, true, Color.black);

                context.ExecuteCommandBuffer(cmd);
                cmd.Clear();

                Vector2 logViewDepthMinDelta = new Vector2(Mathf.Log(_ViewDepthMinMax.x), Mathf.Log(_ViewDepthMinMax.y));
                logViewDepthMinDelta.y = logViewDepthMinDelta.y - logViewDepthMinDelta.x;
                cmd.SetGlobalVector("_LogViewDepthMinDelta", logViewDepthMinDelta);
                //cmd.SetGlobalFloat("_Overestimation", 0.25f);
                //cmd.SetGlobalFloat("_MomentBias", 0);

                if (_Trigonometric)
                {
                    Vector4 _WrappingZoneParameters = new Vector4();
                    _WrappingZoneParameters.x = 3.14f;
                    _WrappingZoneParameters.y = 3.14f - 0.5f * _WrappingZoneParameters.x;
                    float a = _WrappingZoneParameters.y * 2;
                    float x = Mathf.Cos(a);
                    float y = Mathf.Sin(a);
                    float r = Mathf.Abs(y) - Mathf.Abs(x);
                    r = (x < 0) ? (2.0f - r) : r;
                    r = (y < 0) ? (6.0f - r) : r;
                    _WrappingZoneParameters.z = 1 / (7 - r);
                    _WrappingZoneParameters.w = 1 - 7 * _WrappingZoneParameters.z;
                    cmd.SetGlobalVector("_WrappingZoneParameters", _WrappingZoneParameters);
                }

                Camera camera       = renderingData.cameraData.camera;
                var    drawSettings = CreateDrawRendererSettings(camera, SortFlags.None, _RendererConfiguration, renderingData.supportsDynamicBatching);

                context.DrawRenderers(renderingData.cullResults.visibleRenderers, ref drawSettings, _OITFilterSettings);

                // Render objects that did not match any shader pass with error shader
                renderer.RenderObjectsWithError(context, ref renderingData.cullResults, camera, _OITFilterSettings, SortFlags.None);
                context.ExecuteCommandBuffer(cmd);
                cmd.Clear();

                cmd.GetTemporaryRT(_MOITHandle.id, _Descriptor);
                if (renderingData.shadowData.supportsDeepShadowMaps)
                {
                    cmd.GetTemporaryRT(_GIALHandle.id, _Descriptor);
                    cmd.SetRenderTarget(_RMBinding);
                    cmd.ClearRenderTarget(false, true, Color.black);
                }
                else
                {
                    CoreUtils.SetRenderTarget(cmd,
                                              _MOITHandle.Identifier(), RenderBufferLoadAction.DontCare, RenderBufferStoreAction.Store,
                                              _DepthAttachmentHandle.Identifier(), RenderBufferLoadAction.Load, RenderBufferStoreAction.DontCare,
                                              ClearFlag.Color, Color.black);
                }
                context.ExecuteCommandBuffer(cmd);
                cmd.Clear();

                cmd.SetGlobalTexture("_b0", _B0Handle.id);
                cmd.SetGlobalTexture("_b1", _B1Handle.id);
                if (MomentsCount._4 != _MomentsCount)
                {
                    cmd.SetGlobalTexture("_b2", _B2Handle.id);
                }

                drawSettings.SetShaderPassName(0, new ShaderPassName("ResolveMoments"));
                context.DrawRenderers(renderingData.cullResults.visibleRenderers, ref drawSettings, _OITFilterSettings);
                // Render objects that did not match any shader pass with error shader
                renderer.RenderObjectsWithError(context, ref renderingData.cullResults, camera, _OITFilterSettings, SortFlags.None);
                context.ExecuteCommandBuffer(cmd);
                cmd.Clear();


                CoreUtils.SetRenderTarget(cmd,
                                          _ColorAttachmentHandle.Identifier(), RenderBufferLoadAction.Load, RenderBufferStoreAction.Store,
                                          ClearFlag.None);
                cmd.Blit(_ColorAttachmentHandle.Identifier(), _ColorAttachmentHandle.Identifier(), renderer.GetMaterial(MaterialHandle.MomentOITComposite));
                context.ExecuteCommandBuffer(cmd);
                cmd.Clear();
            }

            context.ExecuteCommandBuffer(cmd);
            CommandBufferPool.Release(cmd);
        }
コード例 #11
0
        /// <inheritdoc/>
        public override void Execute(ScriptableRenderer renderer, ScriptableRenderContext context, ref RenderingData renderingData)
        {
            if (renderer == null)
            {
                throw new ArgumentNullException("renderer");
            }

            if (!renderingData.shadowData.supportsDeepShadowMaps)
            {
                return;
            }
            LightData lightData        = renderingData.lightData;
            int       shadowLightIndex = lightData.mainLightIndex;

            if (shadowLightIndex == -1)
            {
                return;
            }


            VisibleLight shadowLight = lightData.visibleLights[shadowLightIndex];
            ShadowData   shadowData  = renderingData.shadowData;

            RenderTargetIdentifier result;

            CommandBuffer cmd = CommandBufferPool.Get(k_RenderScreenSpaceDeepShadowMaps);

            using (new ProfilingSample(cmd, k_RenderScreenSpaceDeepShadowMaps))
            {
#if UNITY_EDITOR
                var testDescriptor = _Descriptor;
                testDescriptor.enableRandomWrite = true;
                testDescriptor.colorFormat       = RenderTextureFormat.ARGB32;
                cmd.GetTemporaryRT(_DeepShadowTest.id, testDescriptor);
                var _ResetCompute           = renderer.GetCompute(ComputeHandle.ResetDeepShadowDataCompute);
                int KernelTestDeepShadowMap = _ResetCompute.FindKernel("KernelTestDeepShadowMap");
                cmd.SetRenderTarget(_DeepShadowTest.Identifier());
                cmd.SetComputeBufferParam(_ResetCompute, KernelTestDeepShadowMap, "_CountBuffer", _CountBuffer);
                cmd.SetComputeBufferParam(_ResetCompute, KernelTestDeepShadowMap, "_DataBuffer", _DataBuffer);
                cmd.SetComputeTextureParam(_ResetCompute, KernelTestDeepShadowMap, "_TestRt", _DeepShadowTest.Identifier());
                cmd.DispatchCompute(_ResetCompute, KernelTestDeepShadowMap, shadowData.deepShadowMapsSize / 8, shadowData.deepShadowMapsSize / 8, 1);

                context.ExecuteCommandBuffer(cmd);
                cmd.Clear();
#endif

                // Resolve
                Material ssdsm = renderer.GetMaterial(MaterialHandle.ScreenSpaceDeepShadowMaps);
                ssdsm.SetBuffer(Shader.PropertyToID("_CountBuffer"), _CountBuffer);
                ssdsm.SetBuffer(Shader.PropertyToID("_DataBuffer"), _DataBuffer);
                cmd.GetTemporaryRT(_DeepShadowLut.id, _Descriptor);

                RenderTargetIdentifier lutId = _DeepShadowLut.Identifier();
                SetRenderTarget(cmd, lutId, RenderBufferLoadAction.DontCare, RenderBufferStoreAction.Store,
                                ClearFlag.Color | ClearFlag.Depth, Color.black, _Descriptor.dimension);
                cmd.Blit(lutId, lutId, ssdsm);

                result = lutId;

                // Blur
                int blurOffset = shadowData.deepShadowMapsBlurOffset;

                if (blurOffset > 0)
                {
                    Material pom = renderer.GetMaterial(MaterialHandle.GaussianBlur);
                    cmd.GetTemporaryRT(_DeepShadowTmp.id, _Descriptor);
                    RenderTargetIdentifier src = lutId;
                    RenderTargetIdentifier dst = _DeepShadowTmp.Identifier();
                    while (blurOffset > 0)
                    {
                        pom.SetFloat("_SampleOffset", blurOffset);
                        SetRenderTarget(cmd, dst, RenderBufferLoadAction.DontCare, RenderBufferStoreAction.Store,
                                        ClearFlag.Color | ClearFlag.Depth, Color.black, _Descriptor.dimension);
                        cmd.Blit(src, dst, pom);
                        result       = dst;
                        dst          = src;
                        src          = result;
                        blurOffset >>= 1;
                    }
                }
                //TODO : for stereo

                context.ExecuteCommandBuffer(cmd);
                cmd.Clear();

                cmd.SetGlobalTexture(_Destination.id, result);
                cmd.ReleaseTemporaryRT(_DeepShadowTest.id);
            }
            //SetKeyword
            CoreUtils.SetKeyword(cmd, ShaderKeywordStrings.DeepShadowMaps, true);
            context.ExecuteCommandBuffer(cmd);
            CommandBufferPool.Release(cmd);
        }