Ejemplo n.º 1
0
 private static void DebugDraw(ISrvBindable src, IRtvBindable dst, MyViewport viewport)
 {
     RC.PixelShader.Set(m_copyPS);
     RC.SetRtv(dst);
     RC.PixelShader.SetSrv(0, src);
     MyScreenPass.DrawFullscreenQuad(viewport);
 }
 internal static void DisplayHistogram(RenderTargetView rtv)
 {
     RC.Context.PixelShader.SetShaderResource(0, m_histogram.ShaderView);
     RC.Context.PixelShader.Set(m_drawHistogram);
     RC.Context.OutputMerger.SetRenderTargets(rtv);
     MyScreenPass.DrawFullscreenQuad(new MyViewport(64, 64, 512, 64));
 }
Ejemplo n.º 3
0
        static void DrawBlurYPS(IRtvBindable dst, MyViewport viewport)
        {
            RC.SetRtv(dst);
            RC.PixelShader.Set(m_blurYPS);
            RC.PixelShader.SetSrv(0, m_fullResAOZTexture);

            MyScreenPass.DrawFullscreenQuad(viewport);
        }
Ejemplo n.º 4
0
 internal static void ResolveOIT(MyUnorderedAccessTexture accumTarget, MyUnorderedAccessTexture coverageTarget)
 {
     RC.SetBS(MyRender11.BlendInvTransparent);
     RC.SetPS(m_psResolve);
     RC.BindDepthRT(null, DepthStencilAccess.ReadOnly, MyGBuffer.Main.Get(MyGbufferSlot.LBuffer));
     RC.BindSRV(0, accumTarget);
     RC.BindSRV(1, coverageTarget);
     MyScreenPass.DrawFullscreenQuad(null);
 }
Ejemplo n.º 5
0
 public static void DisplayHistogram(IRtvBindable output, ISrvBindable avgLumSrv, ISrvTexture histogram)
 {
     RC.PixelShader.SetSrvs(0, histogram, avgLumSrv);
     RC.PixelShader.Set(m_drawHistogram);
     RC.SetRtv(output);
     MyScreenPass.DrawFullscreenQuad(new MyViewport(64, 64, 512, 64));
     //m_histogram.Release();
     //m_histogram = null;
 }
Ejemplo n.º 6
0
 static void DrawLinearDepthPS(ISrvBindable resolvedDepth, IRtvBindable rtv, MyViewport viewport)
 {
     RC.PixelShader.Set(m_linearizeDepthPS);
     //RC.SetRtv(m_fullResViewDepthTarget);
     RC.SetRtv(rtv);
     RC.PixelShader.SetSrv(0, resolvedDepth);
     MyScreenPass.DrawFullscreenQuad(viewport);
     RC.SetRtv(null);
 }
Ejemplo n.º 7
0
        static void RenderDirectionalEnvironmentLight()
        {
            PixelShaderId directionalPixelShader;

            if (!MyRenderProxy.Settings.EnableShadows)
            {
                if (DirectionalEnvironmentLight_NoShadow == PixelShaderId.NULL)
                {
                    DirectionalEnvironmentLight_NoShadow = MyShaders.CreatePs("light_dir.hlsl", new[] { new ShaderMacro("NO_SHADOWS", null) });
                }

                directionalPixelShader = DirectionalEnvironmentLight_NoShadow;
            }
            else
            {
                directionalPixelShader = DirectionalEnvironmentLight_Pixel;
            }
            MySunlightConstantsLayout constants;

            constants.Direction = MyEnvironment.DirectionalLightDir;
            constants.Color     = MyEnvironment.DirectionalLightIntensity;

            var mapping = MyMapping.MapDiscard(m_sunlightConstants);

            mapping.WriteAndPosition(ref constants);
            mapping.Unmap();

            //context.VertexShader.Set(MyCommon.FullscreenShader.VertexShader);
            RC.SetPS(directionalPixelShader);
            RC.SetCB(1, m_sunlightConstants);
            RC.SetCB(4, MyRender11.DynamicShadows.ShadowCascades.CascadeConstantBuffer);
            RC.DeviceContext.PixelShader.SetSamplers(0, MyRender11.StandardSamplers);
            RC.DeviceContext.PixelShader.SetSampler(MyCommon.SHADOW_SAMPLER_SLOT, MyRender11.m_shadowmapSamplerState);

            RC.DeviceContext.PixelShader.SetShaderResource(MyCommon.SKYBOX_SLOT, MyTextures.GetView(MyTextures.GetTexture(MyEnvironment.DaySkybox, MyTextureEnum.CUBEMAP, true)));

            RC.DeviceContext.PixelShader.SetShaderResource(MyCommon.SKYBOX_IBL_SLOT,
                                                           MyRender11.IsIntelBrokenCubemapsWorkaround ? MyTextures.GetView(MyTextures.IntelFallbackCubeTexId) : MyEnvironmentProbe.Instance.cubemapPrefiltered.ShaderView);
            RC.DeviceContext.PixelShader.SetShaderResource(MyCommon.SKYBOX2_SLOT, MyTextures.GetView(MyTextures.GetTexture(MyEnvironment.NightSkybox, MyTextureEnum.CUBEMAP, true)));
            RC.DeviceContext.PixelShader.SetShaderResource(MyCommon.SKYBOX2_IBL_SLOT, MyTextures.GetView(MyTextures.GetTexture(MyEnvironment.NightSkyboxPrefiltered, MyTextureEnum.CUBEMAP, true)));

            RC.DeviceContext.PixelShader.SetShaderResource(MyCommon.CASCADES_SM_SLOT, MyRender11.DynamicShadows.ShadowCascades.CascadeShadowmapArray.ShaderView);
            RC.DeviceContext.PixelShader.SetShaderResource(MyCommon.SHADOW_SLOT, MyRender11.PostProcessedShadows.ShaderView);

            RC.DeviceContext.PixelShader.SetShaderResource(MyCommon.AMBIENT_BRDF_LUT_SLOT,
                                                           MyCommon.GetAmbientBrdfLut());

            RC.BindSRV(MyCommon.AO_SLOT, MyScreenDependants.m_ambientOcclusion);

            MyScreenPass.RunFullscreenPixelFreq(MyGBuffer.Main.Get(MyGbufferSlot.LBuffer));
            if (MyRender11.MultisamplingEnabled)
            {
                RC.SetPS(DirectionalEnvironmentLight_Sample);
                MyScreenPass.RunFullscreenSampleFreq(MyGBuffer.Main.Get(MyGbufferSlot.LBuffer));
            }
        }
Ejemplo n.º 8
0
        static void DrawBlurXPS(MyViewport viewport)
        {
            RC.SetRtv(m_fullResAOZTexture);
            RC.PixelShader.Set(m_blurXPS);
            RC.PixelShader.SetSrv(0, m_fullResAOZTexture2);
            RC.PixelShader.SetSamplers(0, MySamplerStateManager.Point);
            RC.PixelShader.SetSamplers(1, MySamplerStateManager.Linear);

            MyScreenPass.DrawFullscreenQuad(viewport);
        }
Ejemplo n.º 9
0
 private static void ResolveOIT(ISrvBindable accumTarget, ISrvBindable coverageTarget)
 {
     RC.SetDepthStencilState(MyDepthStencilStateManager.IgnoreDepthStencil);
     RC.SetBlendState(MyBlendStateManager.BlendWeightedTransparencyResolve);
     RC.PixelShader.Set(m_psResolve);
     RC.SetRtv(MyGBuffer.Main.LBuffer);
     RC.PixelShader.SetSrv(0, accumTarget);
     RC.PixelShader.SetSrv(1, coverageTarget);
     MyScreenPass.DrawFullscreenQuad(null);
 }
Ejemplo n.º 10
0
        internal static void DisplayHistogram(RenderTargetView rtv, ShaderResourceView avgLumSrv)
        {
            RC.DeviceContext.PixelShader.SetShaderResources(0, m_histogram.SRV, avgLumSrv);
            RC.DeviceContext.PixelShader.Set(m_drawHistogram);
            RC.DeviceContext.OutputMerger.SetRenderTargets(rtv);
            MyScreenPass.DrawFullscreenQuad(new MyViewport(64, 64, 512, 64));

            RC.DeviceContext.PixelShader.Set(m_drawTonemapping);
            MyScreenPass.DrawFullscreenQuad(new MyViewport(64, 128, 512, 64));
        }
Ejemplo n.º 11
0
        internal static void Run(RenderTargetView renderTarget, RenderTargetView intermediateRenderTarget, ShaderResourceView intermediateResourceView, ShaderResourceView initialResourceView,
                                 int maxOffset = 5, MyBlurDensityFunctionType densityFunctionType = MyBlurDensityFunctionType.Gaussian, float WeightParameter = 1.5f,
                                 DepthStencilState depthStencilState = null, int stencilRef       = 0x0, bool copyOnStencilFail = false,
                                 float depthDiscardThreshold         = 0.0f, MyViewport?viewport  = null)
        {
            ProfilerShort.Begin("MyBlur.Run");
            MyGpuProfiler.IC_BeginBlock("MyBlur.Run");
            Debug.Assert(initialResourceView != null);
            Debug.Assert(intermediateResourceView != null);
            Debug.Assert(intermediateRenderTarget != null);
            Debug.Assert(renderTarget != null);

            int shaderKey = InitShaders(densityFunctionType, maxOffset, copyOnStencilFail, depthDiscardThreshold);

            RC.DeviceContext.PixelShader.SetConstantBuffer(5, m_blurConstantBuffer);

            BlurConstants constants = new BlurConstants
            {
                DistributionWeight = WeightParameter,
                StencilRef         = stencilRef,
            };
            var mapping = MyMapping.MapDiscard(m_blurConstantBuffer);

            mapping.WriteAndPosition(ref constants);
            mapping.Unmap();

            // Horizontal pass
            MyRender11.DeviceContext.ClearRenderTargetView(intermediateRenderTarget, Color4.White);
            RC.DeviceContext.OutputMerger.SetTargets(intermediateRenderTarget);
            RC.SetDS(depthStencilState, stencilRef);
            RC.DeviceContext.PixelShader.SetShaderResource(0, MyGBuffer.Main.DepthStencil.m_SRV_depth);
            RC.DeviceContext.PixelShader.SetShaderResource(4, MyGBuffer.Main.DepthStencil.m_SRV_stencil);
            RC.DeviceContext.PixelShader.SetShaderResource(5, initialResourceView);
            RC.SetPS(m_blurShaders[shaderKey].Item1);
            MyScreenPass.DrawFullscreenQuad(viewport);
            RC.DeviceContext.PixelShader.SetShaderResource(5, null);

            // Vertical pass
            MyRender11.DeviceContext.ClearRenderTargetView(renderTarget, Color4.White);
            RC.DeviceContext.OutputMerger.SetTargets(renderTarget);
            RC.SetDS(depthStencilState, stencilRef);
            RC.DeviceContext.PixelShader.SetShaderResource(0, MyGBuffer.Main.DepthStencil.m_SRV_depth);
            RC.DeviceContext.PixelShader.SetShaderResource(4, MyGBuffer.Main.DepthStencil.m_SRV_stencil);
            RC.DeviceContext.PixelShader.SetShaderResource(5, intermediateResourceView);
            RC.SetPS(m_blurShaders[shaderKey].Item2);
            MyScreenPass.DrawFullscreenQuad(viewport);

            RC.DeviceContext.PixelShader.SetShaderResource(0, null);
            RC.DeviceContext.PixelShader.SetShaderResource(4, null);
            RC.DeviceContext.PixelShader.SetShaderResource(5, null);

            MyGpuProfiler.IC_EndBlock();
            ProfilerShort.End();
        }
Ejemplo n.º 12
0
        internal static unsafe void InitSubsystems()
        {
            InitializeBlendStates();
            InitializeRasterizerStates();
            InitilizeSamplerStates();

            MyCommon.Init();
            MyPipelineStates.Init();
            MyTextures.Init();
            MyVertexLayouts.Init();
            MyShaders.Init();
            MyRwTextures.Init();
            MyHwBuffers.Init();
            MyMeshes.Init();
            MyMeshTableSRV.Init();
            MyMergeInstancing.Init();
            MyGeometryRenderer.Init();
            MyLightRendering.Init();
            MyShadows.Init();
            MyLinesRenderer.Init();
            MySpritesRenderer.Init();
            MyPrimitivesRenderer.Init();
            MyFoliageRenderer.Init();
            MyOutline.Init();

            MyComponents.Init();

            MyBillboardRenderer.Init(); // hardcoded limits
            MyDebugRenderer.Init();
            MyGPUFoliageGenerating.Init();

            MyScreenDecals.Init();
            MyEnvProbeProcessing.Init();
            MyShadowsResolve.Init();
            MyAtmosphereRenderer.Init();
            MyAAEdgeMarking.Init();
            MyScreenPass.Init();
            MyCopyToRT.Init();
            MyBlendTargets.Init();
            MyFXAA.Init();
            MyDepthResolve.Init();
            MyBloom.Init();
            MyLuminanceAverage.Init();
            MyToneMapping.Init();
            MySSAO.Init();
            MyHdrDebugTools.Init();

            MySceneMaterials.Init();
            MyMaterials1.Init();
            MyVoxelMaterials1.Init();
            MyMeshMaterials1.Init();

            //MyShaderFactory.RunCompilation(); // rebuild
        }
Ejemplo n.º 13
0
        internal static void Run(IRtvBindable destination, ISrvBindable source)
        {
            RC.SetBlendState(null);

            RC.SetInputLayout(null);
            RC.PixelShader.Set(m_ps);

            RC.SetRtv(destination);
            RC.PixelShader.SetSrv(0, source);

            MyScreenPass.DrawFullscreenQuad(new MyViewport(destination.Size.X, destination.Size.Y));
        }
Ejemplo n.º 14
0
        internal static void ClearAlpha(IRtvBindable destination)
        {
            RC.SetBlendState(MyBlendStateManager.BlendAdditive);

            RC.SetInputLayout(null);
            RC.PixelShader.Set(m_clearAlphaPs);

            RC.SetRtv(destination);

            MyScreenPass.DrawFullscreenQuad(new MyViewport(destination.Size.X, destination.Size.Y));

            RC.SetBlendState(null);
        }
Ejemplo n.º 15
0
        static void RenderDirectionalEnvironmentLight(ISrvTexture postProcessedShadows)
        {
            PixelShaderId    directionalPixelShader;
            MyShadowsQuality shadowsQuality = MyRender11.RenderSettings.ShadowQuality.GetShadowsQuality();

            if (!MyRender11.Settings.EnableShadows || !MyRender11.DebugOverrides.Shadows || shadowsQuality == MyShadowsQuality.DISABLED)
            {
                if (DirectionalEnvironmentLight_NoShadow == PixelShaderId.NULL)
                {
                    DirectionalEnvironmentLight_NoShadow = MyShaders.CreatePs("Lighting/LightDir.hlsl", new[] { new ShaderMacro("NO_SHADOWS", null) });
                }

                directionalPixelShader = DirectionalEnvironmentLight_NoShadow;
            }
            else
            {
                directionalPixelShader = DirectionalEnvironmentLight_Pixel;
            }

            //context.VertexShader.Set(MyCommon.FullscreenShader.VertexShader);
            RC.PixelShader.Set(directionalPixelShader);
            RC.AllShaderStages.SetConstantBuffer(4, MyRender11.DynamicShadows.ShadowCascades.CascadeConstantBuffer);
            RC.PixelShader.SetSampler(MyCommon.SHADOW_SAMPLER_SLOT, MySamplerStateManager.Shadowmap);

            MyFileTextureManager texManager = MyManagers.FileTextures;

            RC.PixelShader.SetSrv(MyCommon.SKYBOX_SLOT, texManager.GetTexture(MyRender11.Environment.Data.Skybox, MyFileTextureEnum.CUBEMAP, true));

            ISrvBindable skybox = MyRender11.IsIntelBrokenCubemapsWorkaround
                ? MyGeneratedTextureManager.IntelFallbackCubeTex
                : (ISrvBindable)MyManagers.EnvironmentProbe.Cubemap;

            RC.PixelShader.SetSrv(MyCommon.SKYBOX_IBL_SLOT, skybox);

            RC.PixelShader.SetSrv(MyCommon.CASCADES_SM_SLOT, MyRender11.DynamicShadows.ShadowCascades.CascadeShadowmapArray);
            RC.PixelShader.SetSrv(MyCommon.SHADOW_SLOT, postProcessedShadows);

            RC.PixelShader.SetSrv(MyCommon.AMBIENT_BRDF_LUT_SLOT,
                                  MyCommon.GetAmbientBrdfLut());

            RC.PixelShader.SetSrv(MyCommon.AO_SLOT, MyScreenDependants.m_ambientOcclusion);

            MyScreenPass.RunFullscreenPixelFreq(MyGBuffer.Main.LBuffer);
            if (MyRender11.MultisamplingEnabled)
            {
                RC.PixelShader.Set(DirectionalEnvironmentLight_Sample);
                MyScreenPass.RunFullscreenSampleFreq(MyGBuffer.Main.LBuffer);
            }
            RC.PixelShader.SetSrv(MyCommon.SHADOW_SLOT, null);
        }
Ejemplo n.º 16
0
        public static void DisplayHdrIntensity(ISrvBindable srv)
        {
            RC.PixelShader.Set(m_psDisplayHdrIntensity);
            RC.PixelShader.SetSrv(5, srv);
            RC.SetBlendState(null);
            IBorrowedRtvTexture outTex = MyManagers.RwTexturesPool.BorrowRtv("MyHdrDebugTools.DisplayHdrIntensity.OutTex", srv.Size.X, srv.Size.Y, Format.B8G8R8X8_UNorm);

            MyScreenPass.RunFullscreenPixelFreq(outTex);
            MyDebugTextureDisplay.Select(outTex);

            RC.PixelShader.SetSrv(5, null);
            RC.SetRtvs(MyGBuffer.Main, MyDepthStencilAccess.ReadOnly);
            outTex.Release();
        }
Ejemplo n.º 17
0
        static void RenderPointlightsTiled()
        {
            RC.BindSRV(MyCommon.TILE_LIGHT_INDICES_SLOT, MyScreenDependants.m_tileIndices);
            RC.BindRawSRV(MyCommon.POINTLIGHT_SLOT, m_pointlightCullHwBuffer.Srv);
            RC.BindSRV(MyCommon.AO_SLOT, MyScreenDependants.m_ambientOcclusion);

            RC.SetPS(PointlightsTiled_Pixel);
            MyScreenPass.RunFullscreenPixelFreq(MyGBuffer.Main.Get(MyGbufferSlot.LBuffer));
            if (MyRender11.MultisamplingEnabled)
            {
                RC.SetPS(PointlightsTiled_Sample);
                MyScreenPass.RunFullscreenSampleFreq(MyGBuffer.Main.Get(MyGbufferSlot.LBuffer));
            }
        }
Ejemplo n.º 18
0
        internal static unsafe void InitSubsystems()
        {
            MyRwTextures.Init();
            MyHwBuffers.Init();
            MyPipelineStates.Init();
            ResetShadows(MyRenderProxy.Settings.ShadowCascadeCount, RenderSettings.ShadowQuality.ShadowCascadeResolution());
            MyRender11.Init();
            MyCommon.Init();
            SamplerStates.Init();
            MyDepthStencilState.Init();
            MyTextures.Init();
            MyVertexLayouts.Init();
            MyShaders.Init();
            MyMeshes.Init();
            MyMeshTableSRV.Init();
            MyLightRendering.Init();
            MyLinesRenderer.Init();
            MySpritesRenderer.Init();
            MyPrimitivesRenderer.Init();
            MyOutline.Init();
            MyBlur.Init();
            MyTransparentRendering.Init();

            MyFoliageComponents.Init();

            MyBillboardRenderer.Init(); // hardcoded limits
            MyDebugRenderer.Init();

            MyScreenDecals.Init();
            MyEnvProbeProcessing.Init();
            MyAtmosphereRenderer.Init();
            MyCloudRenderer.Init();
            MyAAEdgeMarking.Init();
            MyScreenPass.Init();
            MyCopyToRT.Init();
            MyBlendTargets.Init();
            MyFXAA.Init();
            MyDepthResolve.Init();
            MyBloom.Init();
            MyLuminanceAverage.Init();
            MyToneMapping.Init();
            MySSAO.Init();
            MyPlanetBlur.Init();
            MyHdrDebugTools.Init();

            MySceneMaterials.Init();
            MyMaterials1.Init();
            MyVoxelMaterials1.Init();
            MyMeshMaterials1.Init();
        }
Ejemplo n.º 19
0
        internal static void Run(MyBindableResource destination, MyBindableResource source)
        {
            var context = MyRender11.DeviceContext;

            context.OutputMerger.BlendState = null;

            RC.SetIL(null);
            context.PixelShader.Set(m_ps);

            RC.BindDepthRT(null, DepthStencilAccess.ReadWrite, destination);
            RC.BindSRV(0, source);

            MyScreenPass.DrawFullscreenQuad(new MyViewport(destination.GetSize().X, destination.GetSize().Y));
        }
Ejemplo n.º 20
0
        internal static void ClearAlpha(MyBindableResource destination)
        {
            var context = MyRender11.DeviceContext;

            context.OutputMerger.BlendState = MyRender11.BlendAdditive;

            context.InputAssembler.InputLayout = null;
            context.PixelShader.Set(m_clearAlphaPs);

            RC.BindDepthRT(null, DepthStencilAccess.ReadWrite, destination);

            MyScreenPass.DrawFullscreenQuad(new MyViewport(destination.GetSize().X, destination.GetSize().Y));

            context.OutputMerger.BlendState = null;
        }
Ejemplo n.º 21
0
        static void RenderPointlightsTiled()
        {
            RC.PixelShader.SetConstantBuffer(MyCommon.FRAME_SLOT, MyCommon.FrameConstants);
            RC.PixelShader.SetRawSrv(MyCommon.TILE_LIGHT_INDICES_SLOT, MyScreenDependants.m_tileIndices.m_srv);
            RC.AllShaderStages.SetRawSrv(MyCommon.POINTLIGHT_SLOT, m_pointlightCullHwBuffer.Srv);
            RC.PixelShader.SetSrv(MyCommon.AO_SLOT, MyScreenDependants.m_ambientOcclusion);

            RC.PixelShader.Set(PointlightsTiled_Pixel);
            MyScreenPass.RunFullscreenPixelFreq(MyGBuffer.Main.LBuffer);
            if (MyRender11.MultisamplingEnabled)
            {
                RC.PixelShader.Set(PointlightsTiled_Sample);
                MyScreenPass.RunFullscreenSampleFreq(MyGBuffer.Main.LBuffer);
            }
        }
Ejemplo n.º 22
0
 static void Resolve(bool blur, IRtvBindable dst, MyViewport viewport)
 {
     RC.SetRtv(dst);
     RC.PixelShader.SetSrv(0, m_quarterResAOTextureArray);
     if (blur)
     {
         RC.PixelShader.Set(m_reinterleaveAOPS_PreBlur);
         RC.PixelShader.SetSrv(1, m_fullResViewDepthTarget);
     }
     else
     {
         RC.PixelShader.Set(m_reinterleaveAOPS);
     }
     RC.PixelShader.SetSamplers(0, MySamplerStateManager.PointHBAOClamp);
     MyScreenPass.DrawFullscreenQuad(viewport);
 }
Ejemplo n.º 23
0
        internal static void Combine(RwTexId targetArray, MyShadowCascades firstCascades, MyShadowCascades secondCascades)
        {
            if (!MyRender11.Settings.EnableShadows)
            {
                return;
            }

            ProfilerShort.Begin("MyShadowCascadesPostProcess.Combine");
            MyGpuProfiler.IC_BeginBlock("MyShadowCascadesPostProcess.Combine");

            firstCascades.FillConstantBuffer(firstCascades.CascadeConstantBuffer);
            secondCascades.FillConstantBuffer(secondCascades.CascadeConstantBuffer);
            secondCascades.PostProcessor.MarkCascadesInStencil(secondCascades.CascadeInfo);

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

            deviceContext.PixelShader.SetConstantBuffer(MyCommon.FRAME_SLOT, MyCommon.FrameConstants);
            deviceContext.PixelShader.SetConstantBuffer(10, firstCascades.CascadeConstantBuffer);
            deviceContext.PixelShader.SetConstantBuffer(11, secondCascades.CascadeConstantBuffer);
            deviceContext.PixelShader.SetConstantBuffer(12, m_inverseConstants);

            for (int subresourceIndex = 0; subresourceIndex < targetArray.Description2d.ArraySize; ++subresourceIndex)
            {
                renderContext.BindGBufferForRead(0, MyGBuffer.Main);
                deviceContext.OutputMerger.SetTargets((DepthStencilView)null, (RenderTargetView)targetArray.SubresourceRtv(subresourceIndex));
                deviceContext.PixelShader.SetShaderResource(0, firstCascades.CascadeShadowmapArray.SubresourceSrv(subresourceIndex));
                deviceContext.PixelShader.SetShaderResource(1, secondCascades.CascadeShadowmapArray.ShaderView);
                //deviceContext.PixelShader.SetShaderResource(4, MyGBuffer.Main.DepthStencil.m_SRV_stencil);
                renderContext.SetPS(m_combinePS);

                Matrix inverseCascadeMatrix = MatrixD.Transpose(MatrixD.Invert(firstCascades.CascadeInfo[subresourceIndex].CurrentLocalToProjection * MyMatrixHelpers.ClipspaceToTexture));
                var    mapping = MyMapping.MapDiscard(m_inverseConstants);
                mapping.WriteAndPosition(ref inverseCascadeMatrix);
                mapping.Unmap();

                MyScreenPass.DrawFullscreenQuad(new MyViewport(0, 0, targetArray.Description2d.Width, targetArray.Description2d.Height));
            }

            deviceContext.OutputMerger.SetTargets(null as DepthStencilView, null as RenderTargetView);
            deviceContext.PixelShader.SetShaderResource(0, null);
            deviceContext.PixelShader.SetShaderResource(1, null);
            deviceContext.PixelShader.SetShaderResource(2, null);
            MyGpuProfiler.IC_EndBlock();
            ProfilerShort.End();
        }
Ejemplo n.º 24
0
        static void RenderDirectionalEnvironmentLight()
        {
            MySunlightConstantsLayout constants;

            constants.Direction = MyEnvironment.DirectionalLightDir;
            constants.Color     = MyEnvironment.DirectionalLightIntensity;

            var mapping = MyMapping.MapDiscard(m_sunlightConstants);

            mapping.stream.Write(constants);
            mapping.Unmap();

            //context.VertexShader.Set(MyCommon.FullscreenShader.VertexShader);
            RC.SetPS(DirectionalEnvironmentLight_Pixel);
            RC.SetCB(1, m_sunlightConstants);
            RC.SetCB(4, MyShadows.m_csmConstants);
            RC.Context.PixelShader.SetSamplers(0, MyRender11.StandardSamplers);
            RC.Context.PixelShader.SetSampler(MyCommon.SHADOW_SAMPLER_SLOT, MyRender11.m_shadowmapSamplerState);
            RC.Context.PixelShader.SetShaderResource(MyCommon.CASCADES_SM_SLOT, MyShadows.m_cascadeShadowmapArray.ShaderView);

            var z = Vector4.Transform(new Vector4(0.5f, 0.5f, -MyEnvironment.FarClipping, 1), MyEnvironment.Projection);


            RC.Context.PixelShader.SetShaderResource(MyCommon.SKYBOX_SLOT, MyTextures.GetView(MyTextures.GetTexture(MyEnvironment.DaySkybox, MyTextureEnum.CUBEMAP, true)));
            //RC.Context.PixelShader.SetShaderResource(MyCommon.SKYBOX_IBL_SLOT, MyTextures.GetView(MyTextures.GetTexture(MyEnvironment.DaySkyboxPrefiltered, MyTextureEnum.CUBEMAP, true)));

            RC.Context.PixelShader.SetShaderResource(MyCommon.SKYBOX_IBL_SLOT,
                                                     MyRender11.IsIntelBrokenCubemapsWorkaround ? MyTextures.GetView(MyTextures.IntelFallbackCubeTexId) : MyGeometryRenderer.m_envProbe.cubemapPrefiltered.ShaderView);
            RC.Context.PixelShader.SetShaderResource(MyCommon.SKYBOX2_SLOT, MyTextures.GetView(MyTextures.GetTexture(MyEnvironment.NightSkybox, MyTextureEnum.CUBEMAP, true)));
            RC.Context.PixelShader.SetShaderResource(MyCommon.SKYBOX2_IBL_SLOT, MyTextures.GetView(MyTextures.GetTexture(MyEnvironment.NightSkyboxPrefiltered, MyTextureEnum.CUBEMAP, true)));

            RC.Context.PixelShader.SetShaderResource(MyCommon.SHADOW_SLOT, MyRender11.m_shadowsHelper.ShaderView);

            RC.Context.PixelShader.SetShaderResource(MyCommon.AMBIENT_BRDF_LUT_SLOT,
                                                     MyCommon.GetAmbientBrdfLut());

            RC.BindSRV(MyCommon.AO_SLOT, MyScreenDependants.m_ambientOcclusion);

            MyScreenPass.RunFullscreenPixelFreq(MyGBuffer.Main.Get(MyGbufferSlot.LBuffer));
            if (MyRender11.MultisamplingEnabled)
            {
                RC.SetPS(DirectionalEnvironmentLight_Sample);
                MyScreenPass.RunFullscreenSampleFreq(MyGBuffer.Main.Get(MyGbufferSlot.LBuffer));
            }
        }
Ejemplo n.º 25
0
        internal static void Run(MyBindableResource destination, MyBindableResource source)
        {
            var context = MyRender11.Context;

            context.OutputMerger.BlendState = null;
            //context.Rasterizer.SetViewport(0, 0, MyRender.ViewportResolution.X, MyRender.ViewportResolution.Y);

            context.InputAssembler.InputLayout = null;
            context.PixelShader.Set(m_copyPs);

            //context.OutputMerger.SetTargets(null as DepthStencilView, target);
            //context.PixelShader.SetShaderResource(0, resource);

            RC.BindDepthRT(null, DepthStencilAccess.ReadWrite, destination);
            RC.BindSRV(0, source);

            MyScreenPass.DrawFullscreenQuad(new MyViewport(destination.GetSize().X, destination.GetSize().Y));
        }
Ejemplo n.º 26
0
        internal static unsafe void RunForwardPostprocess(IRtvBindable rt, IDsvBindable depthDsv, ISrvBindable depthSrv,
                                                          ref Matrix viewMatrix, ref Matrix projMatrix)
        {
            MyGpuProfiler.IC_BeginBlock("Postprocess");
            var viewMatrixT = Matrix.Transpose(viewMatrix);
            var projMatrixT = Matrix.Transpose(projMatrix);
            var mapping     = MyMapping.MapDiscard(RC, TransformConstants);

            mapping.WriteAndPosition(ref viewMatrixT);
            mapping.WriteAndPosition(ref projMatrixT);
            mapping.WriteAndPosition(ref MyRender11.Environment.Data.EnvironmentLight.SunLightDirection);
            mapping.Unmap();

            RC.AllShaderStages.SetConstantBuffer(MyCommon.FRAME_SLOT, MyCommon.FrameConstants);
            RC.AllShaderStages.SetConstantBuffer(MyCommon.OBJECT_SLOT, TransformConstants);

            RC.SetDepthStencilState(MyDepthStencilStateManager.IgnoreDepthStencil);
            RC.SetRtv(rt);
            RC.PixelShader.SetSrv(0, depthSrv);
            MyFileTextureManager texManager = MyManagers.FileTextures;

            RC.PixelShader.SetSrv(MyCommon.SKYBOX_SLOT, texManager.GetTexture(MyRender11.Environment.Data.Skybox, MyFileTextureEnum.CUBEMAP, true));
            RC.PixelShader.SetSamplers(0, MySamplerStateManager.StandardSamplers);
            RC.PixelShader.Set(m_ps);

            MyScreenPass.DrawFullscreenQuad(new MyViewport(m_viewportSize, m_viewportSize));
            MyGpuProfiler.IC_EndBlock();

            var nearestAtmosphereId = MyAtmosphereRenderer.GetNearestAtmosphereId();

            if (nearestAtmosphereId != null)
            {
                MyGpuProfiler.IC_BeginBlock("Atmosphere");
                RC.PixelShader.SetSrv(0, depthSrv);
                var viewProj = viewMatrix * projMatrix;
                MyAtmosphereRenderer.RenderEnvProbe(MyRender11.Environment.Matrices.CameraPosition, ref viewProj, nearestAtmosphereId.Value);

                MyGpuProfiler.IC_EndBlock();
            }

            RC.SetRtv(null);
        }
Ejemplo n.º 27
0
        internal unsafe static void RunForwardPostprocess(RenderTargetView rt, ShaderResourceView depth, ref Matrix viewMatrix, uint?atmosphereId)
        {
            var mapping = MyMapping.MapDiscard(RC.Context, MyCommon.ProjectionConstants);

            mapping.stream.Write(Matrix.Transpose(viewMatrix));
            mapping.Unmap();

            RC.SetCB(MyCommon.FRAME_SLOT, MyCommon.FrameConstants);
            RC.SetCB(MyCommon.PROJECTION_SLOT, MyCommon.ProjectionConstants);

            RC.Context.OutputMerger.SetTargets(rt);
            RC.Context.PixelShader.SetShaderResource(0, depth);
            RC.Context.PixelShader.SetShaderResource(MyCommon.SKYBOX_SLOT, MyTextures.GetView(MyTextures.GetTexture(MyEnvironment.DaySkybox, MyTextureEnum.CUBEMAP, true)));
            RC.Context.PixelShader.SetShaderResource(MyCommon.SKYBOX2_SLOT, MyTextures.GetView(MyTextures.GetTexture(MyEnvironment.NightSkybox, MyTextureEnum.CUBEMAP, true)));
            RC.Context.PixelShader.SetSamplers(0, MyRender11.StandardSamplers);
            RC.Context.PixelShader.Set(m_ps);

            MyScreenPass.DrawFullscreenQuad(new MyViewport(256, 256));

            RC.Context.OutputMerger.SetTargets(null as RenderTargetView);
        }
Ejemplo n.º 28
0
        static void DrawDeinterleavedDepth(MyViewport viewport)
        {
            var qViewport = GetQuarterViewport(viewport);

            RC.PixelShader.Set(m_deinterleaveDepthPS);
            RC.PixelShader.SetSrv(0, m_fullResViewDepthTarget);

            var rtvs = new IRtvBindable[MAX_NUM_MRTS];

            for (int sliceIndex = 0; sliceIndex < NUM_SLICES; sliceIndex += MAX_NUM_MRTS)
            {
                for (int i = 0; i < MAX_NUM_MRTS; i++)
                {
                    rtvs[i] = m_quarterResViewDepthTextureArray.SubresourceRtv(sliceIndex + i);
                }
                RC.SetRtvs(rtvs);
                RC.PixelShader.SetConstantBuffer(1, m_perPassCBs[sliceIndex]);

                MyScreenPass.DrawFullscreenQuad(qViewport);
            }
        }
        static void DisplayOverlappingHeatMap(IUavTexture accumTarget, IUavTexture coverageTarget, bool useGrayscale)
        {
            IBorrowedRtvTexture heatMap = MyManagers.RwTexturesPool.BorrowRtv("MyTransparentRendering.HeatMap",
                                                                              Format.R8G8B8A8_UNorm);

            RC.ClearRtv(heatMap, default(RawColor4));

            RC.SetRtv(heatMap);
            RC.PixelShader.SetSrv(0, accumTarget);
            RC.PixelShader.Set(useGrayscale ? m_psOverlappingHeatMapInGrayscale : m_psOverlappingHeatMap);
            RC.SetBlendState(MyBlendStateManager.BlendAdditive);
            RC.SetDepthStencilState(MyDepthStencilStateManager.IgnoreDepthStencil);
            MyScreenPass.DrawFullscreenQuad();

            RC.PixelShader.Set(null);
            RC.PixelShader.SetSrv(0, null);
            RC.SetRtv(null);
            SetupOIT(accumTarget, coverageTarget, false);

            MyDebugTextureDisplay.Select(heatMap);
            heatMap.Release();
        }
Ejemplo n.º 30
0
        static void DrawCoarseAO(MyGBuffer gbuffer, MyViewport viewport)
        {
            var qViewport = GetQuarterViewport(viewport);

            RC.PixelShader.Set(m_coarseAOPS);
            RC.PixelShader.SetSamplers(0, Params.DepthClampToEdge ? MySamplerStateManager.PointHBAOClamp : MySamplerStateManager.PointHBAOBorder);
            RC.PixelShader.SetSamplers(1, MySamplerStateManager.PointHBAOClamp);
            RC.PixelShader.SetSrv(1, gbuffer.GBuffer1);

            for (int sliceIndex = 0; sliceIndex < NUM_SLICES; ++sliceIndex)
            {
                RC.PixelShader.SetSrv(0, m_quarterResViewDepthTextureArray.SubresourceSrv(sliceIndex));

                RC.PixelShader.SetConstantBuffer(1, m_perPassCBs[sliceIndex]);
                RC.GeometryShader.SetConstantBuffer(1, m_perPassCBs[sliceIndex]);

                RC.SetRtv(m_quarterResAOTextureArray.SubresourceRtv(sliceIndex));
                MyScreenPass.DrawFullscreenQuad(qViewport);
            }

            RC.GeometryShader.Set(null);
        }