internal static void PreparePointLights() { var activePointlights = 0; MyLights.Update(); MyLights.PointlightsBvh.OverlapAllFrustum(ref MyEnvironment.ViewFrustumClippedD, VisiblePointlights); bool visiblePointlights = VisiblePointlights.Count != 0; if (!visiblePointlights && !m_lastFrameVisiblePointlights) { return; } m_lastFrameVisiblePointlights = visiblePointlights; if (VisiblePointlights.Count > MyRender11Constants.MAX_POINT_LIGHTS) { VisiblePointlights.Sort((x, y) => x.ViewerDistanceSquared.CompareTo(y.ViewerDistanceSquared)); while (VisiblePointlights.Count > MyRender11Constants.MAX_POINT_LIGHTS) { VisiblePointlights.RemoveAtFast(VisiblePointlights.Count - 1); } } foreach (var light in VisiblePointlights) { MyLights.WritePointlightConstants(light, ref m_pointlightsCullBuffer[activePointlights]); activePointlights++; Debug.Assert(activePointlights <= MyRender11Constants.MAX_POINT_LIGHTS); } for (int lightIndex = activePointlights; lightIndex < MyRender11Constants.MAX_POINT_LIGHTS; ++lightIndex) { MyLights.WritePointlightConstants(LightId.NULL, ref m_pointlightsCullBuffer[lightIndex]); } var mapping = MyMapping.MapDiscard(MyCommon.GetObjectCB(16)); mapping.WriteAndPosition(ref activePointlights); mapping.Unmap(); mapping = MyMapping.MapDiscard(m_pointlightCullHwBuffer.Buffer); mapping.WriteAndPosition(m_pointlightsCullBuffer, 0, MyRender11Constants.MAX_POINT_LIGHTS); mapping.Unmap(); RC.CSSetCB(0, MyCommon.FrameConstants); RC.CSSetCB(1, MyCommon.GetObjectCB(16)); //RC.BindUAV(0, MyScreenDependants.m_test); RC.BindUAV(0, MyScreenDependants.m_tileIndices); RC.BindGBufferForRead(0, MyGBuffer.Main); RC.CSBindRawSRV(MyCommon.POINTLIGHT_SLOT, m_pointlightCullHwBuffer.Srv); RC.SetCS(m_preparePointLights); RC.DeviceContext.Dispatch(MyScreenDependants.TilesX, MyScreenDependants.TilesY, 1); RC.SetCS(null); }
internal static void PreparePointLights() { var activePointlights = 0; MyLights.Update(); MyLights.PointlightsBvh.OverlapAllFrustum(ref MyEnvironment.ViewFrustumClippedD, VisiblePointlights); if (VisiblePointlights.Count > MyRender11Constants.MAX_POINT_LIGHTS) { VisiblePointlights.Sort((x, y) => x.ViewerDistanceSquared.CompareTo(y.ViewerDistanceSquared)); while (VisiblePointlights.Count > MyRender11Constants.MAX_POINT_LIGHTS) { VisiblePointlights.RemoveAtFast(VisiblePointlights.Count - 1); } } foreach (var light in VisiblePointlights) { MyLights.WritePointlightConstants(light, ref m_pointlightsCullBuffer[activePointlights]); activePointlights++; Debug.Assert(activePointlights <= MyRender11Constants.MAX_POINT_LIGHTS); } var mapping = MyMapping.MapDiscard(MyCommon.GetObjectCB(16)); mapping.stream.Write(activePointlights); mapping.stream.Write(0f); mapping.stream.Write(0f); mapping.stream.Write(0f); mapping.Unmap(); mapping = MyMapping.MapDiscard(m_pointlightCullHwBuffer.Buffer); for (int i = 0; i < activePointlights; i++) { mapping.stream.Write(m_pointlightsCullBuffer[i]); } for (int i = activePointlights; i < MyRender11Constants.MAX_POINT_LIGHTS; i++) { mapping.stream.Write(new MyPointlightConstants()); } mapping.Unmap(); RC.CSSetCB(0, MyCommon.FrameConstants); RC.CSSetCB(1, MyCommon.GetObjectCB(16)); //RC.BindUAV(0, MyScreenDependants.m_test); RC.BindUAV(0, MyScreenDependants.m_tileIndexes); RC.BindGBufferForRead(0, MyGBuffer.Main); RC.CSBindRawSRV(MyCommon.POINTLIGHT_SLOT, m_pointlightCullHwBuffer.Srv); RC.SetCS(m_preparePointLights); var size = MyRender11.ViewportResolution; RC.Context.Dispatch((size.X + TILE_SIZE - 1) / TILE_SIZE, (size.Y + TILE_SIZE - 1) / TILE_SIZE, 1); RC.SetCS(null); }
private void PrepareSpotlights() { MyLights.Update(); MyLights.SpotlightsBvh.OverlapAllFrustum(ref MyRender11.Environment.ViewFrustumClippedD, MyLightRendering.VisibleSpotlights); if (MyLightRendering.VisibleSpotlights.Count == 0) { OtherShadowsTriangleCounter = 0; } MyLightRendering.VisibleSpotlights.Sort(m_spotlightCastersComparer); int index = 0; int casterIndex = 0; var worldMatrix = MatrixD.CreateTranslation(MyRender11.Environment.CameraPosition); foreach (var id in MyLightRendering.VisibleSpotlights) { if (id.CastsShadows && casterIndex < MAX_SPOTLIGHT_SHADOWCASTERS) { if (ShadowmapsPool.Count <= casterIndex) { ShadowmapsPool.Add(MyRwTextures.CreateShadowmap(SpotlightShadowmapSize, SpotlightShadowmapSize)); } MyLights.Lights.Data[id.Index].CastsShadowsThisFrame = true; MatrixD viewProjection = MyLights.GetSpotlightViewProjection(id); var query = new MyShadowmapQuery { DepthBuffer = ShadowmapsPool[casterIndex].Dsv, Viewport = new MyViewport(SpotlightShadowmapSize, SpotlightShadowmapSize), QueryType = MyFrustumEnum.ShadowProjection, ProjectionInfo = new MyProjectionInfo { WorldCameraOffsetPosition = MyRender11.Environment.CameraPosition, WorldToProjection = viewProjection, LocalToProjection = worldMatrix * viewProjection }, IgnoredEntities = MyLights.IgnoredEntitites.ContainsKey(id) ? MyLights.IgnoredEntitites[id] : null, }; m_shadowmapQueries.Add(query); ++casterIndex; } else { MyLights.Lights.Data[id.Index].CastsShadowsThisFrame = false; } index++; } }
internal static void PreparePointLights() { var activePointlights = 0; MyLights.Update(); BoundingFrustumD viewFrustumClippedD = MyRender11.Environment.Matrices.ViewFrustumClippedD; if (MyStereoRender.Enable) { if (MyStereoRender.RenderRegion == MyStereoRegion.LEFT) { viewFrustumClippedD = MyStereoRender.EnvMatricesLeftEye.ViewFrustumClippedD; } else if (MyStereoRender.RenderRegion == MyStereoRegion.RIGHT) { viewFrustumClippedD = MyStereoRender.EnvMatricesRightEye.ViewFrustumClippedD; } } MyLights.PointlightsBvh.OverlapAllFrustum(ref viewFrustumClippedD, VisiblePointlights); bool visiblePointlights = VisiblePointlights.Count != 0; if (!visiblePointlights && !m_lastFrameVisiblePointlights) { return; } m_lastFrameVisiblePointlights = visiblePointlights; if (VisiblePointlights.Count > MyRender11Constants.MAX_POINT_LIGHTS) { VisiblePointlights.Sort((x, y) => x.ViewerDistanceSquared.CompareTo(y.ViewerDistanceSquared)); while (VisiblePointlights.Count > MyRender11Constants.MAX_POINT_LIGHTS) { VisiblePointlights.RemoveAtFast(VisiblePointlights.Count - 1); } } foreach (var light in VisiblePointlights) { MyLights.WritePointlightConstants(light, ref m_pointlightsCullBuffer[activePointlights]); activePointlights++; Debug.Assert(activePointlights <= MyRender11Constants.MAX_POINT_LIGHTS); } for (int lightIndex = activePointlights; lightIndex < MyRender11Constants.MAX_POINT_LIGHTS; ++lightIndex) { MyLights.WritePointlightConstants(LightId.NULL, ref m_pointlightsCullBuffer[lightIndex]); } var mapping = MyMapping.MapDiscard(MyCommon.GetObjectCB(16)); mapping.WriteAndPosition(ref activePointlights); mapping.Unmap(); mapping = MyMapping.MapDiscard(m_pointlightCullHwBuffer.Buffer); mapping.WriteAndPosition(m_pointlightsCullBuffer, 0, MyRender11Constants.MAX_POINT_LIGHTS); mapping.Unmap(); if (!MyStereoRender.Enable) { RC.ComputeShader.SetConstantBuffer(MyCommon.FRAME_SLOT, MyCommon.FrameConstants); } else { MyStereoRender.CSBindRawCB_FrameConstants(RC); } RC.ComputeShader.SetConstantBuffer(1, MyCommon.GetObjectCB(16)); //RC.BindUAV(0, MyScreenDependants.m_test); RC.ComputeShader.SetRawUav(0, MyScreenDependants.m_tileIndices.m_uav); RC.ComputeShader.SetSrvs(0, MyGBuffer.Main); RC.ComputeShader.SetRawSrv(MyCommon.POINTLIGHT_SLOT, m_pointlightCullHwBuffer.Srv); RC.ComputeShader.Set(m_preparePointLights); Vector2I tiles = new Vector2I(MyScreenDependants.TilesX, MyScreenDependants.TilesY); if (MyStereoRender.Enable && MyStereoRender.RenderRegion != MyStereoRegion.FULLSCREEN) { tiles.X /= 2; } RC.Dispatch(tiles.X, tiles.Y, 1); RC.ComputeShader.Set(null); RC.ComputeShader.SetRawUav(0, null); RC.ComputeShader.ResetSrvs(0, MyGBufferSrvFilter.ALL); }
internal static void Render(ISrvTexture postProcessedShadows) { MyLights.Update(); MyGpuProfiler.IC_BeginBlock("Map lights to tiles"); if (MyRender11.DebugOverrides.PointLights) { PreparePointLights(); } MyGpuProfiler.IC_BeginNextBlock("Apply point lights"); RC.SetPrimitiveTopology(PrimitiveTopology.TriangleList); if (!MyStereoRender.Enable) { RC.ComputeShader.SetConstantBuffer(MyCommon.FRAME_SLOT, MyCommon.FrameConstants); RC.PixelShader.SetConstantBuffer(MyCommon.FRAME_SLOT, MyCommon.FrameConstants); } else { MyStereoRender.CSBindRawCB_FrameConstants(RC); MyStereoRender.PSBindRawCB_FrameConstants(RC); } RC.PixelShader.SetSrvs(0, MyGBuffer.Main); RC.AllShaderStages.SetRawSrv(MyCommon.MATERIAL_BUFFER_SLOT, MySceneMaterials.m_buffer.Srv); RC.SetBlendState(MyBlendStateManager.BlendAdditive); if (!MyStereoRender.Enable) { RC.SetDepthStencilState(MyDepthStencilStateManager.IgnoreDepthStencil); } else { RC.SetDepthStencilState(MyDepthStencilStateManager.StereoIgnoreDepthStencil); } RC.PixelShader.SetSamplers(0, MySamplerStateManager.StandardSamplers); if (MyRender11.DebugOverrides.PointLights) { RenderPointlightsTiled(); } MyGpuProfiler.IC_BeginNextBlock("Apply spotlights"); if (MyRender11.DebugOverrides.SpotLights) { RenderSpotlights(); } MyGpuProfiler.IC_BeginNextBlock("Apply directional light"); if (MyRender11.DebugOverrides.EnvLight) { RenderDirectionalEnvironmentLight(postProcessedShadows); } MyGpuProfiler.IC_EndBlock(); // Because of BindGBufferForRead: RC.AllShaderStages.SetSrv(0, null); RC.AllShaderStages.SetSrv(1, null); RC.AllShaderStages.SetSrv(2, null); RC.AllShaderStages.SetSrv(3, null); RC.AllShaderStages.SetSrv(4, null); RC.SetBlendState(null); RC.SetRtv(null); }
// Returns the final image and copies it to renderTarget if non-null private static IRtvTexture DrawGameScene(IRtvBindable renderTarget, out IBorrowedRtvTexture debugAmbientOcclusion) { MyGpuProfiler.IC_BeginBlockAlways("ClearAndGeometryRender"); PrepareGameScene(); // todo: shouldn't be necessary if (true) { ProfilerShort.Begin("Clear"); MyRender11.RC.ClearState(); ProfilerShort.End(); } if (MyStereoRender.Enable && MyStereoRender.EnableUsingStencilMask) { ProfilerShort.Begin("MyStereoStencilMask.Draw"); MyGpuProfiler.IC_BeginBlock("MyStereoStencilMask.Draw"); MyStereoStencilMask.Draw(); MyGpuProfiler.IC_EndBlock(); ProfilerShort.End(); } ProfilerShort.Begin("MyLights.Update"); MyLights.Update(); ProfilerShort.End(); ProfilerShort.Begin("DynamicGeometryRenderer"); MyCullQuery cullQuery = m_dynamicGeometryRenderer.PrepareCullQuery(true); // it is used to share rendering settings between the old and the new pipeline ProfilerShort.End(); MyGpuProfiler.IC_BeginBlock("NewGeometryRenderer"); ProfilerShort.Begin("NewGeometryRenderer"); IGeometrySrvStrategy geometrySrvStrategy = MyManagers.GeometrySrvResolver.GetGeometrySrvStrategy(); if (MyDebugGeometryStage2.EnableNewGeometryPipeline) { MyManagers.GeometryRenderer.Render(cullQuery, geometrySrvStrategy); } ProfilerShort.End(); MyGpuProfiler.IC_EndBlock(); MyGpuProfiler.IC_BeginBlock("MyGeometryRenderer.Render"); Debug.Assert(m_commandLists.Count == 0, "Not all command lists executed last frame!"); ProfilerShort.Begin("DynamicGeometryRenderer"); m_dynamicGeometryRenderer.Render(m_commandLists); ProfilerShort.End(); // End function block if (MyScene.SeparateGeometry) { ProfilerShort.Begin("StaticGeometryRenderer"); m_staticGeometryRenderer.Render(m_commandLists); // , false); ProfilerShort.End(); // End function block } SendGlobalOutputMessages(); ExecuteCommandLists(m_commandLists); MyGpuProfiler.IC_EndBlock(); #if !UNSHARPER_TMP MyManagers.EnvironmentProbe.FinalizeEnvProbes(); #endif // cleanup context atfer deferred lists if (true) { ProfilerShort.Begin("Clear3"); MyRender11.RC.ClearState(); ProfilerShort.End(); } MyGpuProfiler.IC_EndBlockAlways(); IBorrowedRtvTexture gbuffer1Copy = MyGBuffer.Main.GetGbuffer1CopyRtv(); ProfilerShort.Begin("Render decals - Opaque"); MyGpuProfiler.IC_BeginBlock("Render decals - Opaque"); MyScreenDecals.Draw(gbuffer1Copy, false); MyGpuProfiler.IC_EndBlock(); IBorrowedDepthStencilTexture depthStencilCopy = null; // Highlights need the depth state before foliage if (MyHighlight.HasHighlights) { depthStencilCopy = MyGBuffer.Main.GetDepthStencilCopyRtv(); } ProfilerShort.BeginNextBlock("Render foliage"); MyGpuProfiler.IC_BeginBlockAlways("RenderFoliage"); m_foliageRenderer.Render(); MyGpuProfiler.IC_EndBlockAlways(); MyGpuProfiler.IC_BeginBlock("GBuffer Resolve"); ProfilerShort.BeginNextBlock("MySceneMaterials.MoveToGPU"); MySceneMaterials.MoveToGPU(); MyRender11.RC.ResetTargets(); IBorrowedRtvTexture ambientOcclusionRtv = MyManagers.RwTexturesPool.BorrowRtv("MyScreenDependants.AmbientOcclusion", ResolutionI.X, ResolutionI.Y, SharpDX.DXGI.Format.R8_UNorm); debugAmbientOcclusion = ambientOcclusionRtv; // Pass the texture to the outside int nPasses = MyStereoRender.Enable ? 2 : 1; for (int i = 0; i < nPasses; i++) { if (MyStereoRender.Enable) { MyStereoRender.RenderRegion = i == 0 ? MyStereoRegion.LEFT : MyStereoRegion.RIGHT; } MyGBuffer.Main.ResolveMultisample(); ProfilerShort.BeginNextBlock("Shadows"); MyGpuProfiler.IC_BeginBlockAlways("Shadows"); IBorrowedUavTexture postProcessedShadows; if (MyScene.SeparateGeometry) { MyShadowCascadesPostProcess.Combine(MyShadowCascades.CombineShadowmapArray, DynamicShadows.ShadowCascades, StaticShadows.ShadowCascades); postProcessedShadows = DynamicShadows.ShadowCascades.PostProcess(MyShadowCascades.CombineShadowmapArray); //MyShadowCascadesPostProcess.Combine(MyShadowCascades.CombineShadowmapArray, // DynamicShadows.ShadowCascades, StaticShadows.ShadowCascades); //postProcessedShadows = // DynamicShadows.ShadowCascades.PostProcess(MyShadowCascades.CombineShadowmapArray); } else { postProcessedShadows = DynamicShadows.ShadowCascades.PostProcess(DynamicShadows.ShadowCascades.CascadeShadowmapArray); //postProcessedShadows = MyManagers.Shadow.Evaluate(); } MyGpuProfiler.IC_EndBlockAlways(); if (MySSAO.Params.Enabled && Settings.User.AmbientOcclusionEnabled && m_debugOverrides.Postprocessing && m_debugOverrides.SSAO) { ProfilerShort.BeginNextBlock("SSAO"); MyGpuProfiler.IC_BeginBlockAlways("SSAO"); MySSAO.Run(ambientOcclusionRtv, MyGBuffer.Main); if (MySSAO.Params.UseBlur) { IBorrowedRtvTexture ambientOcclusionHelper = MyManagers.RwTexturesPool.BorrowRtv("MyScreenDependants.AmbientOcclusionHelper", ResolutionI.X, ResolutionI.Y, SharpDX.DXGI.Format.R8_UNorm); MyBlur.Run(ambientOcclusionRtv, ambientOcclusionHelper, ambientOcclusionRtv, clearColor: Color4.White); ambientOcclusionHelper.Release(); } MyGpuProfiler.IC_EndBlockAlways(); } else if (MyHBAO.Params.Enabled && Settings.User.AmbientOcclusionEnabled && m_debugOverrides.Postprocessing && m_debugOverrides.SSAO) { ProfilerShort.BeginNextBlock("HBAO"); MyGpuProfiler.IC_BeginBlock("HBAO"); MyHBAO.Run(ambientOcclusionRtv, MyGBuffer.Main); MyGpuProfiler.IC_EndBlock(); } else { MyRender11.RC.ClearRtv(ambientOcclusionRtv, Color4.White); } ProfilerShort.BeginNextBlock("Lights"); MyGpuProfiler.IC_BeginBlockAlways("Lights"); if (m_debugOverrides.Lighting) { MyLightsRendering.Render(postProcessedShadows, ambientOcclusionRtv); } MyGpuProfiler.IC_EndBlockAlways(); postProcessedShadows.Release(); if (MyRender11.DebugOverrides.Flares) { MyLightsRendering.DrawFlares(); } } MyStereoRender.RenderRegion = MyStereoRegion.FULLSCREEN; MyGpuProfiler.IC_EndBlock(); ProfilerShort.BeginNextBlock("Occlusion Queries"); MyGpuProfiler.IC_BeginBlock("Occlusion Queries"); MyOcclusionQueryRenderer.Render(RC, MyGBuffer.Main.ResolvedDepthStencil, MyGBuffer.Main.LBuffer); MyGpuProfiler.IC_EndBlock(); // Rendering for VR is solved inside of Transparent rendering ProfilerShort.BeginNextBlock("Transparent Pass"); MyGpuProfiler.IC_BeginBlockAlways("TransparentPass"); if (m_debugOverrides.Transparent) { MyTransparentRendering.Render(gbuffer1Copy); } MyGpuProfiler.IC_EndBlockAlways(); gbuffer1Copy.Release(); ProfilerShort.BeginNextBlock("PostProcess"); MyGpuProfiler.IC_BeginBlockAlways("PostProcess"); MyGpuProfiler.IC_BeginBlock("Luminance reduction"); IBorrowedUavTexture avgLum = null; if (MyRender11.Postprocess.EnableEyeAdaptation) { if (m_resetEyeAdaptation) { MyLuminanceAverage.Reset(); m_resetEyeAdaptation = false; } avgLum = MyLuminanceAverage.Run(MyGBuffer.Main.LBuffer); } else { avgLum = MyLuminanceAverage.Skip(); } MyGpuProfiler.IC_EndBlock(); IBorrowedUavTexture histogram = null; if (MyRender11.Settings.DisplayHistogram) { histogram = MyHdrDebugTools.CreateHistogram(MyGBuffer.Main.LBuffer, MyGBuffer.Main.SamplesCount); } if (MyRender11.Settings.DisplayHdrIntensity) { MyHdrDebugTools.DisplayHdrIntensity(MyGBuffer.Main.LBuffer); } MyGpuProfiler.IC_BeginBlock("Bloom"); IBorrowedUavTexture bloom; if (m_debugOverrides.Postprocessing && m_debugOverrides.Bloom) { bloom = MyBloom.Run(MyGBuffer.Main.LBuffer, MyGBuffer.Main.GBuffer2, MyGBuffer.Main.ResolvedDepthStencil.SrvDepth); } else { bloom = MyManagers.RwTexturesPool.BorrowUav("bloom_EightScreenUavHDR", MyRender11.ResolutionI.X / 8, MyRender11.ResolutionI.Y / 8, MyGBuffer.LBufferFormat); MyRender11.RC.ClearRtv(bloom, Color4.Black); } MyGpuProfiler.IC_EndBlock(); MyGpuProfiler.IC_BeginBlock("Tone mapping"); IBorrowedUavTexture tonemapped = MyToneMapping.Run(MyGBuffer.Main.LBuffer, avgLum, bloom, Postprocess.EnableTonemapping && m_debugOverrides.Postprocessing && m_debugOverrides.Tonemapping); bloom.Release(); MyGpuProfiler.IC_EndBlock(); IRtvTexture renderedImage; IBorrowedCustomTexture fxaaTarget = null; bool fxaa = MyRender11.FxaaEnabled; if (fxaa) { fxaaTarget = MyManagers.RwTexturesPool.BorrowCustom("MyRender11.FXAA.Rgb8"); MyGpuProfiler.IC_BeginBlock("FXAA"); MyFXAA.Run(fxaaTarget.Linear, tonemapped); MyGpuProfiler.IC_EndBlock(); renderedImage = fxaaTarget.SRgb; } else { renderedImage = tonemapped; } ProfilerShort.Begin("MyHighlight.Run"); MyHighlight.Run(renderedImage, fxaaTarget, depthStencilCopy); ProfilerShort.End(); if (depthStencilCopy != null) { depthStencilCopy.Release(); } if (renderTarget != null) { MyCopyToRT.Run(renderTarget, renderedImage); } if (MyRender11.Settings.DisplayHistogram) { if (renderTarget != null && avgLum != null) { MyHdrDebugTools.DisplayHistogram(renderTarget, avgLum, histogram); } } MyGpuProfiler.IC_EndBlockAlways(); ProfilerShort.End(); if (fxaaTarget != null) { fxaaTarget.Release(); } if (histogram != null) { histogram.Release(); } avgLum.Release(); tonemapped.Release(); // HOTFIX: MyDebugTextureDisplay uses borrowed textures. If we place MyDebugTextureDisplay to the different location, we will have problem with borrowed textures (comment by Michal) ProfilerShort.Begin("MyDebugTextureDisplay.Draw"); MyGpuProfiler.IC_BeginBlock("MyDebugTextureDisplay.Draw"); MyDebugTextureDisplay.Draw(MyRender11.Backbuffer); MyGpuProfiler.IC_EndBlock(); ProfilerShort.End(); return(renderedImage); }
internal static void Render() { MyLights.Update(); MyGpuProfiler.IC_BeginBlock("Map lights to tiles"); if (MyRender11.DebugOverrides.PointLights) { PreparePointLights(); } MyGpuProfiler.IC_EndBlock(); RC.DeviceContext.InputAssembler.PrimitiveTopology = PrimitiveTopology.TriangleList; if (!MyStereoRender.Enable) { RC.CSSetCB(MyCommon.FRAME_SLOT, MyCommon.FrameConstants); } else { MyStereoRender.CSBindRawCB_FrameConstants(RC); } RC.BindGBufferForRead(0, MyGBuffer.Main); RC.BindRawSRV(MyCommon.MATERIAL_BUFFER_SLOT, MySceneMaterials.m_buffer); RC.SetBS(MyRender11.BlendAdditive); if (!MyStereoRender.Enable) { RC.SetDS(MyDepthStencilState.IgnoreDepthStencil); } else { RC.SetDS(MyDepthStencilState.StereoIgnoreDepthStencil); } RC.DeviceContext.PixelShader.SetSamplers(0, SamplerStates.StandardSamplers); MyGpuProfiler.IC_BeginBlock("Apply point lights"); if (MyRender11.DebugOverrides.PointLights) { RenderPointlightsTiled(); } MyGpuProfiler.IC_EndBlock(); MyGpuProfiler.IC_BeginBlock("Apply spotlights"); if (MyRender11.DebugOverrides.SpotLights) { RenderSpotlights(); } MyGpuProfiler.IC_EndBlock(); MyGpuProfiler.IC_BeginBlock("Apply directional light"); if (MyRender11.DebugOverrides.EnvLight) { RenderDirectionalEnvironmentLight(); } MyGpuProfiler.IC_EndBlock(); // Because of BindGBufferForRead: RC.BindRawSRV(0, null); RC.BindRawSRV(1, null); RC.BindRawSRV(2, null); RC.BindRawSRV(3, null); RC.BindRawSRV(4, null); RC.CSBindRawSRV(0, null); RC.CSBindRawSRV(1, null); RC.CSBindRawSRV(2, null); RC.CSBindRawSRV(3, null); RC.CSBindRawSRV(4, null); RC.SetBS(null); }