diff --git a/binaries/data/mods/public/shaders/arb/foreground_overlay.vp b/binaries/data/mods/public/shaders/arb/foreground_overlay.vp
index b718910bc6..995613031f 100644
--- a/binaries/data/mods/public/shaders/arb/foreground_overlay.vp
+++ b/binaries/data/mods/public/shaders/arb/foreground_overlay.vp
@@ -3,10 +3,12 @@
ATTRIB position = vertex.position;
ATTRIB uv = vertex.texcoord[0];
-DP4 result.position.x, state.matrix.mvp.row[0], position;
-DP4 result.position.y, state.matrix.mvp.row[1], position;
-DP4 result.position.z, state.matrix.mvp.row[2], position;
-DP4 result.position.w, state.matrix.mvp.row[3], position;
+PARAM transform[4] = { program.local[0..3] };
+
+DP4 result.position.x, transform[0], position;
+DP4 result.position.y, transform[1], position;
+DP4 result.position.z, transform[2], position;
+DP4 result.position.w, transform[3], position;
MOV result.texcoord, uv;
diff --git a/binaries/data/mods/public/shaders/arb/foreground_overlay.xml b/binaries/data/mods/public/shaders/arb/foreground_overlay.xml
index b399bdf2a2..7a38f62682 100644
--- a/binaries/data/mods/public/shaders/arb/foreground_overlay.xml
+++ b/binaries/data/mods/public/shaders/arb/foreground_overlay.xml
@@ -4,6 +4,7 @@
+
diff --git a/binaries/data/mods/public/shaders/arb/overlayline.vp b/binaries/data/mods/public/shaders/arb/overlayline.vp
index f782045166..cc5db4ef19 100644
--- a/binaries/data/mods/public/shaders/arb/overlayline.vp
+++ b/binaries/data/mods/public/shaders/arb/overlayline.vp
@@ -1,13 +1,15 @@
!!ARBvp1.0
+
+PARAM transform[4] = { program.local[0..3] };
#if !IGNORE_LOS
-PARAM losTransform = program.local[0];
+PARAM losTransform = program.local[4];
#endif
ATTRIB position = vertex.position;
-DP4 result.position.x, state.matrix.mvp.row[0], position;
-DP4 result.position.y, state.matrix.mvp.row[1], position;
-DP4 result.position.z, state.matrix.mvp.row[2], position;
-DP4 result.position.w, state.matrix.mvp.row[3], position;
+DP4 result.position.x, transform[0], position;
+DP4 result.position.y, transform[1], position;
+DP4 result.position.z, transform[2], position;
+DP4 result.position.w, transform[3], position;
MOV result.texcoord[0], vertex.texcoord[0];
#if !IGNORE_LOS
diff --git a/binaries/data/mods/public/shaders/arb/overlayline.xml b/binaries/data/mods/public/shaders/arb/overlayline.xml
index 9a65b550c9..46dc04f95b 100644
--- a/binaries/data/mods/public/shaders/arb/overlayline.xml
+++ b/binaries/data/mods/public/shaders/arb/overlayline.xml
@@ -11,7 +11,8 @@
-
+
+
diff --git a/binaries/data/mods/public/shaders/glsl/foreground_overlay.fs b/binaries/data/mods/public/shaders/glsl/foreground_overlay.fs
index dc78f8fdc2..f6fed2af82 100644
--- a/binaries/data/mods/public/shaders/glsl/foreground_overlay.fs
+++ b/binaries/data/mods/public/shaders/glsl/foreground_overlay.fs
@@ -6,5 +6,5 @@ varying vec2 v_tex;
void main()
{
- gl_FragColor = texture2D(baseTex, v_tex) * colorMul;
+ gl_FragColor = texture2D(baseTex, v_tex) * colorMul;
}
diff --git a/binaries/data/mods/public/shaders/glsl/foreground_overlay.vs b/binaries/data/mods/public/shaders/glsl/foreground_overlay.vs
index f8ace1171e..f04feda33a 100644
--- a/binaries/data/mods/public/shaders/glsl/foreground_overlay.vs
+++ b/binaries/data/mods/public/shaders/glsl/foreground_overlay.vs
@@ -1,11 +1,14 @@
#version 110
+uniform mat4 transform;
+
varying vec2 v_tex;
+
attribute vec3 a_vertex;
attribute vec2 a_uv0;
void main()
{
- gl_Position = gl_ModelViewProjectionMatrix * vec4(a_vertex, 1.0);
- v_tex = a_uv0;
+ gl_Position = transform * vec4(a_vertex, 1.0);
+ v_tex = a_uv0;
}
diff --git a/binaries/data/mods/public/shaders/glsl/foreground_overlay.xml b/binaries/data/mods/public/shaders/glsl/foreground_overlay.xml
index 14bd5e31bb..d6759eb55b 100644
--- a/binaries/data/mods/public/shaders/glsl/foreground_overlay.xml
+++ b/binaries/data/mods/public/shaders/glsl/foreground_overlay.xml
@@ -3,9 +3,9 @@
-
+
-
+
diff --git a/binaries/data/mods/public/shaders/glsl/overlayline.vs b/binaries/data/mods/public/shaders/glsl/overlayline.vs
index b9997b1bb6..f4adf99928 100644
--- a/binaries/data/mods/public/shaders/glsl/overlayline.vs
+++ b/binaries/data/mods/public/shaders/glsl/overlayline.vs
@@ -2,6 +2,8 @@
#include "common/los_vertex.h"
+uniform mat4 transform;
+
attribute vec3 a_vertex;
attribute vec2 a_uv0;
@@ -19,5 +21,5 @@ void main()
#if !USE_OBJECTCOLOR
v_color = a_color;
#endif
- gl_Position = gl_ModelViewProjectionMatrix * vec4(a_vertex, 1.0);
+ gl_Position = transform * vec4(a_vertex, 1.0);
}
diff --git a/source/renderer/OverlayRenderer.cpp b/source/renderer/OverlayRenderer.cpp
index 0f1b1f3224..70abe53bd8 100644
--- a/source/renderer/OverlayRenderer.cpp
+++ b/source/renderer/OverlayRenderer.cpp
@@ -19,6 +19,7 @@
#include "OverlayRenderer.h"
+#include "graphics/Camera.h"
#include "graphics/LOSTexture.h"
#include "graphics/Overlay.h"
#include "graphics/Terrain.h"
@@ -455,6 +456,8 @@ void OverlayRenderer::RenderTexturedOverlayLines()
shaderTexLineNormal->BindTexture(str_losTex, los.GetTexture());
shaderTexLineNormal->Uniform(str_losTransform, los.GetTextureMatrix()[0], los.GetTextureMatrix()[12], 0.f, 0.f);
+ shaderTexLineNormal->Uniform(str_transform, g_Renderer.GetViewCamera().GetViewProjection());
+
// batch render only the non-always-visible overlay lines using the normal shader
RenderTexturedOverlayLines(shaderTexLineNormal, false);
@@ -470,6 +473,8 @@ void OverlayRenderer::RenderTexturedOverlayLines()
shaderTexLineAlwaysVisible->BindTexture(str_losTex, los.GetTexture());
shaderTexLineAlwaysVisible->Uniform(str_losTransform, los.GetTextureMatrix()[0], los.GetTextureMatrix()[12], 0.f, 0.f);
+ shaderTexLineAlwaysVisible->Uniform(str_transform, g_Renderer.GetViewCamera().GetViewProjection());
+
// batch render only the always-visible overlay lines using the LoS-ignored shader
RenderTexturedOverlayLines(shaderTexLineAlwaysVisible, true);
@@ -541,6 +546,8 @@ void OverlayRenderer::RenderQuadOverlays()
shader->BindTexture(str_losTex, los.GetTexture());
shader->Uniform(str_losTransform, los.GetTextureMatrix()[0], los.GetTextureMatrix()[12], 0.f, 0.f);
+ shader->Uniform(str_transform, g_Renderer.GetViewCamera().GetViewProjection());
+
// Base offsets (in bytes) of the two backing stores relative to their owner VBO
u8* indexBase = m->quadIndices.Bind();
u8* vertexBase = m->quadVertices.Bind();
@@ -626,6 +633,8 @@ void OverlayRenderer::RenderForegroundOverlays(const CCamera& viewCamera)
tech->BeginPass();
CShaderProgramPtr shader = tech->GetShader();
+ shader->Uniform(str_transform, g_Renderer.GetViewCamera().GetViewProjection());
+
float uvs[8] = { 0,1, 1,1, 1,0, 0,0 };
shader->TexCoordPointer(GL_TEXTURE0, 2, GL_FLOAT, sizeof(float)*2, &uvs[0]);
@@ -633,11 +642,10 @@ void OverlayRenderer::RenderForegroundOverlays(const CCamera& viewCamera)
for (size_t i = 0; i < m->sprites.size(); ++i)
{
SOverlaySprite* sprite = m->sprites[i];
+ if (!i || sprite->m_Texture != m->sprites[i - 1]->m_Texture)
+ shader->BindTexture(str_baseTex, sprite->m_Texture);
- shader->BindTexture(str_baseTex, sprite->m_Texture);
-
- if (shader)
- shader->Uniform(str_colorMul, sprite->m_Color);
+ shader->Uniform(str_colorMul, sprite->m_Color);
CVector3D pos[4] = {
sprite->m_Position + right*sprite->m_X0 + up*sprite->m_Y0,