the GL server; instead, simply deduce them from the vertex coordinates and interpolate them in the fragment shader.master
@@ -2,23 +2,27 @@ | |||||
#version 120 | #version 120 | ||||
varying vec2 pass_TexCoord; | |||||
void main() | void main() | ||||
{ | { | ||||
gl_Position = gl_Vertex; | gl_Position = gl_Vertex; | ||||
gl_TexCoord[0] = gl_MultiTexCoord0; | |||||
pass_TexCoord = vec2(0.5, 0.5) + 0.5 * gl_Vertex.xy; | |||||
} | } | ||||
[frag.glsl] | [frag.glsl] | ||||
#version 120 | #version 120 | ||||
varying vec2 pass_TexCoord; | |||||
uniform sampler2D texture; | uniform sampler2D texture; | ||||
uniform vec2 radius; | uniform vec2 radius; | ||||
void main(void) | void main(void) | ||||
{ | { | ||||
vec4 total = vec4(0.0); | vec4 total = vec4(0.0); | ||||
vec2 p = gl_TexCoord[0].xy; | |||||
vec2 p = pass_TexCoord; | |||||
float mask = 2.0-p.x*(6.0-p.x*6.0)*p.y*(6.0-p.y*6.0); | float mask = 2.0-p.x*(6.0-p.x*6.0)*p.y*(6.0-p.y*6.0); | ||||
float b = radius.x+radius.y*mask; | float b = radius.x+radius.y*mask; | ||||
total += texture2D(texture,vec2(p.x-b*4.0,p.y))*0.04; | total += texture2D(texture,vec2(p.x-b*4.0,p.y))*0.04; | ||||
@@ -2,23 +2,27 @@ | |||||
#version 120 | #version 120 | ||||
varying vec2 pass_TexCoord; | |||||
void main() | void main() | ||||
{ | { | ||||
gl_Position = gl_Vertex; | gl_Position = gl_Vertex; | ||||
gl_TexCoord[0] = gl_MultiTexCoord0; | |||||
pass_TexCoord = vec2(0.5, 0.5) + 0.5 * gl_Vertex.xy; | |||||
} | } | ||||
[frag.glsl] | [frag.glsl] | ||||
#version 120 | #version 120 | ||||
varying vec2 pass_TexCoord; | |||||
uniform sampler2D texture; | uniform sampler2D texture; | ||||
uniform vec2 radius; | uniform vec2 radius; | ||||
void main(void) | void main(void) | ||||
{ | { | ||||
vec4 total = vec4(0.0); | vec4 total = vec4(0.0); | ||||
vec2 p = gl_TexCoord[0].xy; | |||||
vec2 p = pass_TexCoord; | |||||
float mask = 2.0-p.x*(6.0-p.x*6.0)*p.y*(6.0-p.y*6.0); | float mask = 2.0-p.x*(6.0-p.x*6.0)*p.y*(6.0-p.y*6.0); | ||||
float b = radius.x+radius.y*mask; | float b = radius.x+radius.y*mask; | ||||
total += texture2D(texture,vec2(p.x,p.y-b*4.0))*0.04; | total += texture2D(texture,vec2(p.x,p.y-b*4.0))*0.04; | ||||
@@ -5,7 +5,6 @@ | |||||
void main() | void main() | ||||
{ | { | ||||
gl_Position = gl_Vertex; | gl_Position = gl_Vertex; | ||||
gl_TexCoord[0] = gl_MultiTexCoord0; | |||||
} | } | ||||
[frag.glsl] | [frag.glsl] | ||||
@@ -20,7 +19,7 @@ uniform float flash; | |||||
void main(void) | void main(void) | ||||
{ | { | ||||
vec2 p = gl_FragCoord.xy/screen_size.xy; | |||||
vec2 p = gl_FragCoord.xy / screen_size.xy; | |||||
vec3 c = texture2D(texture,p).xyz; | vec3 c = texture2D(texture,p).xyz; | ||||
float a = (c.x + c.y + c.z) / 3.0; | float a = (c.x + c.y + c.z) / 3.0; | ||||
@@ -32,4 +31,4 @@ void main(void) | |||||
c += flash; // flash | c += flash; // flash | ||||
gl_FragColor = vec4(c, 1.0); | gl_FragColor = vec4(c, 1.0); | ||||
} | |||||
} |
@@ -2,16 +2,20 @@ | |||||
#version 120 | #version 120 | ||||
varying vec2 pass_TexCoord; | |||||
void main() | void main() | ||||
{ | { | ||||
gl_Position = gl_Vertex; | gl_Position = gl_Vertex; | ||||
gl_TexCoord[0] = gl_MultiTexCoord0; | |||||
pass_TexCoord = vec2(0.5, 0.5) + 0.5 * gl_Vertex.xy; | |||||
} | } | ||||
[frag.glsl] | [frag.glsl] | ||||
#version 120 | #version 120 | ||||
varying vec2 pass_TexCoord; | |||||
uniform sampler2D texture; | uniform sampler2D texture; | ||||
uniform vec2 screen_size; | uniform vec2 screen_size; | ||||
uniform float time; | uniform float time; | ||||
@@ -20,7 +24,7 @@ uniform vec3 mask_color; | |||||
void main(void) | void main(void) | ||||
{ | { | ||||
vec2 p = gl_TexCoord[0].xy; | |||||
vec2 p = pass_TexCoord; | |||||
vec3 source = texture2D(texture, p).xyz; | vec3 source = texture2D(texture, p).xyz; | ||||
vec3 color = vec3(0.5); | vec3 color = vec3(0.5); | ||||
@@ -35,4 +39,4 @@ void main(void) | |||||
color.z = float(int(color.z * 8.0) * 32) / 256.0; | color.z = float(int(color.z * 8.0) * 32) / 256.0; | ||||
gl_FragColor = vec4((source == mask_color) ? color : source, 1.0); | gl_FragColor = vec4((source == mask_color) ? color : source, 1.0); | ||||
} | |||||
} |
@@ -2,21 +2,27 @@ | |||||
#version 120 | #version 120 | ||||
varying vec2 pass_TexCoord; | |||||
void main() | void main() | ||||
{ | { | ||||
gl_Position = gl_Vertex; | gl_Position = gl_Vertex; | ||||
gl_TexCoord[0] = gl_MultiTexCoord0; | |||||
pass_TexCoord = vec2(0.5, 0.5) + 0.5 * gl_Vertex.xy; | |||||
} | } | ||||
[frag.glsl] | [frag.glsl] | ||||
#version 120 | #version 120 | ||||
varying vec2 pass_TexCoord; | |||||
uniform sampler2D glow; | uniform sampler2D glow; | ||||
uniform sampler2D source; | uniform sampler2D source; | ||||
uniform vec2 mix; | uniform vec2 mix; | ||||
void main(void) | void main(void) | ||||
{ | { | ||||
gl_FragColor = texture2D(source,gl_TexCoord[0].xy)*mix.x+texture2D(glow,gl_TexCoord[0].xy)*mix.y; | |||||
gl_FragColor = texture2D(source, pass_TexCoord) * mix.x | |||||
+ texture2D(glow, pass_TexCoord) * mix.y; | |||||
} | } | ||||
@@ -2,23 +2,27 @@ | |||||
#version 120 | #version 120 | ||||
varying vec2 pass_TexCoord; | |||||
void main() | void main() | ||||
{ | { | ||||
gl_Position = gl_Vertex; | gl_Position = gl_Vertex; | ||||
gl_TexCoord[0] = gl_MultiTexCoord0; | |||||
pass_TexCoord = vec2(0.5, 0.5) + 0.5 * gl_Vertex.xy; | |||||
} | } | ||||
[frag.glsl] | [frag.glsl] | ||||
#version 120 | #version 120 | ||||
varying vec2 pass_TexCoord; | |||||
uniform sampler2D texture; | uniform sampler2D texture; | ||||
uniform vec2 screen_size; | uniform vec2 screen_size; | ||||
uniform vec4 mirror; | uniform vec4 mirror; | ||||
void main(void) | void main(void) | ||||
{ | { | ||||
vec2 p = gl_TexCoord[0].xy; | |||||
vec2 p = pass_TexCoord; | |||||
vec3 s = texture2D(texture, p).xyz; | vec3 s = texture2D(texture, p).xyz; | ||||
vec3 c = vec3(0.0); | vec3 c = vec3(0.0); | ||||
@@ -28,4 +32,4 @@ void main(void) | |||||
if(p.y > 1.0 - mirror.y) c += texture2D(texture, vec2(p.x * (0.8 + 2.0 * (1.0 - p.y)) + 0.1 - 1.0 * (1.0 - p.y), - mirror.y - (mirror.y + p.y) * mirror.w)).xyz * (mirror.z / mirror.y * (1.0 - p.y)); | if(p.y > 1.0 - mirror.y) c += texture2D(texture, vec2(p.x * (0.8 + 2.0 * (1.0 - p.y)) + 0.1 - 1.0 * (1.0 - p.y), - mirror.y - (mirror.y + p.y) * mirror.w)).xyz * (mirror.z / mirror.y * (1.0 - p.y)); | ||||
gl_FragColor = vec4(s + c, 1.0); | gl_FragColor = vec4(s + c, 1.0); | ||||
} | |||||
} |
@@ -4,8 +4,7 @@ | |||||
void main() | void main() | ||||
{ | { | ||||
gl_Position=gl_Vertex; | |||||
gl_TexCoord[0]=gl_MultiTexCoord0; | |||||
gl_Position = gl_Vertex; | |||||
} | } | ||||
[frag.glsl] | [frag.glsl] | ||||
@@ -19,9 +18,9 @@ uniform vec2 offset; | |||||
uniform float noise; | uniform float noise; | ||||
uniform vec3 retrace; | uniform vec3 retrace; | ||||
float rand(in vec2 p,in float t,in float v) | |||||
float rand(in vec2 p, in float t, in float v) | |||||
{ | { | ||||
return fract(sin(dot(p+mod(t,1.0),vec2(12.9898,78.2333)))*v); | |||||
return fract(sin(dot(p + mod(t, 1.0), vec2(12.9898, 78.2333))) * v); | |||||
} | } | ||||
void main(void) | void main(void) | ||||
@@ -36,4 +35,4 @@ void main(void) | |||||
c*=1.0+(noise-noise*2.0*r1); // noise | c*=1.0+(noise-noise*2.0*r1); // noise | ||||
c-=retrace.x*0.01*mod(p.y*retrace.y+time*retrace.z,1.0); // retrace | c-=retrace.x*0.01*mod(p.y*retrace.y+time*retrace.z,1.0); // retrace | ||||
gl_FragColor=vec4(c,1.0); | gl_FragColor=vec4(c,1.0); | ||||
} | |||||
} |
@@ -4,8 +4,7 @@ | |||||
void main() | void main() | ||||
{ | { | ||||
gl_Position=gl_Vertex; | |||||
gl_TexCoord[0]=gl_MultiTexCoord0; | |||||
gl_Position = gl_Vertex; | |||||
} | } | ||||
[frag.glsl] | [frag.glsl] | ||||
@@ -104,4 +103,4 @@ void main(void) | |||||
c*=letterbox(z,corner.x+2.0,corner.y,corner.z); // corner | c*=letterbox(z,corner.x+2.0,corner.y,corner.z); // corner | ||||
c+=(g3+g4)*glass.z; // glass | c+=(g3+g4)*glass.z; // glass | ||||
gl_FragColor=vec4(c,1.0); | gl_FragColor=vec4(c,1.0); | ||||
} | |||||
} |
@@ -2,16 +2,20 @@ | |||||
#version 120 | #version 120 | ||||
varying vec2 pass_TexCoord; | |||||
void main() | void main() | ||||
{ | { | ||||
gl_Position = gl_Vertex; | gl_Position = gl_Vertex; | ||||
gl_TexCoord[0] = gl_MultiTexCoord0; | |||||
pass_TexCoord = vec2(0.5, 0.5) + 0.5 * gl_Vertex.xy; | |||||
} | } | ||||
[frag.glsl] | [frag.glsl] | ||||
#version 120 | #version 120 | ||||
varying vec2 pass_TexCoord; | |||||
uniform sampler2D texture; | uniform sampler2D texture; | ||||
uniform vec2 screen_size; | uniform vec2 screen_size; | ||||
uniform vec4 radial; | uniform vec4 radial; | ||||
@@ -25,7 +29,7 @@ vec3 deform(in vec2 p) | |||||
void main(void) | void main(void) | ||||
{ | { | ||||
vec2 p = -1.0+2.0*gl_TexCoord[0].xy; | |||||
vec2 p = -1.0 + 2.0 * pass_TexCoord; | |||||
vec2 s = p; | vec2 s = p; | ||||
vec3 source=deform(s); | vec3 source=deform(s); | ||||
@@ -41,4 +45,4 @@ void main(void) | |||||
s += d; | s += d; | ||||
} | } | ||||
gl_FragColor = vec4(source + color * radial.w, 1.0); | gl_FragColor = vec4(source + color * radial.w, 1.0); | ||||
} | |||||
} |
@@ -2,24 +2,28 @@ | |||||
#version 120 | #version 120 | ||||
varying vec2 pass_TexCoord; | |||||
void main() | void main() | ||||
{ | { | ||||
gl_Position = gl_Vertex; | gl_Position = gl_Vertex; | ||||
gl_TexCoord[0] = gl_MultiTexCoord0; | |||||
pass_TexCoord = vec2(0.5, 0.5) + 0.5 * gl_Vertex.xy; | |||||
} | } | ||||
[frag.glsl] | [frag.glsl] | ||||
#version 120 | #version 120 | ||||
varying vec2 pass_TexCoord; | |||||
uniform sampler2D source; | uniform sampler2D source; | ||||
uniform sampler2D buffer; | uniform sampler2D buffer; | ||||
uniform vec2 mix; | uniform vec2 mix; | ||||
void main(void) | void main(void) | ||||
{ | { | ||||
vec4 old_color = texture2D(buffer, gl_TexCoord[0].xy); | |||||
vec4 new_color = texture2D(source, gl_TexCoord[0].xy); | |||||
vec4 old_color = texture2D(buffer, pass_TexCoord); | |||||
vec4 new_color = texture2D(source, pass_TexCoord); | |||||
/* The old way */ | /* The old way */ | ||||
//gl_FragColor = new_color * mix.x + old_color * mix.y; | //gl_FragColor = new_color * mix.x + old_color * mix.y; | ||||
@@ -67,8 +67,13 @@ float main_angle = 0.0f; // main angle | |||||
float part_angle = 0.0f; // part angle | float part_angle = 0.0f; // part angle | ||||
float fx_angle; // current angle | float fx_angle; // current angle | ||||
/* fs_quad variable */ | /* fs_quad variable */ | ||||
float fs_quad_vtx[] = {-1.0f, 1.0f, 0, 1.0f, -1.0f, -1.0f, 0, 1.0f, 1.0f, -1.0f, 0, 1.0f, 1.0f, 1.0f, 0, 1.0f}; | |||||
float fs_quad_tex[] = {0, 1.0f, 0, 0, 1.0f, 0, 1.0f, 1.0f}; | |||||
float fs_quad_vtx[] = | |||||
{ | |||||
-1.0f, 1.0f, 0, 1.0f, | |||||
-1.0f, -1.0f, 0, 1.0f, | |||||
1.0f, -1.0f, 0, 1.0f, | |||||
1.0f, 1.0f, 0, 1.0f | |||||
}; | |||||
/* flash variable */ | /* flash variable */ | ||||
bool flash_flag = false; // flag | bool flash_flag = false; // flag | ||||
float flash_angle = 0; // angle | float flash_angle = 0; // angle | ||||
@@ -1471,7 +1476,7 @@ void Render::Draw2D() | |||||
glLoadMatrixf(&m[0][0]); | glLoadMatrixf(&m[0][0]); | ||||
glMatrixMode(GL_MODELVIEW); | glMatrixMode(GL_MODELVIEW); | ||||
fx_angle=main_angle-part_angle; | |||||
fx_angle = main_angle - part_angle; | |||||
} | } | ||||
void Render::Draw3D() | void Render::Draw3D() | ||||
@@ -1485,9 +1490,6 @@ void Render::Draw3D() | |||||
glEnableClientState(GL_VERTEX_ARRAY); | glEnableClientState(GL_VERTEX_ARRAY); | ||||
glVertexPointer(4, GL_FLOAT, 0, fs_quad_vtx); | glVertexPointer(4, GL_FLOAT, 0, fs_quad_vtx); | ||||
glEnableClientState(GL_TEXTURE_COORD_ARRAY); | |||||
glTexCoordPointer(2, GL_FLOAT, 0, fs_quad_tex); | |||||
if (m_shader_copper) | if (m_shader_copper) | ||||
{ | { | ||||
// shader copper | // shader copper | ||||
@@ -1723,11 +1725,10 @@ void Render::Draw3D() | |||||
ShaderSimple(fbo_front, 0); | ShaderSimple(fbo_front, 0); | ||||
glDisableClientState(GL_VERTEX_ARRAY); | glDisableClientState(GL_VERTEX_ARRAY); | ||||
glDisableClientState(GL_TEXTURE_COORD_ARRAY); | |||||
} | } | ||||
Render::~Render() | Render::~Render() | ||||
{ | { | ||||
if (m_fps_debug) | if (m_fps_debug) | ||||
Ticker::Unref(m_fps_debug); | Ticker::Unref(m_fps_debug); | ||||
} | |||||
} |
@@ -2,20 +2,24 @@ | |||||
#version 120 | #version 120 | ||||
varying vec2 pass_TexCoord; | |||||
void main() | void main() | ||||
{ | { | ||||
gl_Position = gl_Vertex; | gl_Position = gl_Vertex; | ||||
gl_TexCoord[0] = gl_MultiTexCoord0; | |||||
pass_TexCoord = vec2(0.5, 0.5) + 0.5 * gl_Vertex.xy; | |||||
} | } | ||||
[frag.glsl] | [frag.glsl] | ||||
#version 120 | #version 120 | ||||
varying vec2 pass_TexCoord; | |||||
uniform sampler2D texture; | uniform sampler2D texture; | ||||
void main(void) | void main(void) | ||||
{ | { | ||||
gl_FragColor = texture2D(texture, gl_TexCoord[0].xy); | |||||
gl_FragColor = texture2D(texture, pass_TexCoord); | |||||
} | } | ||||