|
From: Lasse Kärkkäi. <tr...@us...> - 2011-01-28 00:12:48
|
Module: performous
Branch: opengl2
Commit: 791ad259be31cc805e25533d9c89ff6c32d8b50f
Author: Lasse Karkkainen <tro...@tr...>
Date: Fri Jan 28 01:12:35 2011 +0100
B0rked anaglyph red-cyan 3d mode.
---
game/video_driver.cc | 6 +++++-
themes/default/shaders/core.frag | 4 +++-
2 files changed, 8 insertions(+), 2 deletions(-)
diff --git a/game/video_driver.cc b/game/video_driver.cc
index 5dae9f0..caed025 100644
--- a/game/video_driver.cc
+++ b/game/video_driver.cc
@@ -99,6 +99,7 @@ bool Window::view(unsigned num) {
double vx = 0.5f * (screen->w - s_width);
double vy = 0.5f * (screen->h - s_height);
double vw = s_width, vh = s_height;
+ glmath::Matrix colorMatrix;
if (stereo) {
if (num > 1) return false;
double separation = 0.0004f * (num ? -1 : 1) * config["graphic/stereo3dseparation"].f();
@@ -107,7 +108,9 @@ bool Window::view(unsigned num) {
glMatrixMode(GL_MODELVIEW);
glTranslatef(-separation, 0.0f, 0.0f);
if (type == 0) {
- // TODO: implement color shaders for red/cyan
+ // FIXME: This is somewhat b0rked because what we really want is eye1 + eye2, not eye2 alpha-blended on top of eye1...
+ if (!num) colorMatrix.cols[0] = Vec4(0.0, 1.0, 1.0);
+ else { colorMatrix.cols[2] = colorMatrix.cols[1] = Vec4(1.0, 0.0, 0.0); colorMatrix(3,3) = 0.5; }
}
if (type == 1) {
double margin = screen->h - s_height;
@@ -117,6 +120,7 @@ bool Window::view(unsigned num) {
} else {
if (num != 0) return false;
}
+ m_shader->setUniformMatrix("colorMatrix", colorMatrix);
glViewport(vx, vy, vw, vh);
return true;
}
diff --git a/themes/default/shaders/core.frag b/themes/default/shaders/core.frag
index 8f78c53..bdf7016 100644
--- a/themes/default/shaders/core.frag
+++ b/themes/default/shaders/core.frag
@@ -1,5 +1,6 @@
#extension GL_ARB_texture_rectangle : enable
+uniform float4x4 colorMatrix;
uniform int texMode;
uniform sampler2D tex;
uniform sampler2DRect texRect;
@@ -18,5 +19,6 @@ void main()
texel = vec4(1.0, 0.0, 1.0, 1.0); // Magenta to highlight
}
- gl_FragColor = texel * gl_Color;
+ gl_FragColor = colorMatrix * gl_Color * texel;
}
+
|