diff --git a/binaries/data/mods/public/shaders/arb/foreground_overlay.fp b/binaries/data/mods/public/shaders/arb/foreground_overlay.fp
index dd45618867..e829e3800c 100644
--- a/binaries/data/mods/public/shaders/arb/foreground_overlay.fp
+++ b/binaries/data/mods/public/shaders/arb/foreground_overlay.fp
@@ -1,5 +1,9 @@
!!ARBfp1.0
-TEX result.color, fragment.texcoord[0], texture[0], 2D;
+PARAM colorMul = program.local[0];
+TEMP color;
+TEX color, fragment.texcoord[0], texture[0], 2D;
+MUL color, color, colorMul;
+MOV result.color, color;
END
diff --git a/binaries/data/mods/public/shaders/arb/foreground_overlay.xml b/binaries/data/mods/public/shaders/arb/foreground_overlay.xml
index 9d6a28c572..b399bdf2a2 100644
--- a/binaries/data/mods/public/shaders/arb/foreground_overlay.xml
+++ b/binaries/data/mods/public/shaders/arb/foreground_overlay.xml
@@ -3,11 +3,12 @@
-
+
-
+
+
diff --git a/binaries/data/mods/public/shaders/glsl/foreground_overlay.fs b/binaries/data/mods/public/shaders/glsl/foreground_overlay.fs
index d330b93b6b..dc78f8fdc2 100644
--- a/binaries/data/mods/public/shaders/glsl/foreground_overlay.fs
+++ b/binaries/data/mods/public/shaders/glsl/foreground_overlay.fs
@@ -1,9 +1,10 @@
#version 110
uniform sampler2D baseTex;
+uniform vec4 colorMul;
varying vec2 v_tex;
void main()
{
- gl_FragColor = texture2D(baseTex, v_tex);
+ gl_FragColor = texture2D(baseTex, v_tex) * colorMul;
}
diff --git a/binaries/data/mods/public/simulation/components/StatusBars.js b/binaries/data/mods/public/simulation/components/StatusBars.js
index de6b4aae7b..b030b716ad 100644
--- a/binaries/data/mods/public/simulation/components/StatusBars.js
+++ b/binaries/data/mods/public/simulation/components/StatusBars.js
@@ -1,3 +1,5 @@
+const NATURAL_COLOR = "255 255 255 255"; // pure white
+
function StatusBars() {}
StatusBars.prototype.Schema =
@@ -119,7 +121,8 @@ StatusBars.prototype.AddAuraIcons = function(cmpOverlayRenderer, yoffset)
icon,
{ "x": xoffset - iconSize/2, "y": yoffset },
{ "x": xoffset + iconSize/2, "y": yoffset + iconSize },
- offset
+ offset,
+ NATURAL_COLOR
);
xoffset += iconSize * 1.2;
}
@@ -142,14 +145,16 @@ StatusBars.prototype.AddBars = function(cmpOverlayRenderer, yoffset)
"art/textures/ui/session/icons/"+type+"_bg.png",
{ "x": -width/2, "y":yoffset },
{ "x": width/2, "y": height + yoffset },
- offset
+ offset,
+ NATURAL_COLOR
);
cmpOverlayRenderer.AddSprite(
"art/textures/ui/session/icons/"+type+"_fg.png",
{ "x": -width/2, "y": yoffset },
{ "x": width*(amount - 0.5), "y": height + yoffset },
- offset
+ offset,
+ NATURAL_COLOR
);
yoffset += height * 1.2;
@@ -190,7 +195,8 @@ StatusBars.prototype.AddBars = function(cmpOverlayRenderer, yoffset)
icon,
{ "x": -rankSize/2 + xoffset, "y": -rankSize/2 + yoffset },
{ "x": rankSize/2 + xoffset, "y": rankSize/2 + yoffset },
- offset
+ offset,
+ "255 255 255 255"
);
}
}
diff --git a/source/graphics/Overlay.h b/source/graphics/Overlay.h
index 98f1d9615e..8506ee6e52 100644
--- a/source/graphics/Overlay.h
+++ b/source/graphics/Overlay.h
@@ -1,4 +1,4 @@
-/* Copyright (C) 2012 Wildfire Games.
+/* Copyright (C) 2015 Wildfire Games.
* This file is part of 0 A.D.
*
* 0 A.D. is free software: you can redistribute it and/or modify
@@ -136,6 +136,7 @@ struct SOverlayTexturedLine
struct SOverlaySprite
{
CTexturePtr m_Texture;
+ CColor m_Color;
CVector3D m_Position; // base position
float m_X0, m_Y0, m_X1, m_Y1; // billboard corner coordinates, relative to base position
};
diff --git a/source/renderer/OverlayRenderer.cpp b/source/renderer/OverlayRenderer.cpp
index 660d3ba2c5..9373d3480d 100644
--- a/source/renderer/OverlayRenderer.cpp
+++ b/source/renderer/OverlayRenderer.cpp
@@ -1,4 +1,4 @@
-/* Copyright (C) 2014 Wildfire Games.
+/* Copyright (C) 2015 Wildfire Games.
* This file is part of 0 A.D.
*
* 0 A.D. is free software: you can redistribute it and/or modify
@@ -622,6 +622,8 @@ void OverlayRenderer::RenderForegroundOverlays(const CCamera& viewCamera)
shader->BindTexture(str_baseTex, sprite->m_Texture);
else
sprite->m_Texture->Bind();
+
+ shader->Uniform(str_colorMul, sprite->m_Color);
CVector3D pos[4] = {
sprite->m_Position + right*sprite->m_X0 + up*sprite->m_Y0,
diff --git a/source/simulation2/components/CCmpOverlayRenderer.cpp b/source/simulation2/components/CCmpOverlayRenderer.cpp
index b2ad7e8de5..abcc0e126b 100644
--- a/source/simulation2/components/CCmpOverlayRenderer.cpp
+++ b/source/simulation2/components/CCmpOverlayRenderer.cpp
@@ -1,4 +1,4 @@
-/* Copyright (C) 2012 Wildfire Games.
+/* Copyright (C) 2015 Wildfire Games.
* This file is part of 0 A.D.
*
* 0 A.D. is free software: you can redistribute it and/or modify
@@ -27,6 +27,8 @@
#include "graphics/TextureManager.h"
#include "renderer/Renderer.h"
+#include "ps/CLogger.h"
+
class CCmpOverlayRenderer : public ICmpOverlayRenderer
{
public:
@@ -112,8 +114,12 @@ public:
UpdateMessageSubscriptions();
}
- virtual void AddSprite(VfsPath textureName, CFixedVector2D corner0, CFixedVector2D corner1, CFixedVector3D position)
+ virtual void AddSprite(VfsPath textureName, CFixedVector2D corner0, CFixedVector2D corner1, CFixedVector3D position, std::string color)
{
+ CColor colorObj(1.0f, 1.0f, 1.0f, 1.0f);
+ if (!colorObj.ParseString(color, 1))
+ LOGERROR("OverlayRenderer: Error parsing '%s'", color);
+
CTextureProperties textureProps(textureName);
SOverlaySprite sprite;
@@ -122,6 +128,7 @@ public:
sprite.m_Y0 = corner0.Y.ToFloat();
sprite.m_X1 = corner1.X.ToFloat();
sprite.m_Y1 = corner1.Y.ToFloat();
+ sprite.m_Color = colorObj;
m_Sprites.push_back(sprite);
m_SpriteOffsets.push_back(CVector3D(position));
diff --git a/source/simulation2/components/ICmpOverlayRenderer.cpp b/source/simulation2/components/ICmpOverlayRenderer.cpp
index 233b316cbd..1fc287bdc1 100644
--- a/source/simulation2/components/ICmpOverlayRenderer.cpp
+++ b/source/simulation2/components/ICmpOverlayRenderer.cpp
@@ -1,4 +1,4 @@
-/* Copyright (C) 2010 Wildfire Games.
+/* Copyright (C) 2015 Wildfire Games.
* This file is part of 0 A.D.
*
* 0 A.D. is free software: you can redistribute it and/or modify
@@ -23,5 +23,5 @@
BEGIN_INTERFACE_WRAPPER(OverlayRenderer)
DEFINE_INTERFACE_METHOD_0("Reset", void, ICmpOverlayRenderer, Reset)
-DEFINE_INTERFACE_METHOD_4("AddSprite", void, ICmpOverlayRenderer, AddSprite, VfsPath, CFixedVector2D, CFixedVector2D, CFixedVector3D)
+DEFINE_INTERFACE_METHOD_5("AddSprite", void, ICmpOverlayRenderer, AddSprite, VfsPath, CFixedVector2D, CFixedVector2D, CFixedVector3D, std::string)
END_INTERFACE_WRAPPER(OverlayRenderer)
diff --git a/source/simulation2/components/ICmpOverlayRenderer.h b/source/simulation2/components/ICmpOverlayRenderer.h
index 73ce959acd..3e6e4ca32d 100644
--- a/source/simulation2/components/ICmpOverlayRenderer.h
+++ b/source/simulation2/components/ICmpOverlayRenderer.h
@@ -1,4 +1,4 @@
-/* Copyright (C) 2010 Wildfire Games.
+/* Copyright (C) 2015 Wildfire Games.
* This file is part of 0 A.D.
*
* 0 A.D. is free software: you can redistribute it and/or modify
@@ -48,8 +48,9 @@ public:
* @param corner0,corner1 coordinates of sprite's corners, in world-space units oriented with the camera plane,
* relative to the sprite position.
* @param offset world-space offset of sprite position from the entity's base position.
+ * @param color multiply color of texture
*/
- virtual void AddSprite(VfsPath textureName, CFixedVector2D corner0, CFixedVector2D corner1, CFixedVector3D offset) = 0;
+ virtual void AddSprite(VfsPath textureName, CFixedVector2D corner0, CFixedVector2D corner1, CFixedVector3D offset, std::string color = "255 255 255 255") = 0;
DECLARE_INTERFACE_TYPE(OverlayRenderer)
};