diff --git a/OpenRA.Game/Graphics/WorldRenderer.cs b/OpenRA.Game/Graphics/WorldRenderer.cs index 9539537ca7..2f5d84dbfe 100644 --- a/OpenRA.Game/Graphics/WorldRenderer.cs +++ b/OpenRA.Game/Graphics/WorldRenderer.cs @@ -380,6 +380,8 @@ namespace OpenRA.Graphics } } + ApplyPostProcessing(PostProcessPassType.AfterAnnotations); + Game.Renderer.Flush(); preparedRenderables.Clear(); diff --git a/OpenRA.Game/Renderer.cs b/OpenRA.Game/Renderer.cs index f12312e11e..bf8ae4d408 100644 --- a/OpenRA.Game/Renderer.cs +++ b/OpenRA.Game/Renderer.cs @@ -46,7 +46,7 @@ namespace OpenRA readonly IVertexBuffer tempVertexBuffer; readonly IIndexBuffer quadIndexBuffer; readonly Stack scissorState = []; - readonly ITexture worldBufferSnapshot; + readonly ITexture bufferSnapshot; IFrameBuffer screenBuffer; Sprite screenSprite; @@ -61,12 +61,13 @@ namespace OpenRA public int WorldDownscaleFactor { get; private set; } = 1; /// - /// Copies and returns the currently rendered world state as a temporary texture. + /// Copies and returns the currently rendered state as a temporary texture. /// - public ITexture WorldBufferSnapshot() + public ITexture GetRenderBufferSnapshot() { - worldBufferSnapshot.SetDataFromReadBuffer(new Rectangle(int2.Zero, worldSheet.Size)); - return worldBufferSnapshot; + var size = renderType == RenderType.World ? worldSheet.Size : Window.SurfaceSize.NextPowerOf2(); + bufferSnapshot.SetDataFromReadBuffer(new Rectangle(int2.Zero, size)); + return bufferSnapshot; } SheetBuilder fontSheetBuilder; @@ -107,7 +108,7 @@ namespace OpenRA tempVertexBuffer = Context.CreateEmptyVertexBuffer(TempVertexBufferSize); quadIndexBuffer = Context.CreateIndexBuffer(Util.CreateQuadIndices(TempIndexBufferSize / 6)); - worldBufferSnapshot = Context.CreateTexture(); + bufferSnapshot = Context.CreateTexture(); } static Size GetResolution(GraphicSettings graphicsSettings) @@ -543,7 +544,7 @@ namespace OpenRA { worldBuffer?.Dispose(); screenBuffer.Dispose(); - worldBufferSnapshot.Dispose(); + bufferSnapshot.Dispose(); tempVertexBuffer.Dispose(); quadIndexBuffer.Dispose(); fontSheetBuilder?.Dispose(); diff --git a/OpenRA.Game/Traits/TraitsInterfaces.cs b/OpenRA.Game/Traits/TraitsInterfaces.cs index bc5d29602e..47d6da7667 100644 --- a/OpenRA.Game/Traits/TraitsInterfaces.cs +++ b/OpenRA.Game/Traits/TraitsInterfaces.cs @@ -464,7 +464,7 @@ namespace OpenRA.Traits bool SpatiallyPartitionable { get; } } - public enum PostProcessPassType { AfterShroud, AfterWorld, AfterActors } + public enum PostProcessPassType { AfterShroud, AfterWorld, AfterActors, AfterAnnotations } [RequireExplicitImplementation] public interface IRenderPostProcessPass diff --git a/OpenRA.Mods.Cnc/Traits/World/ChronoVortexRenderer.cs b/OpenRA.Mods.Cnc/Traits/World/ChronoVortexRenderer.cs index c6ae904301..5c3e52394b 100644 --- a/OpenRA.Mods.Cnc/Traits/World/ChronoVortexRenderer.cs +++ b/OpenRA.Mods.Cnc/Traits/World/ChronoVortexRenderer.cs @@ -93,7 +93,7 @@ namespace OpenRA.Mods.Cnc.Traits shader.SetVec("Scroll", scroll.X, scroll.Y); shader.SetVec("p1", width, height); shader.SetVec("p2", -1, -1); - shader.SetTexture("WorldTexture", Game.Renderer.WorldBufferSnapshot()); + shader.SetTexture("SourceTexture", Game.Renderer.GetRenderBufferSnapshot()); shader.SetTexture("VortexTexture", vortexSheet.GetTexture()); shader.PrepareRender(); foreach (var (pos, frame) in vortices) diff --git a/OpenRA.Mods.Common/Traits/PaletteEffects/MenuPostProcessEffect.cs b/OpenRA.Mods.Common/Traits/PaletteEffects/MenuPostProcessEffect.cs index e3f524fda6..6a42dc7bd2 100644 --- a/OpenRA.Mods.Common/Traits/PaletteEffects/MenuPostProcessEffect.cs +++ b/OpenRA.Mods.Common/Traits/PaletteEffects/MenuPostProcessEffect.cs @@ -51,7 +51,7 @@ namespace OpenRA.Mods.Common.Traits long endTime; public MenuPostProcessEffect(MenuPostProcessEffectInfo info) - : base("menufade", PostProcessPassType.AfterShroud) + : base("menufade", PostProcessPassType.AfterAnnotations) { Info = info; to = info.GameStartEffect; diff --git a/OpenRA.Mods.Common/Traits/World/RenderPostProcessPassBase.cs b/OpenRA.Mods.Common/Traits/World/RenderPostProcessPassBase.cs index d66ebae669..29b6fb545d 100644 --- a/OpenRA.Mods.Common/Traits/World/RenderPostProcessPassBase.cs +++ b/OpenRA.Mods.Common/Traits/World/RenderPostProcessPassBase.cs @@ -43,7 +43,7 @@ namespace OpenRA.Mods.Common.Traits bool IRenderPostProcessPass.Enabled => Enabled; void IRenderPostProcessPass.Draw(WorldRenderer wr) { - shader.SetTexture("WorldTexture", Game.Renderer.WorldBufferSnapshot()); + shader.SetTexture("SourceTexture", Game.Renderer.GetRenderBufferSnapshot()); PrepareRender(wr, shader); shader.PrepareRender(); renderer.DrawBatch(buffer, shader, 0, 6, PrimitiveType.TriangleList); diff --git a/OpenRA.Mods.D2k/Traits/World/SonicBlastRenderer.cs b/OpenRA.Mods.D2k/Traits/World/SonicBlastRenderer.cs index 4189b61a37..9ef338eab2 100644 --- a/OpenRA.Mods.D2k/Traits/World/SonicBlastRenderer.cs +++ b/OpenRA.Mods.D2k/Traits/World/SonicBlastRenderer.cs @@ -76,7 +76,7 @@ namespace OpenRA.Mods.D2k.Traits shader.SetVec("Scroll", scroll.X, scroll.Y); shader.SetVec("p1", width, height); shader.SetVec("p2", -1, -1); - shader.SetTexture("WorldTexture", Game.Renderer.WorldBufferSnapshot()); + shader.SetTexture("SourceTexture", Game.Renderer.GetRenderBufferSnapshot()); shader.PrepareRender(); foreach (var pos in positions) { diff --git a/glsl/postprocess_chronoshift.frag b/glsl/postprocess_chronoshift.frag index 87f4f6b340..9f76ac9647 100644 --- a/glsl/postprocess_chronoshift.frag +++ b/glsl/postprocess_chronoshift.frag @@ -4,12 +4,12 @@ precision mediump float; #endif uniform float Blend; -uniform sampler2D WorldTexture; +uniform sampler2D SourceTexture; out vec4 fragColor; void main() { - vec4 c = texelFetch(WorldTexture, ivec2(gl_FragCoord.xy), 0); + vec4 c = texelFetch(SourceTexture, ivec2(gl_FragCoord.xy), 0); float lum = 0.5 * (min(c.r, min(c.g, c.b)) + max(c.r, max(c.g, c.b))); fragColor = mix(c, vec4(lum, lum, lum, c.a), Blend); } diff --git a/glsl/postprocess_flash.frag b/glsl/postprocess_flash.frag index 4178a905c5..fdc069703f 100644 --- a/glsl/postprocess_flash.frag +++ b/glsl/postprocess_flash.frag @@ -5,11 +5,11 @@ precision mediump float; uniform float Blend; uniform vec3 Color; -uniform sampler2D WorldTexture; +uniform sampler2D SourceTexture; out vec4 fragColor; void main() { - vec4 c = texelFetch(WorldTexture, ivec2(gl_FragCoord.xy), 0); + vec4 c = texelFetch(SourceTexture, ivec2(gl_FragCoord.xy), 0); fragColor = mix(c, vec4(Color, c.a), Blend); } diff --git a/glsl/postprocess_menufade.frag b/glsl/postprocess_menufade.frag index 7edaeb7ee3..16eb0b8b48 100644 --- a/glsl/postprocess_menufade.frag +++ b/glsl/postprocess_menufade.frag @@ -6,7 +6,7 @@ precision mediump float; uniform float From; uniform float To; uniform float Blend; -uniform sampler2D WorldTexture; +uniform sampler2D SourceTexture; out vec4 fragColor; vec4 ColorForEffect(float effect, vec4 c) @@ -27,6 +27,6 @@ vec4 ColorForEffect(float effect, vec4 c) void main() { - vec4 c = texelFetch(WorldTexture, ivec2(gl_FragCoord.xy), 0); + vec4 c = texelFetch(SourceTexture, ivec2(gl_FragCoord.xy), 0); fragColor = mix(ColorForEffect(To, c), ColorForEffect(From, c), Blend); } diff --git a/glsl/postprocess_textured_sonic.frag b/glsl/postprocess_textured_sonic.frag index 2c553d34e4..1bc6c7e730 100644 --- a/glsl/postprocess_textured_sonic.frag +++ b/glsl/postprocess_textured_sonic.frag @@ -3,7 +3,7 @@ precision mediump float; #endif -uniform sampler2D WorldTexture; +uniform sampler2D SourceTexture; uniform float Scale; in vec2 vTexCoord; @@ -14,5 +14,5 @@ void main() if (dot(vTexCoord, vTexCoord) >= 1.0) discard; - fragColor = texelFetch(WorldTexture, ivec2(gl_FragCoord.xy + Scale * vTexCoord), 0); + fragColor = texelFetch(SourceTexture, ivec2(gl_FragCoord.xy + Scale * vTexCoord), 0); } diff --git a/glsl/postprocess_textured_vortex.frag b/glsl/postprocess_textured_vortex.frag index c5b191faf8..569e87ca7d 100644 --- a/glsl/postprocess_textured_vortex.frag +++ b/glsl/postprocess_textured_vortex.frag @@ -4,7 +4,7 @@ precision mediump float; #endif uniform sampler2D VortexTexture; -uniform sampler2D WorldTexture; +uniform sampler2D SourceTexture; in vec2 vTexCoord; out vec4 fragColor; @@ -18,5 +18,5 @@ void main() if (vtx.r > 0.055) discard; - fragColor = texelFetch(WorldTexture, ivec2(gl_FragCoord.xy + delta), 0) * vec4(frac, frac, frac, 1); + fragColor = texelFetch(SourceTexture, ivec2(gl_FragCoord.xy + delta), 0) * vec4(frac, frac, frac, 1); } diff --git a/glsl/postprocess_tint.frag b/glsl/postprocess_tint.frag index 43b05780d1..3a4891d912 100644 --- a/glsl/postprocess_tint.frag +++ b/glsl/postprocess_tint.frag @@ -4,11 +4,11 @@ precision mediump float; #endif uniform vec3 Tint; -uniform sampler2D WorldTexture; +uniform sampler2D SourceTexture; out vec4 fragColor; void main() { - vec4 c = texelFetch(WorldTexture, ivec2(gl_FragCoord.xy), 0); + vec4 c = texelFetch(SourceTexture, ivec2(gl_FragCoord.xy), 0); fragColor = vec4(Tint, c.a) * c; }