예제 #1
0
        internal void GatherArray(RwTexId postprocessTarget, RwTexId cascadeArray, MyProjectionInfo[] cascadeInfo, ConstantsBufferId cascadeConstantBuffer)
        {
            if (!MyRenderProxy.Settings.EnableShadows)
            {
                return;
            }

            MarkCascadesInStencil(cascadeInfo);

            MyGpuProfiler.IC_BeginBlock("Cascades postprocess");

            MyRenderContext renderContext = MyRenderContext.Immediate;
            DeviceContext   deviceContext = renderContext.DeviceContext;

            renderContext.SetCS(m_gatherCS);
            ComputeShaderId.TmpUav[0] = postprocessTarget.Uav;
            deviceContext.ComputeShader.SetUnorderedAccessViews(0, ComputeShaderId.TmpUav, ComputeShaderId.TmpCount);

            deviceContext.ComputeShader.SetShaderResource(0, MyRender11.MultisamplingEnabled ? MyScreenDependants.m_resolvedDepth.m_SRV_depth : MyGBuffer.Main.DepthStencil.m_SRV_depth);
            deviceContext.ComputeShader.SetShaderResource(1, MyGBuffer.Main.DepthStencil.m_SRV_stencil);
            deviceContext.ComputeShader.SetSampler(MyCommon.SHADOW_SAMPLER_SLOT, MyRender11.m_shadowmapSamplerState);
            deviceContext.ComputeShader.SetConstantBuffer(0, MyCommon.FrameConstants);
            deviceContext.ComputeShader.SetConstantBuffer(4, cascadeConstantBuffer);
            deviceContext.ComputeShader.SetShaderResource(MyCommon.CASCADES_SM_SLOT, cascadeArray.ShaderView);

            deviceContext.Dispatch(m_threadGroupCountX, m_threadGroupCountY, 1);

            ComputeShaderId.TmpUav[0] = null;
            renderContext.DeviceContext.ComputeShader.SetUnorderedAccessViews(0, ComputeShaderId.TmpUav, ComputeShaderId.TmpCount);
            deviceContext.ComputeShader.SetShaderResource(0, null);

            if (MyRender11.Settings.EnableShadowBlur)
            {
                MyBlur.Run(postprocessTarget.Rtv, MyRender11.CascadesHelper.Rtv, MyRender11.CascadesHelper.ShaderView, postprocessTarget.ShaderView, depthDiscardThreshold: 0.2f);
            }

            MyGpuProfiler.IC_EndBlock();
        }
예제 #2
0
        internal void GatherArray(RwTexId postprocessTarget, RwTexId cascadeArray, MyProjectionInfo[] cascadeInfo, ConstantsBufferId cascadeConstantBuffer)
        {
            if (!MyRenderProxy.Settings.EnableShadows || !MyRender11.DebugOverrides.Shadows)
            {
                return;
            }

            MarkCascadesInStencil(cascadeInfo);

            MyGpuProfiler.IC_BeginBlock("Cascades postprocess");

            MyRenderContext renderContext = MyRenderContext.Immediate;
            DeviceContext   deviceContext = renderContext.DeviceContext;

            MyShadowsQuality shadowsQuality = MyRender11.RenderSettings.ShadowQuality.GetShadowsQuality();

            if (shadowsQuality == MyShadowsQuality.LOW)
            {
                renderContext.SetCS(m_gatherCS_LD);
            }
            else if (shadowsQuality == MyShadowsQuality.MEDIUM)
            {
                renderContext.SetCS(m_gatherCS_MD);
            }
            else if (shadowsQuality == MyShadowsQuality.HIGH)
            {
                renderContext.SetCS(m_gatherCS_HD);
            }

            ComputeShaderId.TmpUav[0] = postprocessTarget.Uav;
            deviceContext.ComputeShader.SetUnorderedAccessViews(0, ComputeShaderId.TmpUav, ComputeShaderId.TmpCount);

            deviceContext.ComputeShader.SetShaderResource(0, MyRender11.MultisamplingEnabled ? MyScreenDependants.m_resolvedDepth.m_SRV_depth : MyGBuffer.Main.DepthStencil.m_SRV_depth);
            deviceContext.ComputeShader.SetShaderResource(1, MyGBuffer.Main.DepthStencil.m_SRV_stencil);
            deviceContext.ComputeShader.SetSampler(MyCommon.SHADOW_SAMPLER_SLOT, SamplerStates.m_shadowmap);
            if (!MyStereoRender.Enable)
            {
                deviceContext.ComputeShader.SetConstantBuffer(0, MyCommon.FrameConstants);
            }
            else
            {
                MyStereoRender.CSBindRawCB_FrameConstants(renderContext);
            }
            deviceContext.ComputeShader.SetConstantBuffer(4, cascadeConstantBuffer);
            deviceContext.ComputeShader.SetShaderResource(MyCommon.CASCADES_SM_SLOT, cascadeArray.SRV);

            Vector2I threadGroups = GetThreadGroupCount();

            deviceContext.Dispatch(threadGroups.X, threadGroups.Y, 1);

            ComputeShaderId.TmpUav[0] = null;
            renderContext.DeviceContext.ComputeShader.SetUnorderedAccessViews(0, ComputeShaderId.TmpUav, ComputeShaderId.TmpCount);
            deviceContext.ComputeShader.SetShaderResource(0, null);
            deviceContext.ComputeShader.SetShaderResource(1, null);

            if (shadowsQuality == MyShadowsQuality.HIGH && MyRender11.Settings.EnableShadowBlur)
            {
                MyBlur.Run(postprocessTarget.Rtv, MyRender11.CascadesHelper.Rtv, MyRender11.CascadesHelper.SRV, postprocessTarget.SRV, depthDiscardThreshold: 0.2f);
            }

            MyGpuProfiler.IC_EndBlock();
        }