Add Multiply blend mode for D2K move-flash and shroud.

This commit is contained in:
Paul Chote
2013-12-11 08:58:46 +13:00
parent 89d1d17b80
commit 089973280d
6 changed files with 21 additions and 7 deletions

View File

@@ -31,7 +31,7 @@ namespace OpenRA.FileFormats.Graphics
IGraphicsDevice Create( Size size, WindowMode windowMode ); IGraphicsDevice Create( Size size, WindowMode windowMode );
} }
public enum BlendMode { None, Alpha, Additive, Subtractive } public enum BlendMode { None, Alpha, Additive, Subtractive, Multiply }
public interface IGraphicsDevice public interface IGraphicsDevice
{ {

View File

@@ -10,8 +10,8 @@
using System.IO; using System.IO;
using OpenRA.FileFormats; using OpenRA.FileFormats;
using OpenRA.Traits;
using OpenRA.Graphics; using OpenRA.Graphics;
using OpenRA.Traits;
namespace OpenRA.Mods.RA namespace OpenRA.Mods.RA
{ {
@@ -24,6 +24,7 @@ namespace OpenRA.Mods.RA
[Desc("Palette byte offset")] [Desc("Palette byte offset")]
public readonly long Offset = 0; public readonly long Offset = 0;
public readonly bool AllowModifiers = true; public readonly bool AllowModifiers = true;
public readonly bool InvertColor = false;
public object Create(ActorInitializer init) { return new PaletteFromR8(this); } public object Create(ActorInitializer init) { return new PaletteFromR8(this); }
} }
@@ -42,10 +43,11 @@ namespace OpenRA.Mods.RA
for (var i = 0; i < 256; i++) for (var i = 0; i < 256; i++)
{ {
// The custom palette is scaled into the range 0-128.
// This makes the move-flash match the original game, but may not be correct in other cases.
var packed = s.ReadUInt16(); var packed = s.ReadUInt16();
colors[i] = (uint)((255 << 24) | ((packed & 0xF800) << 7) | ((packed & 0x7E0) << 4) | ((packed & 0x1f) << 2)); colors[i] = (uint)((255 << 24) | ((packed & 0xF800) << 8) | ((packed & 0x7E0) << 5) | ((packed & 0x1f) << 3));
if (info.InvertColor)
colors[i] ^= 0x00FFFFFF;
} }
} }

View File

@@ -177,6 +177,12 @@ namespace OpenRA.Renderer.Sdl2
ErrorHandler.CheckGlError(); ErrorHandler.CheckGlError();
Gl.glBlendEquation(Gl.GL_FUNC_REVERSE_SUBTRACT); Gl.glBlendEquation(Gl.GL_FUNC_REVERSE_SUBTRACT);
break; break;
case BlendMode.Multiply:
Gl.glEnable(Gl.GL_BLEND);
ErrorHandler.CheckGlError();
Gl.glBlendFuncSeparate(Gl.GL_DST_COLOR, Gl.GL_ZERO, Gl.GL_ONE, Gl.GL_ONE_MINUS_SRC_ALPHA);
ErrorHandler.CheckGlError();
break;
} }
ErrorHandler.CheckGlError(); ErrorHandler.CheckGlError();

View File

@@ -179,6 +179,12 @@ namespace OpenRA.Renderer.SdlCommon
ErrorHandler.CheckGlError(); ErrorHandler.CheckGlError();
Gl.glBlendEquation(Gl.GL_FUNC_REVERSE_SUBTRACT); Gl.glBlendEquation(Gl.GL_FUNC_REVERSE_SUBTRACT);
break; break;
case BlendMode.Multiply:
Gl.glEnable(Gl.GL_BLEND);
ErrorHandler.CheckGlError();
Gl.glBlendFuncSeparate(Gl.GL_DST_COLOR, Gl.GL_ZERO, Gl.GL_ONE, Gl.GL_ONE_MINUS_SRC_ALPHA);
ErrorHandler.CheckGlError();
break;
} }
ErrorHandler.CheckGlError(); ErrorHandler.CheckGlError();
} }

View File

@@ -414,7 +414,7 @@ World:
Name: moveflash Name: moveflash
Filename: DATA.R8 Filename: DATA.R8
Offset: 2572352 Offset: 2572352
A: 64 InvertColor: true
PaletteFromRGBA@disabled: PaletteFromRGBA@disabled:
Name: disabled Name: disabled
R: 0 R: 0

View File

@@ -304,7 +304,7 @@ moveflsh:
Start: 3621 Start: 3621
Length: 5 Length: 5
Tick: 80 Tick: 80
BlendMode: Subtractive BlendMode: Multiply
resources: resources:
spice: BLOXBASE spice: BLOXBASE