progress on asset management system

This commit is contained in:
2018-09-12 01:32:05 -05:00
parent 8d80913fe2
commit 419fb6ab6b
76 changed files with 918 additions and 14 deletions

View File

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

View File

@@ -0,0 +1,22 @@
#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 color = texture(u_texture, vTexCoord);
float brightness = (color.r*0.2126) + (color.g*0.7152) + (color.b * 0.0722);
if (brightness > 0.6) {
gl_FragColor = color *0.75;
} else {
gl_FragColor = vec4(0.0);
}
}

View File

@@ -0,0 +1,27 @@
#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 sampler2D u_texture1;
void main() {
vec4 origColor = texture2D(u_texture, vTexCoord);
vec4 blurredColor = texture2D(u_texture1, vTexCoord);
vec4 result;
result = origColor + blurredColor;
result.a = vColor.a;
result.rgb *= vColor.rgb;
gl_FragColor = result;
}

View File

@@ -0,0 +1,45 @@
varying vec4 vColor;
varying vec2 vTexCoord;
uniform sampler2D u_texture;
uniform vec2 resolution;
uniform float radius;
uniform int pass;
void main() {
//this will be our RGBA sum
vec4 sum = vec4(0.0);
//our original texcoord for this fragment
vec2 tc = vTexCoord;
//the amount to blur, i.e. how far off center to sample from
//1.0 -> blur by one pixel
//2.0 -> blur by two pixels, etc.
float blur = radius/resolution.y;
//the direction of our blur
//(1.0, 0.0) -> x-axis blur
//(0.0, 1.0) -> y-axis blur
float hstep = 1.0;
float vstep = 0.0;
if (pass == 1) {
hstep = 0.0;
vstep = 1.0;
}
sum += texture2D(u_texture, vec2(tc.x - 5.0*blur*hstep, tc.y - 5.0*blur*vstep)) * 0.014374;
sum += texture2D(u_texture, vec2(tc.x - 4.0*blur*hstep, tc.y - 4.0*blur*vstep)) * 0.035855;
sum += texture2D(u_texture, vec2(tc.x - 3.0*blur*hstep, tc.y - 3.0*blur*vstep)) * 0.072994;
sum += texture2D(u_texture, vec2(tc.x - 2.0*blur*hstep, tc.y - 2.0*blur*vstep)) * 0.121281;
sum += texture2D(u_texture, vec2(tc.x - 1.0*blur*hstep, tc.y - 1.0*blur*vstep)) * 0.164472;
sum += texture2D(u_texture, vec2(tc.x + 1.0*blur*hstep, tc.y + 1.0*blur*vstep)) * 0.164472;
sum += texture2D(u_texture, vec2(tc.x + 2.0*blur*hstep, tc.y + 2.0*blur*vstep)) * 0.121281;
sum += texture2D(u_texture, vec2(tc.x + 3.0*blur*hstep, tc.y + 3.0*blur*vstep)) * 0.072994;
sum += texture2D(u_texture, vec2(tc.x + 4.0*blur*hstep, tc.y + 4.0*blur*vstep)) * 0.035855;
sum += texture2D(u_texture, vec2(tc.x + 5.0*blur*hstep, tc.y + 5.0*blur*vstep)) * 0.014374;
gl_FragColor = sum;
}

View File

@@ -0,0 +1,10 @@
#ifdef GL_ES
precision mediump float;
#endif
//input from vertex shader
varying vec4 vColor;
void main() {
gl_FragColor = vColor;
}

View File

@@ -0,0 +1,13 @@
attribute vec2 a_position;
attribute vec4 a_color;
//our camera matrix
uniform mat4 u_projTrans;
//send the color out to the fragment shader
varying vec4 vColor;
void main() {
vColor = a_color;
gl_Position = u_projTrans * vec4(a_position.xy, 0.0, 1.0);
}