no message

This commit is contained in:
BADIM-PC\Vadim
2018-02-19 23:03:35 +03:00
parent e2d987a208
commit 9a485dc06f
8 changed files with 269 additions and 32 deletions

View File

@@ -0,0 +1,22 @@
in vec4 color;
in vec2 texCoord;
out vec4 fragColor;
uniform sampler2D tex;
uniform sampler2D mask_tex;
uniform float offset_x;
uniform float offset_y;
uniform float resolution_x;
uniform float resolution_y;
uniform float mask_resolution_x;
uniform float mask_resolution_y;
void main(void)
{
vec4 col = texture2D(tex, texCoord);
vec2 mask_coords = vec2((texCoord.x*resolution_x + offset_x)/mask_resolution_x, (texCoord.y*resolution_y + offset_y)/mask_resolution_y);
vec4 mask = texture2D(mask_tex, mask_coords);
fragColor = vec4(col.rgb, col.a*mask.a);
}

11
data/shaders/color.frag Normal file
View File

@@ -0,0 +1,11 @@
varying vec4 color;
varying vec2 texCoord;
uniform sampler2D tex;
uniform vec4 myColor;
void main(void)
{
vec4 c = myColor * color;
gl_FragColor = texture2D(tex, texCoord) * c;
}

11
data/shaders/common.frag Normal file
View File

@@ -0,0 +1,11 @@
in vec4 color;
in vec2 texCoord;
out vec4 fragColor;
uniform sampler2D tex;
void main(void)
{
fragColor = texture2D(tex, texCoord) * color;
}

14
data/shaders/common.vert Normal file
View File

@@ -0,0 +1,14 @@
attribute vec3 gpu_Vertex;
attribute vec2 gpu_TexCoord;
attribute vec4 gpu_Color;
uniform mat4 gpu_ModelViewProjectionMatrix;
varying vec4 color;
varying vec2 texCoord;
void main(void)
{
color = gpu_Color;
texCoord = vec2(gpu_TexCoord);
gl_Position = gpu_ModelViewProjectionMatrix * vec4(gpu_Vertex, 1.0);
}

View File

@@ -0,0 +1,51 @@
in vec4 color;
in vec2 texCoord;
out vec4 fragColor;
uniform sampler2D tex;
uniform float resolution_x;
uniform float resolution_y;
uniform float screen_w;
uniform float screen_h;
uniform float time;
uniform float zoom;
void main(void)
{
float x_offset = 1.0/(screen_w*zoom) + 1.0/(resolution_x*zoom);
float y_offset = 1.0/(screen_h*zoom) + 1.0/(resolution_y*zoom);
vec4 center = texture2D(tex, texCoord);
vec4 left = texture2D(tex, vec2(texCoord.s - x_offset, texCoord.t));
vec4 right = texture2D(tex, vec2(texCoord.s + x_offset, texCoord.t));
vec4 up = texture2D(tex, vec2(texCoord.s, texCoord.t - y_offset));
vec4 down = texture2D(tex, vec2(texCoord.s, texCoord.t + y_offset));
bool is_image_edge = (texCoord.s - x_offset < 0 || texCoord.s + x_offset > 1 || texCoord.t - y_offset < 0 || texCoord.t + y_offset > 1);
if(left.a != right.a || left.a != up.a || left.a != down.a || (center.a > 0.5 && is_image_edge))
{
if(center.a > 0.5)
{
float speed = 0.6;
float ant_size = 10;
float black_to_white_ratio = 0.5;
float ant_position = (gl_FragCoord.x + gl_FragCoord.y);
float t = step(black_to_white_ratio, mod(time*speed + ant_position/ant_size, 1.0));
fragColor = vec4(t, t, t, 1);
}
else
fragColor = vec4(1, 1, 1, 1);
}
else if(center.a < 0.5)
{
fragColor = vec4(0, 0, 0, 0.1);
}
else
discard;
}

View File

@@ -0,0 +1,8 @@
#version 120
varying vec4 color;
void main(void)
{
gl_FragColor = color;
}

View File

@@ -0,0 +1,13 @@
#version 120
attribute vec3 gpu_Vertex;
attribute vec4 gpu_Color;
uniform mat4 gpu_ModelViewProjectionMatrix;
varying vec4 color;
void main(void)
{
color = gpu_Color;
gl_Position = gpu_ModelViewProjectionMatrix * vec4(gpu_Vertex, 1.0);
}