added simple crt shader
This commit is contained in:
parent
9a485dc06f
commit
800e6fdfb9
|
@ -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);
|
||||
}
|
|
@ -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);
|
||||
}
|
|
@ -13,7 +13,7 @@
|
|||
#include <emscripten.h>
|
||||
#endif
|
||||
|
||||
#define STUDIO_UI_SCALE 3
|
||||
#define STUDIO_UI_SCALE 4
|
||||
#define STUDIO_PIXEL_FORMAT SDL_PIXELFORMAT_ARGB8888
|
||||
#define TEXTURE_SIZE (TIC80_FULLWIDTH)
|
||||
#define OFFSET_LEFT ((TIC80_FULLWIDTH-TIC80_WIDTH)/2)
|
||||
|
@ -1120,7 +1120,7 @@ static s32 start(s32 argc, char **argv, const char* folder)
|
|||
GPU_Image* texture = GPU_CreateImage(TIC80_FULLWIDTH, TIC80_FULLHEIGHT, GPU_FORMAT_BGRA);
|
||||
|
||||
s32 color_shader = 0;
|
||||
GPU_ShaderBlock color_block = load_shader_program(&color_shader, "data/shaders/common.vert", "data/shaders/color.frag");
|
||||
GPU_ShaderBlock color_block = load_shader_program(&color_shader, "data/shaders/common.vert", "data/shaders/crt-simple.frag");
|
||||
int color_loc = GPU_GetUniformLocation(color_shader, "myColor");
|
||||
|
||||
{
|
||||
|
@ -1148,8 +1148,8 @@ static s32 start(s32 argc, char **argv, const char* folder)
|
|||
GPU_ActivateShaderProgram(color_shader, &color_block);
|
||||
update_color_shader((1+sin(t))/2, (1+sin(t+1))/2, (1+sin(t+2))/2, 1.0f, color_loc);
|
||||
|
||||
// GPU_BlitScale(texture, NULL, screen, TIC80_FULLWIDTH/2*STUDIO_UI_SCALE, TIC80_FULLHEIGHT/2*STUDIO_UI_SCALE, STUDIO_UI_SCALE, STUDIO_UI_SCALE);
|
||||
GPU_Blit(texture, NULL, screen, TIC80_FULLWIDTH/2*STUDIO_UI_SCALE, TIC80_FULLHEIGHT/2*STUDIO_UI_SCALE);
|
||||
GPU_BlitScale(texture, NULL, screen, TIC80_FULLWIDTH/2*STUDIO_UI_SCALE, TIC80_FULLHEIGHT/2*STUDIO_UI_SCALE, STUDIO_UI_SCALE, STUDIO_UI_SCALE);
|
||||
// GPU_Blit(texture, NULL, screen, TIC80_FULLWIDTH/2*STUDIO_UI_SCALE, TIC80_FULLHEIGHT/2*STUDIO_UI_SCALE);
|
||||
|
||||
GPU_Flip(screen);
|
||||
|
||||
|
|
Loading…
Reference in New Issue