fbo functioning

This commit is contained in:
2017-07-19 16:04:43 -05:00
parent 5f1958e62d
commit 942cd9f102
8 changed files with 99 additions and 80 deletions

38
android/assets/shaders/glow.fsh Executable file
View File

@@ -0,0 +1,38 @@
#ifdef GL_ES
#define LOWP lowp
precision mediump float;
#else
#define LOWP
#endif
varying LOWP vec4 vColor;
varying vec2 vTexCoord;
uniform sampler2D u_texture;
void main() {
vec4 sum = vec4(0);
vec2 texcoord = vTexCoord;
int j;
int i;
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 = vec4(sum * sum * 0.012 + texture2D(u_texture, texcoord))
* vColor;
} else {
if (texture2D(u_texture, texcoord).r < 0.5) {
gl_FragColor = vec4(
sum * sum * 0.009 + texture2D(u_texture, texcoord))
* vColor;
} else {
gl_FragColor = vec4(
sum * sum * 0.0075 + texture2D(u_texture, texcoord))
* vColor;
}
}
}

View File

@@ -1,42 +0,0 @@
#ifdef GL_ES
#define LOWP lowp
precision mediump float;
#else
#define LOWP
#endif
varying LOWP vec4 vColor;
varying vec2 vTexCoord;
uniform sampler2D u_texture;
void main()
{
vec4 sum = vec4(0);
vec2 texcoord = vTexCoord;
int j;
int i;
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);
}
}
}

View File

@@ -1,17 +0,0 @@
#ifdef GL_ES
#define LOWP lowp
precision mediump float;
#else
#define LOWP
#endif
varying LOWP vec4 vColor;
varying vec2 vTexCoord;
uniform sampler2D u_texture;
void main() {
vec4 texColor = texture2D(u_texture, vTexCoord);
texColor.rgb = 1.0 - texColor.rgb;
gl_FragColor = texColor * vColor;
}

View File

@@ -1,15 +0,0 @@
attribute vec4 a_position;
attribute vec4 a_color;
attribute vec2 a_texCoord0;
uniform mat4 u_projTrans;
uniform vec2 mouse;
varying vec4 vColor;
varying vec2 vTexCoord;
void main() {
vColor = a_color;
vTexCoord = a_texCoord0;
gl_Position = u_projTrans * a_position;
}