Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

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

  • Loading branch information...
commit 089973280d540b8bf82366071867abef9bbf72a1 1 parent 89d1d17
@pchote pchote authored
View
2  OpenRA.FileFormats/Graphics/IGraphicsDevice.cs
@@ -31,7 +31,7 @@ public interface IDeviceFactory
IGraphicsDevice Create( Size size, WindowMode windowMode );
}
- public enum BlendMode { None, Alpha, Additive, Subtractive }
+ public enum BlendMode { None, Alpha, Additive, Subtractive, Multiply }
public interface IGraphicsDevice
{
View
10 OpenRA.Mods.D2k/PaletteFromR8.cs
@@ -10,8 +10,8 @@
using System.IO;
using OpenRA.FileFormats;
-using OpenRA.Traits;
using OpenRA.Graphics;
+using OpenRA.Traits;
namespace OpenRA.Mods.RA
{
@@ -24,6 +24,7 @@ class PaletteFromR8Info : ITraitInfo
[Desc("Palette byte offset")]
public readonly long Offset = 0;
public readonly bool AllowModifiers = true;
+ public readonly bool InvertColor = false;
public object Create(ActorInitializer init) { return new PaletteFromR8(this); }
}
@@ -42,10 +43,11 @@ public void InitPalette(WorldRenderer wr)
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();
- 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
6 OpenRA.Renderer.Sdl2/Sdl2GraphicsDevice.cs
@@ -177,6 +177,12 @@ public void SetBlendMode(BlendMode mode)
ErrorHandler.CheckGlError();
Gl.glBlendEquation(Gl.GL_FUNC_REVERSE_SUBTRACT);
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();
View
6 OpenRA.Renderer.SdlCommon/SdlGraphics.cs
@@ -179,6 +179,12 @@ public void SetBlendMode(BlendMode mode)
ErrorHandler.CheckGlError();
Gl.glBlendEquation(Gl.GL_FUNC_REVERSE_SUBTRACT);
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();
}
View
2  mods/d2k/rules/system.yaml
@@ -414,7 +414,7 @@ World:
Name: moveflash
Filename: DATA.R8
Offset: 2572352
- A: 64
+ InvertColor: true
PaletteFromRGBA@disabled:
Name: disabled
R: 0
View
2  mods/d2k/sequences/misc.yaml
@@ -304,7 +304,7 @@ moveflsh:
Start: 3621
Length: 5
Tick: 80
- BlendMode: Subtractive
+ BlendMode: Multiply
resources:
spice: BLOXBASE
Please sign in to comment.
Something went wrong with that request. Please try again.