|
From: Lasse Kärkkäi. <tr...@us...> - 2011-02-06 20:38:51
|
Module: performous
Branch: opengl2
Commit: 2296fe1e6c97d0566647af3c3b13bffbffc5dd61
Author: Lasse Karkkainen <tro...@tr...>
Date: Sun Feb 6 21:35:36 2011 +0100
Fix all shaders.
* 3dobject shader is now in Window & 3dobject
* Removed unused shader files
* Removed all mention of shaders in guitar/dancegraph
Regression: dance note effects removed
* Can be done with colorMatrix (much faster)
* Quite possibly moving to 3d objects instead of flat arrows
---
game/3dobject.hh | 1 +
game/dancegraph.cc | 15 ---------
game/guitargraph.cc | 6 ---
game/instrumentgraph.hh | 4 --
game/video_driver.cc | 4 ++
themes/default/shaders/3dobject.frag | 2 -
themes/default/shaders/dancenote.frag | 55 --------------------------------
themes/default/shaders/dancenote.vert | 56 ---------------------------------
themes/default/shaders/intro.frag | 28 ----------------
themes/default/shaders/intro.vert | 7 ----
10 files changed, 5 insertions(+), 173 deletions(-)
diff --git a/game/3dobject.hh b/game/3dobject.hh
index ef99f11..bef24e5 100644
--- a/game/3dobject.hh
+++ b/game/3dobject.hh
@@ -67,6 +67,7 @@ class Object3d: boost::noncopyable {
void drawVBO();
/// draws the object
void draw(float x = 0, float y = 0, float z = 0, float s = 1.0) {
+ UseShader us(getShader("3dobject"));
glutil::PushMatrix pm;
glTranslatef(x, y, z); // Move to position
if (s != 1.0) glScalef(s,s,s); // Scale if needed
diff --git a/game/dancegraph.cc b/game/dancegraph.cc
index f3393dc..2cf3d9f 100644
--- a/game/dancegraph.cc
+++ b/game/dancegraph.cc
@@ -90,8 +90,6 @@ DanceGraph::DanceGraph(Audio& audio, Song const& song):
m_flow_direction(1),
m_insideStop()
{
- m_shader_note.reset(new Shader);
- m_shader_note->compileFile(getThemePath("shaders/dancenote.vert")).compileFile(getThemePath("shaders/dancenote.frag")).link();
// Initialize some arrays
for (size_t i = 0; i < max_panels; i++) {
m_activeNotes[i] = m_notes.end();
@@ -428,14 +426,8 @@ void DanceGraph::draw(double time) {
// Arrows on cursor
{
- UseShader us(*m_shader_note);
- us().setUniform("clock", float(time))
- .setUniform("noteType", 0)
- .setUniform("scale", getScale());
for (int arrow_i = 0; arrow_i < m_pads; ++arrow_i) {
float l = m_pressed_anim[arrow_i].get();
- us().setUniform("hitAnim", l)
- .setUniform("position", panel2x(arrow_i), time2y(0.0));
drawArrow(arrow_i, m_arrows_cursor);
}
}
@@ -491,11 +483,6 @@ void DanceGraph::drawNote(DanceNote& note, double time) {
double glow = note.hitAnim.get();
{
- UseShader us(*m_shader_note);
- us().setUniform("hitAnim", float(glow))
- .setUniform("clock", float(time))
- .setUniform("scale", getScale());
-
if (yEnd - yBeg > arrowSize) {
// Draw holds
if (note.isHit && note.releaseTime <= 0) { // The note is being held down
@@ -503,7 +490,6 @@ void DanceGraph::drawNote(DanceNote& note, double time) {
yEnd = std::max(time2y(0.0), yEnd);
}
if (note.releaseTime > 0) yBeg = time2y(note.releaseTime - time); // Oh noes, it got released!
- us().setUniform("noteType", 2).setUniform("position", x, yBeg);
// Draw begin
drawArrow(arrow_i, m_arrows_hold, 0.0f, 1.0f/3.0f);
if (yEnd - yBeg > 0) {
@@ -521,7 +507,6 @@ void DanceGraph::drawNote(DanceNote& note, double time) {
} else {
// Draw short note
if (mine && note.isHit) yBeg = time2y(0.0);
- us().setUniform("noteType", (mine ? 3 : 1)).setUniform("position", x, yBeg);
drawArrow((mine ? -1 : arrow_i), (mine ? m_mine : m_arrows));
}
}
diff --git a/game/guitargraph.cc b/game/guitargraph.cc
index 72d6cdc..e1d2175 100644
--- a/game/guitargraph.cc
+++ b/game/guitargraph.cc
@@ -127,8 +127,6 @@ GuitarGraph::GuitarGraph(Audio& audio, Song const& song, bool drums, int number)
} else {
initGuitar();
}
- m_shader_note.reset(new Shader);
- m_shader_note->compileFile(getThemePath("shaders/3dobject.vert")).compileFile(getThemePath("shaders/3dobject.frag"));
// Load 3D fret objects
m_fretObj.load(getThemePath("fret.obj"));
m_tappableObj.load(getThemePath("fret_tap.obj"));
@@ -1060,7 +1058,6 @@ void GuitarGraph::drawNote(int fret, Color color, float tBeg, float tEnd, float
color.a = clamp(time2a(tBeg)*2.0f,0.0f,1.0f);
{
glutil::Color c(color);
- UseShader us(*m_shader_note); // Switch shader
m_fretObj.draw(x, y, 0.0f);
}
y -= fretWid;
@@ -1099,14 +1096,12 @@ void GuitarGraph::drawNote(int fret, Color color, float tBeg, float tEnd, float
color.a = s;
{
glutil::Color c(color);
- UseShader us(*m_shader_note); // Switch shader
m_fretObj.draw(x, yBeg, 0.0f, s);
}
} else {
color.a = clamp(time2a(tBeg)*2.0f,0.0f,1.0f);
{
glutil::Color c(color);
- UseShader us(*m_shader_note); // Switch shader
m_fretObj.draw(x, yBeg, 0.0f);
}
}
@@ -1125,7 +1120,6 @@ void GuitarGraph::drawNote(int fret, Color color, float tBeg, float tEnd, float
if (m_use3d) { // 3D
float s = 1.0 - hitAnim;
glutil::Color c(Color(l, l, l, s));
- UseShader us(*m_shader_note); // Switch shader
m_tappableObj.draw(x, yBeg, 0.0f, s);
} else { // 2D
glutil::Color c(Color(l, l, l));
diff --git a/game/instrumentgraph.hh b/game/instrumentgraph.hh
index 0c6e050..7b6fd77 100644
--- a/game/instrumentgraph.hh
+++ b/game/instrumentgraph.hh
@@ -13,7 +13,6 @@
#include "screen.hh"
#include "fs.hh"
#include "theme.hh"
-#include "glshader.hh"
/// Represents popup messages
@@ -136,9 +135,6 @@ class InstrumentGraph {
boost::scoped_ptr<SvgTxtThemeSimple> m_popupText;
boost::scoped_ptr<ThemeInstrumentMenu> m_menuTheme;
- // Shaders
- boost::scoped_ptr<Shader> m_shader_note;
-
// Dynamic stuff for join menu
ConfigItem m_selectedTrack; /// menu modifies this to select track
ConfigItem m_selectedDifficulty; /// menu modifies this to select difficulty
diff --git a/game/video_driver.cc b/game/video_driver.cc
index a766a49..ea238da 100644
--- a/game/video_driver.cc
+++ b/game/video_driver.cc
@@ -83,6 +83,10 @@ Window::Window(unsigned int width, unsigned int height, bool fs): m_windowW(widt
.link()
.bind()
.setUniformMatrix("colorMatrix", glmath::Matrix());
+ shader("3dobject")
+ .compileFile(getThemePath("shaders/3dobject.vert"))
+ .compileFile(getThemePath("shaders/3dobject.frag"))
+ .link();
}
Window::~Window() { }
diff --git a/themes/default/shaders/3dobject.frag b/themes/default/shaders/3dobject.frag
index bade8b1..9bc1d80 100644
--- a/themes/default/shaders/3dobject.frag
+++ b/themes/default/shaders/3dobject.frag
@@ -1,5 +1,3 @@
-#extension GL_ARB_texture_rectangle : enable
-
varying vec3 normal;
void main()
diff --git a/themes/default/shaders/dancenote.frag b/themes/default/shaders/dancenote.frag
deleted file mode 100644
index 8be9c5c..0000000
--- a/themes/default/shaders/dancenote.frag
+++ /dev/null
@@ -1,55 +0,0 @@
-#extension GL_ARB_texture_rectangle : enable
-
-uniform int texMode;
-uniform sampler2D tex;
-uniform sampler2DRect texRect;
-uniform int noteType;
-uniform float hitAnim;
-uniform float clock;
-uniform float scale;
-
-
-void colorGlow(inout vec4 c) {
- c = vec4(
- min(c.r + hitAnim *.5, 1.0),
- min(c.g + hitAnim *.5, 1.0),
- min(c.b + hitAnim *.5, 1.0),
- max(c.a - hitAnim, 0.0));
-}
-
-
-void main()
-{
- vec4 texel;
-
- if (texMode == 1) {
- texel = texture2D(tex, gl_TexCoord[0].st).rgba;
- } else if (texMode == 2) {
- texel = texture2DRect(texRect, gl_TexCoord[0].st).rgba;
- } else if (texMode == 0) {
- texel = vec4(1.0, 1.0, 1.0, 1.0);
- } else {
- texel = vec4(1.0, 0.0, 1.0, 1.0); // Magenta to highlight
- }
-
- // Cursor arrows
- if (noteType == 0) {
- /* no op */
-
- // Regular arrows
- } else if (noteType == 1) {
- colorGlow(texel);
-
- // Holds
- } else if (noteType == 2) {
- colorGlow(texel);
-
- // Mines
- } else if (noteType == 3) {
- /* no op */
-
- }
-
- gl_FragColor = texel;
-}
-
diff --git a/themes/default/shaders/dancenote.vert b/themes/default/shaders/dancenote.vert
deleted file mode 100644
index 3573391..0000000
--- a/themes/default/shaders/dancenote.vert
+++ /dev/null
@@ -1,56 +0,0 @@
-uniform int noteType;
-uniform float hitAnim;
-uniform float clock;
-uniform float scale;
-uniform vec2 position;
-
-#define deg2rad 0.0174532925
-
-mat4 scaleMat(in float sc) {
- return mat4(sc, 0, 0, 0,
- 0, sc, 0, 0,
- 0, 0, sc, 0,
- 0, 0, 0, 1);
-}
-
-mat4 rotMat(in float ang) {
- float ca = cos(ang);
- float sa = sin(ang);
- return mat4(ca, -sa, 0, 0,
- sa, ca, 0, 0,
- 0, 0, 1, 0,
- 0, 0, 0, 1);
-}
-
-
-void main()
-{
- gl_FrontColor = gl_Color;
- gl_BackColor = gl_Color;
- gl_TexCoord[0] = gl_MultiTexCoord0;
-
- mat4 trans = scaleMat(scale);
-
- // Cursor arrows
- if (noteType == 0) {
- trans *= scaleMat(1.0 - hitAnim * .5);
-
- // Regular arrows
- } else if (noteType == 1) {
- trans *= scaleMat(1.0 + hitAnim);
-
- // Holds
- } else if (noteType == 2) {
- trans *= scaleMat(1.0 + hitAnim);
-
- // Mines
- } else if (noteType == 3) {
- trans *= scaleMat(1.0 + hitAnim);
- float r = float(mod(int(clock*360.0), 360)) * deg2rad; // They rotate!
- trans *= rotMat(r);
- }
-
- gl_Position = gl_ModelViewProjectionMatrix * trans * gl_Vertex;
- gl_Position += gl_ModelViewProjectionMatrix * vec4(position.xy, 0, 0);
-}
-
diff --git a/themes/default/shaders/intro.frag b/themes/default/shaders/intro.frag
deleted file mode 100644
index f4665b3..0000000
--- a/themes/default/shaders/intro.frag
+++ /dev/null
@@ -1,28 +0,0 @@
-#extension GL_ARB_texture_rectangle : enable
-
-uniform int texMode;
-uniform sampler2D tex;
-uniform sampler2DRect texRect;
-
-uniform float anim;
-
-void main()
-{
- vec4 texel;
-
- if (texMode == 1) {
- texel = texture2D(tex, gl_TexCoord[0].st).rgba;
- } else if (texMode == 2) {
- texel = texture2DRect(texRect, gl_TexCoord[0].st).rgba;
- } else if (texMode == 0) {
- texel = gl_Color;
- } else {
- texel = vec4(1.0, 0.0, 1.0, 1.0); // Magenta to highlight
- }
-
- float r = anim * 0.5;
- float g = anim * 0.5 + 0.5;
- float b = anim * 0.3 + 0.7;
-
- gl_FragColor = vec4(texel.r * r, texel.g * g, texel.b * b, texel.a);
-}
diff --git a/themes/default/shaders/intro.vert b/themes/default/shaders/intro.vert
deleted file mode 100644
index 48bf7e9..0000000
--- a/themes/default/shaders/intro.vert
+++ /dev/null
@@ -1,7 +0,0 @@
-void main()
-{
- gl_FrontColor = gl_Color;
- gl_BackColor = gl_Color;
- gl_TexCoord[0] = gl_MultiTexCoord0;
- gl_Position = gl_ModelViewProjectionMatrix * gl_Vertex;
-}
|