Fix menu effects ignoring annotations

This commit is contained in:
Gustas
2025-12-30 21:49:19 +02:00
committed by Paul Chote
parent 6e98d7f73e
commit 638c0d7db1
13 changed files with 27 additions and 24 deletions

View File

@@ -380,6 +380,8 @@ namespace OpenRA.Graphics
}
}
ApplyPostProcessing(PostProcessPassType.AfterAnnotations);
Game.Renderer.Flush();
preparedRenderables.Clear();

View File

@@ -46,7 +46,7 @@ namespace OpenRA
readonly IVertexBuffer<Vertex> tempVertexBuffer;
readonly IIndexBuffer quadIndexBuffer;
readonly Stack<Rectangle> scissorState = [];
readonly ITexture worldBufferSnapshot;
readonly ITexture bufferSnapshot;
IFrameBuffer screenBuffer;
Sprite screenSprite;
@@ -61,12 +61,13 @@ namespace OpenRA
public int WorldDownscaleFactor { get; private set; } = 1;
/// <summary>
/// Copies and returns the currently rendered world state as a temporary texture.
/// Copies and returns the currently rendered state as a temporary texture.
/// </summary>
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<Vertex>(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();

View File

@@ -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

View File

@@ -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)

View File

@@ -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;

View File

@@ -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);

View File

@@ -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)
{

View File

@@ -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);
}

View File

@@ -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);
}

View File

@@ -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);
}

View File

@@ -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);
}

View File

@@ -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);
}

View File

@@ -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;
}