internal static void RenderPostProcesses(PostProcessStage postProcessStage, Texture source, Texture[] target, Texture availableRT, bool copyToTarget = true, bool scaleToTarget = false) { Texture lastSurface = source; GetRenderProfiler().StartProfilingBlock("Render Post process: " + postProcessStage.ToString()); { if (Settings.EnableLightsRuntime) { (MyRender.GetEffect(MyEffects.BlendLights) as MyEffectBlendLights).DefaultTechnique = MyEffectBlendLights.Technique.LightsEnabled; (MyRender.GetEffect(MyEffects.BlendLights) as MyEffectBlendLights).CopyEmissivityTechnique = MyEffectBlendLights.Technique.CopyEmissivity; MyEffectDirectionalLight directionalLight = MyRender.GetEffect(MyEffects.DirectionalLight) as MyEffectDirectionalLight; directionalLight.DefaultTechnique = MyEffectDirectionalLight.Technique.Default; directionalLight.DefaultWithoutShadowsTechnique = MyEffectDirectionalLight.Technique.WithoutShadows; directionalLight.DefaultNoLightingTechnique = MyEffectDirectionalLight.Technique.NoLighting; MyEffectPointLight pointLight = MyRender.GetEffect(MyEffects.PointLight) as MyEffectPointLight; pointLight.PointTechnique = MyEffectPointLight.MyEffectPointLightTechnique.Point; pointLight.PointWithShadowsTechnique = MyEffectPointLight.MyEffectPointLightTechnique.PointShadows; pointLight.HemisphereTechnique = MyEffectPointLight.MyEffectPointLightTechnique.Point; pointLight.SpotTechnique = MyEffectPointLight.MyEffectPointLightTechnique.Spot; pointLight.SpotShadowTechnique = MyEffectPointLight.MyEffectPointLightTechnique.SpotShadows; } } foreach (MyPostProcessBase postProcess in m_postProcesses) { if (postProcess.Enabled && (MyRender.CurrentRenderSetup.EnabledPostprocesses == null || MyRender.CurrentRenderSetup.EnabledPostprocesses.Contains(postProcess.Name))) { var currSurface = postProcess.Render(postProcessStage, lastSurface, availableRT); // Effect used availableRT as target, so lastSurface is available now if (currSurface != lastSurface && lastSurface != null) { availableRT = lastSurface; } lastSurface = currSurface; } } GetRenderProfiler().EndProfilingBlock(); if (lastSurface != null && copyToTarget) { MyRender.SetRenderTargets(target, null); if (scaleToTarget) SetCorrectViewportSize(); BlendState.Opaque.Apply(); Blit(lastSurface, scaleToTarget); } }