changed vert to the glsl tutorial one

This commit is contained in:
2017-07-17 23:52:58 -05:00
parent 686d6c3e9b
commit 97faafa327
7 changed files with 56 additions and 50 deletions

View File

@@ -2,7 +2,6 @@
precision mediump float;
#endif
uniform float time;
uniform vec2 mouse;
uniform vec2 resolution;

View File

@@ -4,9 +4,11 @@ attribute vec2 a_texCoord0;
uniform mat4 u_projTrans;
varying vec4 vColor;
varying vec2 vTexCoord;
void main() {
vTexCoord = a_texCoord0;
void main() {
vColor = a_color;
vTexCoord = a_texCoord0;
gl_Position = u_projTrans * a_position;
}

View File

@@ -1,33 +1,37 @@
#ifdef GL_ES
#define LOWP lowp
precision mediump float;
#else
#define LOWP
#endif
varying LOWP vec4 vColor;
varying vec2 vTexCoord;
uniform sampler2D u_texture;
uniform float resolution;
uniform float radius;
uniform vec2 dir;
uniform vec2 vTexCoord;
void main()
{
vec4 sum = vec4(0);
vec2 texcoord = vTexCoord;
int j;
int i;
void main() {
for( i= -4 ;i < 4; i++)
{
for (j = -3; j < 3; j++)
{
sum += texture2D(u_texture, texcoord + vec2(j, i)*0.004) * 0.25;
}
}
if (texture2D(u_texture, texcoord).r < 0.3)
{
gl_FragColor = sum*sum*0.012 + texture2D(u_texture, texcoord);
}
else
{
if (texture2D(u_texture, texcoord).r < 0.5)
{
gl_FragColor = sum*sum*0.009 + texture2D(u_texture, texcoord);
}
else
{
gl_FragColor = sum*sum*0.0075 + texture2D(u_texture, texcoord);
}
}
vec4 sum = vec4(0.0);
vec2 tc = vTexCoord;
float blur = radius/resolution;
float hstep = dir.x;
float vstep = dir.y;
sum += texture2D(u_texture, vec2(tc.x - 4.0*blur*hstep, tc.y - 4.0*blur*vstep)) * 0.05;
sum += texture2D(u_texture, vec2(tc.x - 3.0*blur*hstep, tc.y - 3.0*blur*vstep)) * 0.09;
sum += texture2D(u_texture, vec2(tc.x - 2.0*blur*hstep, tc.y - 2.0*blur*vstep)) * 0.12;
sum += texture2D(u_texture, vec2(tc.x - 1.0*blur*hstep, tc.y - 1.0*blur*vstep)) * 0.15;
sum += texture2D(u_texture, vec2(tc.x, tc.y)) * 0.16;
sum += texture2D(u_texture, vec2(tc.x + 1.0*blur*hstep, tc.y + 1.0*blur*vstep)) * 0.15;
sum += texture2D(u_texture, vec2(tc.x + 2.0*blur*hstep, tc.y + 2.0*blur*vstep)) * 0.12;
sum += texture2D(u_texture, vec2(tc.x + 3.0*blur*hstep, tc.y + 3.0*blur*vstep)) * 0.09;
sum += texture2D(u_texture, vec2(tc.x + 4.0*blur*hstep, tc.y + 4.0*blur*vstep)) * 0.05;
gl_FragColor = vColor * vec4(sum.rgb, 1.0);
}

View File

@@ -4,9 +4,11 @@ attribute vec2 a_texCoord0;
uniform mat4 u_projTrans;
varying vec4 vColor;
varying vec2 vTexCoord;
void main() {
vTexCoord = a_texCoord0;
void main() {
vColor = a_color;
vTexCoord = a_texCoord0;
gl_Position = u_projTrans * a_position;
}