added simple crt shader
This commit is contained in:
		@@ -1,22 +0,0 @@
 | 
			
		||||
 | 
			
		||||
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);
 | 
			
		||||
}
 | 
			
		||||
							
								
								
									
										23
									
								
								data/shaders/crt-simple.frag
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										23
									
								
								data/shaders/crt-simple.frag
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,23 @@
 | 
			
		||||
varying vec4 color;
 | 
			
		||||
varying vec2 texCoord;
 | 
			
		||||
 | 
			
		||||
uniform sampler2D tex;
 | 
			
		||||
uniform vec4 myColor;
 | 
			
		||||
 | 
			
		||||
out vec4 fragColor;
 | 
			
		||||
 | 
			
		||||
void main(void)
 | 
			
		||||
{
 | 
			
		||||
    vec4 c = myColor * color;
 | 
			
		||||
 | 
			
		||||
	vec4 rgba = texture2D(tex, texCoord);
 | 
			
		||||
    vec4 intensity;
 | 
			
		||||
 | 
			
		||||
  if(fract(gl_FragCoord.y * (0.5 * 4.0 / 3.0)) > 0.5) {
 | 
			
		||||
    intensity = vec4(0);
 | 
			
		||||
  } else {
 | 
			
		||||
    intensity = smoothstep(0.2, 0.8, rgba) + normalize(rgba);
 | 
			
		||||
  }
 | 
			
		||||
  
 | 
			
		||||
    fragColor = intensity * -0.25 + rgba * 1.1;
 | 
			
		||||
}
 | 
			
		||||
@@ -1,51 +0,0 @@
 | 
			
		||||
 | 
			
		||||
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;
 | 
			
		||||
}
 | 
			
		||||
@@ -1,8 +0,0 @@
 | 
			
		||||
#version 120
 | 
			
		||||
 | 
			
		||||
varying vec4 color;
 | 
			
		||||
 | 
			
		||||
void main(void)
 | 
			
		||||
{
 | 
			
		||||
    gl_FragColor = color;
 | 
			
		||||
}
 | 
			
		||||
@@ -1,13 +0,0 @@
 | 
			
		||||
#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);
 | 
			
		||||
}
 | 
			
		||||
		Reference in New Issue
	
	Block a user