Skip to content

Commit

Permalink
added simple shaders
Browse files Browse the repository at this point in the history
  • Loading branch information
paulcscharf committed Apr 18, 2013
1 parent 8178a1b commit d31e68d
Show file tree
Hide file tree
Showing 9 changed files with 189 additions and 0 deletions.
12 changes: 12 additions & 0 deletions data/shaders/postprocess_vs.glsl
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
#version 130

in vec2 v_position;
in vec2 v_texCoord;

out vec2 p_texCoord;

void main()
{
gl_Position = vec4(v_position, 0, 1);
p_texCoord = v_texCoord;
}
10 changes: 10 additions & 0 deletions data/shaders/simple_fs.glsl
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
#version 130

in vec4 p_color;

out vec4 fragColor;

void main()
{
fragColor = p_color;
}
70 changes: 70 additions & 0 deletions data/shaders/simple_postprocess_fs.glsl
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
#version 130

uniform sampler2D diffuseTexture;

uniform vec2 pixelSize;

in vec2 p_texCoord;

out vec4 fragColor;

void main()
{
vec2 uv = p_texCoord;

vec4 c = texture(diffuseTexture, uv) * 3;

uv.x = p_texCoord.x + pixelSize.x * 1.5;
uv.y = p_texCoord.y;
c += texture(diffuseTexture, uv) * 2;

uv.x = p_texCoord.x - pixelSize.x * 1.5;
uv.y = p_texCoord.y;
c += texture(diffuseTexture, uv) * 2;

uv.x = p_texCoord.x;
uv.y = p_texCoord.y + pixelSize.y * 1.5;
c += texture(diffuseTexture, uv) * 2;

uv.x = p_texCoord.x;
uv.y = p_texCoord.y - pixelSize.y * 1.5;
c += texture(diffuseTexture, uv) * 2;


uv.x = p_texCoord.x + pixelSize.x * 3.5;
uv.y = p_texCoord.y;
c += texture(diffuseTexture, uv);

uv.x = p_texCoord.x - pixelSize.x * 3.5;
uv.y = p_texCoord.y;
c += texture(diffuseTexture, uv);

uv.x = p_texCoord.x;
uv.y = p_texCoord.y + pixelSize.y * 3.5;
c += texture(diffuseTexture, uv);

uv.x = p_texCoord.x;
uv.y = p_texCoord.y - pixelSize.y * 3.5;
c += texture(diffuseTexture, uv);


uv.x = p_texCoord.x + pixelSize.x * 5.5;
uv.y = p_texCoord.y;
c += texture(diffuseTexture, uv);

uv.x = p_texCoord.x - pixelSize.x * 5.5;
uv.y = p_texCoord.y;
c += texture(diffuseTexture, uv);

uv.x = p_texCoord.x;
uv.y = p_texCoord.y + pixelSize.y * 5.5;
c += texture(diffuseTexture, uv);

uv.x = p_texCoord.x;
uv.y = p_texCoord.y - pixelSize.y * 5.5;
c += texture(diffuseTexture, uv);

c /= 19;

fragColor = c;
}
14 changes: 14 additions & 0 deletions data/shaders/simple_sprite_fs.glsl
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
#version 130

uniform sampler2D diffuseTexture;

in vec4 p_color;
in vec2 p_texcoord;

out vec4 fragColor;

void main()
{
vec4 c = p_color * texture(diffuseTexture, p_texcoord);
fragColor = c;
}
21 changes: 21 additions & 0 deletions data/shaders/simple_sprite_vs.glsl
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
#version 130

uniform mat4 projectionMatrix;
uniform mat4 modelviewMatrix;

in vec3 v_position;
in vec2 v_texcoord;
in vec4 v_color;
in vec2 v_expand;

out vec4 p_color;
out vec2 p_texcoord;

void main()
{
vec4 p = modelviewMatrix * vec4(v_position, 1.0);
p += vec4(v_expand, 0.0, 0.0);
gl_Position = projectionMatrix * p;
p_color = v_color;
p_texcoord = v_texcoord;
}
15 changes: 15 additions & 0 deletions data/shaders/simple_vs.glsl
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
#version 130

uniform mat4 projectionMatrix;
uniform mat4 modelviewMatrix;

in vec3 v_position;
in vec4 v_color;

out vec4 p_color;

void main()
{
gl_Position = projectionMatrix * modelviewMatrix * vec4(v_position, 1.0);
p_color = v_color;
}
14 changes: 14 additions & 0 deletions data/shaders/uvcolor_fs.glsl
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
#version 130

uniform sampler2D diffuseTexture;

in vec4 p_color;
in vec2 p_texcoord;

out vec4 fragColor;

void main()
{
vec4 c = p_color * texture(diffuseTexture, p_texcoord);
fragColor = c;
}
15 changes: 15 additions & 0 deletions data/shaders/uvcolor_fs_intensity.glsl
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
#version 130

uniform sampler2D diffuseTexture;
uniform float intensity = 1;

in vec4 p_color;
in vec2 p_texcoord;

out vec4 fragColor;

void main()
{
vec4 c = p_color * texture(diffuseTexture, p_texcoord) * vec4(vec3(intensity), 1);
fragColor = c;
}
18 changes: 18 additions & 0 deletions data/shaders/uvcolor_vs.glsl
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
#version 130

uniform mat4 projectionMatrix;
uniform mat4 modelviewMatrix;

in vec3 v_position;
in vec2 v_texcoord;
in vec4 v_color;

out vec4 p_color;
out vec2 p_texcoord;

void main()
{
gl_Position = projectionMatrix * modelviewMatrix * vec4(v_position, 1.0);
p_color = v_color;
p_texcoord = v_texcoord;
}

0 comments on commit d31e68d

Please sign in to comment.