Explorar el Código

neercs: do not pass the texture coordinates from the application to

the GL server; instead, simply deduce them from the vertex coordinates
and interpolate them in the fragment shader.
master
Sam Hocevar hace 12 años
padre
commit
804e386ca4
Se han modificado 12 ficheros con 71 adiciones y 39 borrados
  1. +6
    -2
      neercs/video/blurh.lolfx
  2. +6
    -2
      neercs/video/blurv.lolfx
  3. +2
    -3
      neercs/video/color.lolfx
  4. +7
    -3
      neercs/video/copper.lolfx
  5. +8
    -2
      neercs/video/glow.lolfx
  6. +7
    -3
      neercs/video/mirror.lolfx
  7. +4
    -5
      neercs/video/noise.lolfx
  8. +2
    -3
      neercs/video/postfx.lolfx
  9. +7
    -3
      neercs/video/radial.lolfx
  10. +7
    -3
      neercs/video/remanence.lolfx
  11. +9
    -8
      neercs/video/render.cpp
  12. +6
    -2
      neercs/video/simple.lolfx

+ 6
- 2
neercs/video/blurh.lolfx Ver fichero

@@ -2,23 +2,27 @@

#version 120

varying vec2 pass_TexCoord;

void main()
{
gl_Position = gl_Vertex;
gl_TexCoord[0] = gl_MultiTexCoord0;
pass_TexCoord = vec2(0.5, 0.5) + 0.5 * gl_Vertex.xy;
}

[frag.glsl]

#version 120

varying vec2 pass_TexCoord;

uniform sampler2D texture;
uniform vec2 radius;

void main(void)
{
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 b = radius.x+radius.y*mask;
total += texture2D(texture,vec2(p.x-b*4.0,p.y))*0.04;


+ 6
- 2
neercs/video/blurv.lolfx Ver fichero

@@ -2,23 +2,27 @@

#version 120

varying vec2 pass_TexCoord;

void main()
{
gl_Position = gl_Vertex;
gl_TexCoord[0] = gl_MultiTexCoord0;
pass_TexCoord = vec2(0.5, 0.5) + 0.5 * gl_Vertex.xy;
}

[frag.glsl]

#version 120

varying vec2 pass_TexCoord;

uniform sampler2D texture;
uniform vec2 radius;

void main(void)
{
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 b = radius.x+radius.y*mask;
total += texture2D(texture,vec2(p.x,p.y-b*4.0))*0.04;


+ 2
- 3
neercs/video/color.lolfx Ver fichero

@@ -5,7 +5,6 @@
void main()
{
gl_Position = gl_Vertex;
gl_TexCoord[0] = gl_MultiTexCoord0;
}

[frag.glsl]
@@ -20,7 +19,7 @@ uniform float flash;

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;

float a = (c.x + c.y + c.z) / 3.0;
@@ -32,4 +31,4 @@ void main(void)
c += flash; // flash

gl_FragColor = vec4(c, 1.0);
}
}

+ 7
- 3
neercs/video/copper.lolfx Ver fichero

@@ -2,16 +2,20 @@

#version 120

varying vec2 pass_TexCoord;

void main()
{
gl_Position = gl_Vertex;
gl_TexCoord[0] = gl_MultiTexCoord0;
pass_TexCoord = vec2(0.5, 0.5) + 0.5 * gl_Vertex.xy;
}

[frag.glsl]

#version 120

varying vec2 pass_TexCoord;

uniform sampler2D texture;
uniform vec2 screen_size;
uniform float time;
@@ -20,7 +24,7 @@ uniform vec3 mask_color;

void main(void)
{
vec2 p = gl_TexCoord[0].xy;
vec2 p = pass_TexCoord;
vec3 source = texture2D(texture, p).xyz;

vec3 color = vec3(0.5);
@@ -35,4 +39,4 @@ void main(void)
color.z = float(int(color.z * 8.0) * 32) / 256.0;

gl_FragColor = vec4((source == mask_color) ? color : source, 1.0);
}
}

+ 8
- 2
neercs/video/glow.lolfx Ver fichero

@@ -2,21 +2,27 @@

#version 120

varying vec2 pass_TexCoord;

void main()
{
gl_Position = gl_Vertex;
gl_TexCoord[0] = gl_MultiTexCoord0;
pass_TexCoord = vec2(0.5, 0.5) + 0.5 * gl_Vertex.xy;
}

[frag.glsl]

#version 120

varying vec2 pass_TexCoord;

uniform sampler2D glow;
uniform sampler2D source;
uniform vec2 mix;

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;
}


+ 7
- 3
neercs/video/mirror.lolfx Ver fichero

@@ -2,23 +2,27 @@

#version 120

varying vec2 pass_TexCoord;

void main()
{
gl_Position = gl_Vertex;
gl_TexCoord[0] = gl_MultiTexCoord0;
pass_TexCoord = vec2(0.5, 0.5) + 0.5 * gl_Vertex.xy;
}

[frag.glsl]

#version 120

varying vec2 pass_TexCoord;

uniform sampler2D texture;
uniform vec2 screen_size;
uniform vec4 mirror;

void main(void)
{
vec2 p = gl_TexCoord[0].xy;
vec2 p = pass_TexCoord;
vec3 s = texture2D(texture, p).xyz;

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));

gl_FragColor = vec4(s + c, 1.0);
}
}

+ 4
- 5
neercs/video/noise.lolfx Ver fichero

@@ -4,8 +4,7 @@

void main()
{
gl_Position=gl_Vertex;
gl_TexCoord[0]=gl_MultiTexCoord0;
gl_Position = gl_Vertex;
}

[frag.glsl]
@@ -19,9 +18,9 @@ uniform vec2 offset;
uniform float noise;
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)
@@ -36,4 +35,4 @@ void main(void)
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
gl_FragColor=vec4(c,1.0);
}
}

+ 2
- 3
neercs/video/postfx.lolfx Ver fichero

@@ -4,8 +4,7 @@

void main()
{
gl_Position=gl_Vertex;
gl_TexCoord[0]=gl_MultiTexCoord0;
gl_Position = gl_Vertex;
}

[frag.glsl]
@@ -104,4 +103,4 @@ void main(void)
c*=letterbox(z,corner.x+2.0,corner.y,corner.z); // corner
c+=(g3+g4)*glass.z; // glass
gl_FragColor=vec4(c,1.0);
}
}

+ 7
- 3
neercs/video/radial.lolfx Ver fichero

@@ -2,16 +2,20 @@

#version 120

varying vec2 pass_TexCoord;

void main()
{
gl_Position = gl_Vertex;
gl_TexCoord[0] = gl_MultiTexCoord0;
pass_TexCoord = vec2(0.5, 0.5) + 0.5 * gl_Vertex.xy;
}

[frag.glsl]

#version 120

varying vec2 pass_TexCoord;

uniform sampler2D texture;
uniform vec2 screen_size;
uniform vec4 radial;
@@ -25,7 +29,7 @@ vec3 deform(in vec2 p)

void main(void)
{
vec2 p = -1.0+2.0*gl_TexCoord[0].xy;
vec2 p = -1.0 + 2.0 * pass_TexCoord;
vec2 s = p;
vec3 source=deform(s);

@@ -41,4 +45,4 @@ void main(void)
s += d;
}
gl_FragColor = vec4(source + color * radial.w, 1.0);
}
}

+ 7
- 3
neercs/video/remanence.lolfx Ver fichero

@@ -2,24 +2,28 @@

#version 120

varying vec2 pass_TexCoord;

void main()
{
gl_Position = gl_Vertex;
gl_TexCoord[0] = gl_MultiTexCoord0;
pass_TexCoord = vec2(0.5, 0.5) + 0.5 * gl_Vertex.xy;
}

[frag.glsl]

#version 120

varying vec2 pass_TexCoord;

uniform sampler2D source;
uniform sampler2D buffer;
uniform vec2 mix;

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 */
//gl_FragColor = new_color * mix.x + old_color * mix.y;


+ 9
- 8
neercs/video/render.cpp Ver fichero

@@ -67,8 +67,13 @@ float main_angle = 0.0f; // main angle
float part_angle = 0.0f; // part angle
float fx_angle; // current angle
/* 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 */
bool flash_flag = false; // flag
float flash_angle = 0; // angle
@@ -1471,7 +1476,7 @@ void Render::Draw2D()
glLoadMatrixf(&m[0][0]);
glMatrixMode(GL_MODELVIEW);

fx_angle=main_angle-part_angle;
fx_angle = main_angle - part_angle;
}

void Render::Draw3D()
@@ -1485,9 +1490,6 @@ void Render::Draw3D()
glEnableClientState(GL_VERTEX_ARRAY);
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)
{
// shader copper
@@ -1723,11 +1725,10 @@ void Render::Draw3D()
ShaderSimple(fbo_front, 0);

glDisableClientState(GL_VERTEX_ARRAY);
glDisableClientState(GL_TEXTURE_COORD_ARRAY);
}

Render::~Render()
{
if (m_fps_debug)
Ticker::Unref(m_fps_debug);
}
}

+ 6
- 2
neercs/video/simple.lolfx Ver fichero

@@ -2,20 +2,24 @@

#version 120

varying vec2 pass_TexCoord;

void main()
{
gl_Position = gl_Vertex;
gl_TexCoord[0] = gl_MultiTexCoord0;
pass_TexCoord = vec2(0.5, 0.5) + 0.5 * gl_Vertex.xy;
}

[frag.glsl]

#version 120

varying vec2 pass_TexCoord;

uniform sampler2D texture;

void main(void)
{
gl_FragColor = texture2D(texture, gl_TexCoord[0].xy);
gl_FragColor = texture2D(texture, pass_TexCoord);
}


Cargando…
Cancelar
Guardar