Browse Source

added shine, also codebase for shine video

master
Joshua Moerman 14 years ago
parent
commit
bbac9156c9
  1. 6
      App.h
  2. 7
      resources/myTeaShader.frag
  3. 10
      resources/myTeaShader.vert
  4. 11
      resources/myTextureShader.frag

6
App.h

@ -69,6 +69,9 @@ public:
void update() { void update() {
++counter; ++counter;
if(counter % 100 == 0){
std::cout << counter << std::endl;
}
} }
void draw() { void draw() {
@ -128,8 +131,9 @@ public:
} }
void scene() { void scene() {
if(mouse_buttons[0]){ if(mouse_buttons[0] || mouse_buttons[1] || mouse_buttons[2]){
mshader.set_uniform("steps", counter/10); mshader.set_uniform("steps", counter/10);
mshader.set_uniform("button", (mouse_buttons[0] ? 0 : (mouse_buttons[1] ? 1 : 2)));
glEnableClientState(GL_VERTEX_ARRAY); glEnableClientState(GL_VERTEX_ARRAY);
glVertexPointer(2, GL_FLOAT, 0, &mouse[0]); glVertexPointer(2, GL_FLOAT, 0, &mouse[0]);

7
resources/myTeaShader.frag

@ -3,7 +3,8 @@ varying vec4 color;
uniform int steps; uniform int steps;
void main( void ) { void main( void ) {
gl_FragColor.rgb = sin(3.0*sin(normalize(color.rgb) + vec3(steps)*vec3(0.01, 0.017, 0.0093)))*0.5+0.5; //gl_FragColor.rgb = sin(3.0*sin(normalize(color.rgb) + vec3(steps)*vec3(0.01, 0.017, 0.0093)))*0.5+0.5;
gl_FragColor.rgb *= 0.5; //gl_FragColor.rgb *= 0.5;
gl_FragColor.a = 1.0; //gl_FragColor.a = 1.0;
gl_FragColor = color;
} }

10
resources/myTeaShader.vert

@ -1,9 +1,17 @@
varying vec4 color; varying vec4 color;
uniform int button;
void main( void ) { void main( void ) {
gl_Position = gl_Vertex; gl_Position = gl_Vertex;
gl_Position.xy /= vec2(800, 600)*0.5; gl_Position.xy /= vec2(800, 600)*0.5;
gl_Position.xy -= 1.0; gl_Position.xy -= 1.0;
gl_Position.y *= -1.0; gl_Position.y *= -1.0;
color = gl_Vertex;
if(button == 0)
color = vec4(1.0);
else if (button == 1)
color = vec4(0.0, 1.0, 1.0, 1.0);
else
color = vec4(0.0, 0.0, 1.0, 1.0);
} }

11
resources/myTextureShader.frag

@ -3,7 +3,14 @@ uniform sampler2D tex;
void main( void ) { void main( void ) {
gl_FragColor = texture2D(tex, gl_TexCoord[0].st); gl_FragColor = texture2D(tex, gl_TexCoord[0].st);
//gl_FragColor -= texture2D(tex, gl_TexCoord[0].st + vec2(0.0, 0.005));
//gl_FragColor = gl_FragColor*2.0 + 0.5; vec2 offset = vec2(0.01, 0.0);
vec4 a = texture2D(tex, gl_TexCoord[0].st - offset);
vec4 b = texture2D(tex, gl_TexCoord[0].st + offset);
if(length(a-b) < 0.1 && length(gl_FragColor.rgb) > 0.3)
gl_FragColor *= 1.0 + 0.01/length(a-b);
gl_FragColor.a = 1.0; gl_FragColor.a = 1.0;
} }