Browse Source

glsl letterbox and round corner & some new fancy animation!

master
parent
commit
e1441b8be0
3 changed files with 24 additions and 21 deletions
  1. +10
    -7
      neercs/neercs.cpp
  2. +6
    -6
      neercs/video/postfx.lolfx
  3. +8
    -8
      neercs/video/render.cpp

+ 10
- 7
neercs/neercs.cpp View File

@@ -86,6 +86,7 @@ void Neercs::TickGame(float seconds)
float a = m_time * 1 + M_PI / 180 * i * 8; float a = m_time * 1 + M_PI / 180 * i * 8;
float b = m_time * -2 + M_PI / 180 * i * 5; float b = m_time * -2 + M_PI / 180 * i * 5;
int y = h / 2 + h / 4 * lol::cos(a) + h / 4 * lol::sin(b); int y = h / 2 + h / 4 * lol::cos(a) + h / 4 * lol::sin(b);
caca_set_color_argb(m_caca, hex_color(0.25f + 0.5f / w * i - 0.25f / h * y, 0.25f, 0.25f + 0.25f / w * i + 0.25f / h * y), bg_color);
caca_draw_line(m_caca, i, y - 1, i, y + 1,'%'); caca_draw_line(m_caca, i, y - 1, i, y + 1,'%');
} }


@@ -99,21 +100,23 @@ void Neercs::TickGame(float seconds)
int logo_x = (w - 45) / 2; int logo_x = (w - 45) / 2;
int logo_y = h / 2 - 2; int logo_y = h / 2 - 2;


caca_set_color_argb(m_caca, hex_color(0.5f + 0.375f * lol::cos(m_time * 3 ),0.5f,0.5f + 0.25f * lol::sin(m_time * 3 )), bg_color);
caca_set_color_argb(m_caca, hex_color(0.5f + 0.5f * lol::cos(m_time * 3 ), 0.5f, 0.5f + 0.25f * lol::sin(m_time * 3 )), bg_color);
caca_put_str(m_caca, logo_x, logo_y ,".___ __ ______ ______ ______ ______ ______,"); caca_put_str(m_caca, logo_x, logo_y ,".___ __ ______ ______ ______ ______ ______,");
caca_set_color_argb(m_caca, hex_color(0.5f + 0.375f * lol::cos(m_time * 3 + M_PI / 4 * 1),0.5f,0.5f + 0.25f * lol::sin(m_time * 3 + M_PI / 4 * 1)), bg_color);
caca_set_color_argb(m_caca, hex_color(0.5f + 0.5f * lol::cos(m_time * 3 + M_PI / 4 * 1), 0.5f, 0.5f + 0.25f * lol::sin(m_time * 3 + M_PI / 4 * 1)), bg_color);
caca_put_str(m_caca, logo_x, logo_y + 1, " \\° \\| /° __ \\° __ \\° __ \\/° ___//° ___/"); caca_put_str(m_caca, logo_x, logo_y + 1, " \\° \\| /° __ \\° __ \\° __ \\/° ___//° ___/");
caca_set_color_argb(m_caca, hex_color(0.5f + 0.375f * lol::cos(m_time * 3 + M_PI / 4 * 2),0.5f,0.5f + 0.25f * lol::sin(m_time * 3 + M_PI / 4 * 2)), bg_color);
caca_set_color_argb(m_caca, hex_color(0.5f + 0.5f * lol::cos(m_time * 3 + M_PI / 4 * 2), 0.5f, 0.5f + 0.25f * lol::sin(m_time * 3 + M_PI / 4 * 2)), bg_color);
caca_put_str(m_caca, logo_x, logo_y + 2, " / ` > ____/ ____/ ,_ <_ <____\\___ \\"); caca_put_str(m_caca, logo_x, logo_y + 2, " / ` > ____/ ____/ ,_ <_ <____\\___ \\");
caca_set_color_argb(m_caca, hex_color(0.5f + 0.375f * lol::cos(m_time * 3 + M_PI / 4 * 3),0.5f,0.5f + 0.25f * lol::sin(m_time * 3 + M_PI / 4 * 3)), bg_color);
caca_set_color_argb(m_caca, hex_color(0.5f + 0.5f * lol::cos(m_time * 3 + M_PI / 4 * 3), 0.5f, 0.5f + 0.25f * lol::sin(m_time * 3 + M_PI / 4 * 3)), bg_color);
caca_put_str(m_caca, logo_x, logo_y + 3, "/__/\\___\\______\\______\\__| \\__/_____________\\"); caca_put_str(m_caca, logo_x, logo_y + 3, "/__/\\___\\______\\______\\__| \\__/_____________\\");
caca_set_color_argb(m_caca, 0xdef, bg_color); caca_set_color_argb(m_caca, 0xdef, bg_color);
caca_put_str(m_caca, logo_x + 5, logo_y + 5, "ALL YOUR TERMINALS ARE BELONG TO US"); caca_put_str(m_caca, logo_x + 5, logo_y + 5, "ALL YOUR TERMINALS ARE BELONG TO US");


caca_set_color_argb(m_caca, 0x666, bg_color); caca_set_color_argb(m_caca, 0x666, bg_color);
caca_put_str(m_caca, w - 10, h - 1, "CACA RULEZ");
caca_printf(m_caca, 0, h - 2, "W=%i", w);
caca_printf(m_caca, 0, h - 1, "H=%i", h);
caca_printf(m_caca, 2, h - 3, "W=%i", w);
caca_printf(m_caca, 2, h - 2, "H=%i", h);

caca_set_color_argb(m_caca, hex_color(0.6f + 0.4f * lol::cos(m_time * 2), 0.125f, 0.125f), bg_color);
caca_put_str(m_caca, w - 12, h - 2, "CACA RULEZ");
} }






+ 6
- 6
neercs/video/postfx.lolfx View File

@@ -27,7 +27,7 @@ float lens=deform+sync*0.0625;
vec2 zoom(in vec2 p,in float radius) vec2 zoom(in vec2 p,in float radius)
{ {
float zoom=1.5-(radius*cos(p.x*lens)+radius*cos(p.y*lens)); float zoom=1.5-(radius*cos(p.x*lens)+radius*cos(p.y*lens));
return vec2(p.x*zoom-0.5,p.y*zoom-0.5);
return p*zoom-0.5;
} }


vec3 get_color(in sampler2D tex,in vec2 p) vec3 get_color(in sampler2D tex,in vec2 p)
@@ -37,7 +37,7 @@ vec3 get_color(in sampler2D tex,in vec2 p)


float rand(in vec2 p) float rand(in vec2 p)
{ {
return fract(sin(dot(p.xy,vec2(12.9898,78.233)))*43758.5453);
return fract(sin(dot(p,vec2(12.9898,78.233)))*43758.5453);
} }


float letterbox(in vec2 p,in float radius,in float smooth) float letterbox(in vec2 p,in float radius,in float smooth)
@@ -82,16 +82,16 @@ void main(void)
{ {
color-=0.0125*mod(z.y*4.0+time*0.25,1.0); // electron beam color-=0.0125*mod(z.y*4.0+time*0.25,1.0); // electron beam
color-=(vec3(rnd1,rnd1,rnd1)-vec3(rnd2,rnd2,rnd2))*0.1; // noise color-=(vec3(rnd1,rnd1,rnd1)-vec3(rnd2,rnd2,rnd2))*0.1; // noise
color*=0.75+0.25*sin(z.x*float(screen_size.x*2)); // scanline w
color*=0.90+0.10*cos(z.y*float(screen_size.y))*sin(0.5+z.x*float(screen_size.x)); // scanline h
color*=0.75+0.25*cos(z.x*float(screen_size.x*2))*sin(0.5+z.y*float(screen_size.y)); // scanline w
color*=0.75+0.50*sin(z.y*float(screen_size.y*2)); // scanline h
} }
else else
{ {
color*=0.675; color*=0.675;
} }
color=vec3(color.x*0.875,color.y*1.25,color.z*0.5);
color=vec3(color.x*0.75,color.y*1.0,color.z*0.5);
color*=q.x*(6.0-q.x*6.0)*q.y*(6.0-q.y*6.0); // vignetting color*=q.x*(6.0-q.x*6.0)*q.y*(6.0-q.y*6.0); // vignetting
//color*=2.0*letterbox(z,-0.75,0.125)*2.0; // vignetting //color*=2.0*letterbox(z,-0.75,0.125)*2.0; // vignetting
color*=letterbox(z,-0.75,0.975); // letterbox
color*=letterbox(z,-0.75,0.95); // letterbox
gl_FragColor=vec4(color,1.0); gl_FragColor=vec4(color,1.0);
} }

+ 8
- 8
neercs/video/render.cpp View File

@@ -83,7 +83,7 @@ float beat_speed = 2.0f; // speed
/* window variable */ /* window variable */
ivec2 border; // border width ivec2 border; // border width
/* text variable */ /* text variable */
ivec2 ratio_2d(2,4); // 2d ratio
ivec2 ratio_2d(1,3); // 2d ratio
ivec2 map_size(256,256); // texture map size ivec2 map_size(256,256); // texture map size
ivec2 font_size(8,8); // font size ivec2 font_size(8,8); // font size
ivec2 canvas_char(0,0); // canvas char number ivec2 canvas_char(0,0); // canvas char number
@@ -99,7 +99,7 @@ float radial_value1 = 2.0f;
float radial_value2 = 0.8f; float radial_value2 = 0.8f;
float radial_color = 0; // color float radial_color = 0; // color
bool postfx_scanline = true; bool postfx_scanline = true;
float postfx_deform = 0.625f; // deformation ratio
float postfx_deform = 0.825f; // deformation ratio


Shader *shader_simple, *shader_blur_h, *shader_blur_v; Shader *shader_simple, *shader_blur_h, *shader_blur_v;
Shader *shader_glow, *shader_radial, *shader_postfx; Shader *shader_glow, *shader_radial, *shader_postfx;
@@ -229,7 +229,7 @@ int Render::InitDraw(void)
int Render::CreateGLWindow() int Render::CreateGLWindow()
{ {
screen_size = Video::GetSize(); screen_size = Video::GetSize();
border = 18 * ratio_2d;
border = 24 * ratio_2d;
border.y = border.x; // enabled to get same border everywhere border.y = border.x; // enabled to get same border everywhere
canvas_char = (screen_size - border * 2) / (font_size * ratio_2d); canvas_char = (screen_size - border * 2) / (font_size * ratio_2d);
canvas_size = canvas_char * font_size * ratio_2d; canvas_size = canvas_char * font_size * ratio_2d;
@@ -247,7 +247,7 @@ Render::Render(caca_canvas_t *caca)
m_ready(false), m_ready(false),
m_pause(false), m_pause(false),
m_polygon(true), m_polygon(true),
m_shader(false),
m_shader(true),
m_shader_blur(true), m_shader_blur(true),
m_shader_glow(true), m_shader_glow(true),
m_shader_fx(true), m_shader_fx(true),
@@ -442,7 +442,7 @@ void Render::Draw3D()
shader_blur_h->SetTexture(shader_blur_h_texture, fbo_ping->GetTexture(), 0); shader_blur_h->SetTexture(shader_blur_h_texture, fbo_ping->GetTexture(), 0);
shader_blur_h->SetUniform(shader_blur_h_screen_size, vec2(1.0f / glow_fbo_size)); shader_blur_h->SetUniform(shader_blur_h_screen_size, vec2(1.0f / glow_fbo_size));
shader_blur_h->SetUniform(shader_blur_h_time, fx_angle); shader_blur_h->SetUniform(shader_blur_h_time, fx_angle);
shader_blur_h->SetUniform(shader_blur_h_value, 2.5f/screen_size.x);
shader_blur_h->SetUniform(shader_blur_h_value, 2.25f / screen_size.x);
fs_quad(); fs_quad();
shader_blur_h->Unbind(); shader_blur_h->Unbind();
fbo_blur_h->Unbind(); fbo_blur_h->Unbind();
@@ -452,7 +452,7 @@ void Render::Draw3D()
shader_blur_v->SetTexture(shader_blur_v_texture, fbo_blur_h->GetTexture(), 0); shader_blur_v->SetTexture(shader_blur_v_texture, fbo_blur_h->GetTexture(), 0);
shader_blur_v->SetUniform(shader_blur_v_screen_size, vec2(1.0f / glow_fbo_size)); shader_blur_v->SetUniform(shader_blur_v_screen_size, vec2(1.0f / glow_fbo_size));
shader_blur_v->SetUniform(shader_blur_v_time, fx_angle); shader_blur_v->SetUniform(shader_blur_v_time, fx_angle);
shader_blur_v->SetUniform(shader_blur_h_value, 2.5f/screen_size.y);
shader_blur_v->SetUniform(shader_blur_h_value, 2.25f / screen_size.y);
fs_quad(); fs_quad();
shader_blur_v->Unbind(); shader_blur_v->Unbind();
fbo_blur_v->Unbind(); fbo_blur_v->Unbind();
@@ -462,7 +462,7 @@ void Render::Draw3D()
shader_blur_h->SetTexture(shader_blur_h_texture, fbo_blur_v->GetTexture(), 0); shader_blur_h->SetTexture(shader_blur_h_texture, fbo_blur_v->GetTexture(), 0);
shader_blur_h->SetUniform(shader_blur_h_screen_size, vec2(1.0f / glow_fbo_size)); shader_blur_h->SetUniform(shader_blur_h_screen_size, vec2(1.0f / glow_fbo_size));
shader_blur_h->SetUniform(shader_blur_h_time, fx_angle); shader_blur_h->SetUniform(shader_blur_h_time, fx_angle);
shader_blur_h->SetUniform(shader_blur_h_value, 1.0f/screen_size.x);
shader_blur_h->SetUniform(shader_blur_h_value, 1.0f / screen_size.x);
fs_quad(); fs_quad();
shader_blur_h->Unbind(); shader_blur_h->Unbind();
fbo_blur_h->Unbind(); fbo_blur_h->Unbind();
@@ -472,7 +472,7 @@ void Render::Draw3D()
shader_blur_v->SetTexture(shader_blur_v_texture, fbo_blur_h->GetTexture(), 0); shader_blur_v->SetTexture(shader_blur_v_texture, fbo_blur_h->GetTexture(), 0);
shader_blur_v->SetUniform(shader_blur_v_screen_size, vec2(1.0f / glow_fbo_size)); shader_blur_v->SetUniform(shader_blur_v_screen_size, vec2(1.0f / glow_fbo_size));
shader_blur_v->SetUniform(shader_blur_v_time, fx_angle); shader_blur_v->SetUniform(shader_blur_v_time, fx_angle);
shader_blur_v->SetUniform(shader_blur_h_value, 1.0f/screen_size.y);
shader_blur_v->SetUniform(shader_blur_h_value, 1.0f / screen_size.y);
fs_quad(); fs_quad();
shader_blur_v->Unbind(); shader_blur_v->Unbind();
fbo_blur_v->Unbind(); fbo_blur_v->Unbind();


Loading…
Cancel
Save