浏览代码

neercs: added a protection glass above the monitor

master
父节点
当前提交
8b9b07f593
共有 4 个文件被更改,包括 56 次插入34 次删除
  1. +8
    -16
      neercs/term/term.cpp
  2. +4
    -4
      neercs/video/mirror.lolfx
  3. +14
    -8
      neercs/video/postfx.lolfx
  4. +30
    -6
      neercs/video/render.cpp

+ 8
- 16
neercs/term/term.cpp 查看文件

@@ -149,7 +149,6 @@ void Term::TickGame(float seconds)

if (m_debug)
{
m_time += seconds;
DrawFancyShit();
}
#else
@@ -186,7 +185,7 @@ static uint32_t hex_color(float r, float g, float b)
void Term::DrawFancyShit()
{
/* draw something awesome */
int bg_color = 0x222;
int bg_color = 0x000;
int w = caca_get_canvas_width(m_caca);
int h = caca_get_canvas_height(m_caca);

@@ -221,13 +220,9 @@ void Term::DrawFancyShit()
int logo_y = h / 2 - 2;

caca_set_color_argb(m_caca, 0xbac, 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 + 3, logo_y ,"__ _________ ______ ______ ______ ______");
//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 + 2, logo_y + 1, "/ \\/ / __ > __ > __ > ___// ___/ \x0a9");
//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 + 1, logo_y + 2, "/ / ____/ ____/ __ < <____\\___ \\");
//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_set_color_argb(m_caca, 0x269, bg_color);
caca_put_str(m_caca, logo_x + 5, logo_y + 5, "ALL YOUR TERMINALS ARE BELONG TO US");
@@ -246,22 +241,19 @@ void Term::DrawFancyShit()
| :D | /
|______|/
*/
/*
int lolcube_x = w - 12;
int lolcube_y = h - 8;

int lolcube_x = w / 2 - 5 + (w - 10) * lol::cos(m_time / 2);
int lolcube_y = h - 5 - abs ((h - 5) * lol::sin(m_time * 4));

caca_set_color_argb(m_caca, hex_color(0.5f + 0.5f * lol::sin(m_time * 2), 0.5f + 0.5f * lol::cos(m_time * 3), 0.5f + 0.5f * lol::sin(m_time * 5)), bg_color);
caca_set_color_argb(m_caca, 0x777, bg_color);
caca_put_str(m_caca, lolcube_x + 2, lolcube_y , "_______");
caca_put_str(m_caca, lolcube_x + 1, lolcube_y + 1, "/ /|");
caca_put_str(m_caca, lolcube_x , lolcube_y + 2, "/______/ |");
caca_put_str(m_caca, lolcube_x , lolcube_y + 3, "| | |");
caca_put_str(m_caca, lolcube_x , lolcube_y + 4, "| :D | /");
caca_put_str(m_caca, lolcube_x , lolcube_y + 5, "|______|/");
*/

caca_set_color_argb(m_caca, 0x777, bg_color);
caca_put_str(m_caca, 0, 0, "rez@lol:~/ sudo -s");
caca_put_str(m_caca, 0, 1, "[sudo] password for rez:");
caca_put_str(m_caca, 0, 2, "root@lol:~/ echo LOL");
caca_put_str(m_caca, 0, 3, "LOL");
caca_put_str(m_caca, 0, 4, "root@lol:~/");
}
caca_put_str(m_caca, 0, 0, "rez@lol:~/code/neercs/");
}

+ 4
- 4
neercs/video/mirror.lolfx 查看文件

@@ -22,10 +22,10 @@ void main(void)
vec3 s = texture2D(texture, p).xyz;

vec3 c = vec3(0.0);
if(p.x < mirror.x) c += (texture2D(texture, vec2(mirror.x + (mirror.x - p.x) * mirror.w, p.y * (0.8 + 2.0 * p.x) + 0.1 - 1.0 * p.x)).xyz) * (mirror.z / mirror.x * p.x);
if(p.x > 1.0 - mirror.x) c += (texture2D(texture, vec2(- mirror.x - (mirror.x + p.x) * mirror.w, p.y * (0.8 + 2.0 * (1.0 - p.x)) + 0.1 - 1.0 * (1.0 - p.x))).xyz) * (mirror.z / mirror.x * (1.0 - p.x));
if(p.y < mirror.y) c += (texture2D(texture, vec2(p.x * (0.8 + 2.0 * p.y) + 0.1 - 1.0 * p.y, mirror.y + (mirror.y - p.y) * mirror.w)).xyz) * (mirror.z / mirror.y * p.y);
if(p.y > 1.0 - mirror.y) c += (texture2D(texture, vec2(p.x * (0.8 + 2.0 * (1.0 - p.y)) + 0.1 - 1.0 * (1.0 - p.y), - mirror.y - (mirror.y + p.y) * mirror.w)).xyz) * (mirror.z / mirror.y * (1.0 - p.y));
if(p.x < mirror.x) c += texture2D(texture, vec2(mirror.x + (mirror.x - p.x) * mirror.w, p.y * (0.8 + 2.0 * p.x) + 0.1 - 1.0 * p.x)).xyz * (mirror.z / mirror.x * p.x);
if(p.x > 1.0 - mirror.x) c += texture2D(texture, vec2(- mirror.x - (mirror.x + p.x) * mirror.w, p.y * (0.8 + 2.0 * (1.0 - p.x)) + 0.1 - 1.0 * (1.0 - p.x))).xyz * (mirror.z / mirror.x * (1.0 - p.x));
if(p.y < mirror.y) c += texture2D(texture, vec2(p.x * (0.8 + 2.0 * p.y) + 0.1 - 1.0 * p.y, mirror.y + (mirror.y - p.y) * mirror.w)).xyz * (mirror.z / mirror.y * p.y);
if(p.y > 1.0 - mirror.y) c += texture2D(texture, vec2(p.x * (0.8 + 2.0 * (1.0 - p.y)) + 0.1 - 1.0 * (1.0 - p.y), - mirror.y - (mirror.y + p.y) * mirror.w)).xyz * (mirror.z / mirror.y * (1.0 - p.y));

gl_FragColor = vec4(s + c, 1.0);
}

+ 14
- 8
neercs/video/postfx.lolfx 查看文件

@@ -19,6 +19,7 @@ uniform float time;
uniform vec2 deform;
uniform vec4 ghost1;
uniform vec4 ghost2;
uniform vec4 glass;
uniform float vignetting;
uniform float aberration;
uniform vec4 moire_h;
@@ -29,9 +30,9 @@ uniform vec3 corner;
uniform float sync;
uniform float beat;

vec2 screen(in vec2 p,in float radius)
vec2 screen(in vec2 p,in float bend,in float radius)
{
float d=deform.x+sync*0.0625+beat*0.0375;
float d=bend+sync*0.0625+beat*0.0375;
return p*(1.5-(radius*cos(p.x*d)+radius*cos(p.y*d)))-0.5;
}

@@ -50,18 +51,22 @@ void main(void)
vec2 q=gl_FragCoord.xy/screen_size.xy;
vec2 p=-1.0+2.0*gl_FragCoord.xy/screen_size.xy;
p.y+=0.025*sync;
vec2 z=screen(p,deform.y);
vec2 z1=screen(p,deform.y+ghost1.z*0.01);
vec2 z2=screen(p,deform.y+ghost2.z*0.01);
vec2 z=screen(p,deform.x,deform.y);
vec2 z1=screen(p,deform.x,deform.y+ghost1.z);
vec2 z2=screen(p,deform.x,deform.y+ghost2.z);
vec2 z3=screen(p,glass.w,deform.y+glass.x-glass.y);
vec2 z4=screen(p,glass.w,deform.y+glass.x+glass.y);
float mask=q.x*(6.0-q.x*6.0)*q.y*(6.0-q.y*6.0);

vec3 source=get_color(texture,z);
vec3 g1=get_color(texture,z1-ghost1.xy*0.01);
vec3 g2=get_color(texture,z2-ghost2.xy*0.01);
vec3 g1=get_color(texture,z1-ghost1.xy);
vec3 g2=get_color(texture,z2-ghost2.xy);
vec3 g3=get_color(texture,z3);
vec3 g4=get_color(texture,z4);

vec3 c=source+g1*ghost1.w+g2*ghost2.w; // mix

float v=aberration/float(screen_size.x/ratio_2d.x);//+aberration/float(screen_size.x)*(2.0-mask);
float v=aberration/float(screen_size.x/ratio_2d.x); //+aberration/float(screen_size.x)*(2.0-mask);
vec3 ca1=get_color(texture,vec2(z.x-v,z.y));
vec3 ca2=get_color(texture,vec2(z.x+v,z.y));
c+=vec3(ca1.x,c.y,ca2.z); // chromatic aberration
@@ -88,5 +93,6 @@ void main(void)
c+=r*0.05; // reflection
c*=mix(1.0,mask,vignetting); // vignetting
c*=letterbox(z,corner.x+2.0,corner.y,corner.z); // corner
c+=(g3+g4)*glass.z; // glass
gl_FragColor=vec4(c,1.0);
}

+ 30
- 6
neercs/video/render.cpp 查看文件

@@ -112,13 +112,14 @@ float postfx_vignetting = 0.5f; // vignetting strength
float postfx_aberration = 4.0f; // chromatic aberration
vec4 postfx_ghost1(1.0f,0.0f,0.0f,-0.25f); // ghost picture 1 [position x,position y,position z,strength]
vec4 postfx_ghost2(1.5f,0.0f,0.0f,0.25f); // ghost picture 2 [position x,position y,position z,strength]
vec4 postfx_glass(8.0f,0.25f,0.75f,0.2f); // glass [depth,thickness,strength,deform ratio]
vec4 postfx_moire_h(0.75f,-0.25f,0.0f,1.0f); // vertical moire [base,variable,repeat,shift]
vec4 postfx_moire_v(0.75f,-0.25f,1.0f,1.5f); // horizontal moire [base,variable,repeat,shift]
vec4 postfx_moire_v(0.75f,-0.25f,1.0f,2.0f); // horizontal moire [base,variable,repeat,shift]
vec4 postfx_scanline_h(1.0f,0.0f,0.0f,0.0f); // vertical scanline [base,variable,repeat,shift]
vec4 postfx_scanline_v(0.75f,-0.25f,2.0f,0.0f); // horizontal scanline [base,variable,repeat,shift]
vec3 postfx_corner(0.0f,0.8f,0.96f); // corner [width,radius,blur]
vec4 mirror(0.95f,0.9f,0.4f,4.0f); // mirror [width,height,strength,ratio]
vec4 radial(4.0f,0.9f,16,0.5f); // radial [distance,fade ratio,iteration,strength]
vec4 radial(4.0f,0.9f,16,0.25f); // radial [distance,fade ratio,iteration,strength]
/* text variable */
ivec2 ratio_2d(2,3); // 2d ratio
ivec2 map_size(256,256); // texture map size
@@ -132,7 +133,7 @@ int setup_n = 0; // item/option number
int setup_h = 8; // height
int setup_cursor = 0; // cursor position
int setup_option_i = 0; // selected option
int setup_option_n = 13; // option number
int setup_option_n = 14; // option number
int setup_option_p = 0; // option position
int setup_item_i = 0; // selected item
int setup_item_n = 8; // item number
@@ -223,6 +224,15 @@ char const *setup_text[] = {
"front y",
"front z",
"front strength",
"glass",
"depth",
"thickness",
"strength",
"deform ratio",
"",
"",
"",
"",
"moire",
"h base",
"h variable",
@@ -343,6 +353,15 @@ vec4 setup_var[]={ // setup variable [start,end,step,value]
vec4(-2.0f, 2.0f, 0.10f, postfx_ghost2.y),
vec4(-2.0f, 2.0f, 0.10f, postfx_ghost2.z),
vec4(-1.0f, 1.0f, 0.05f, postfx_ghost2.w),
vec4(0), /* glass */
vec4(0.0f, 16.0f, 0.50f, postfx_glass.x),
vec4(0.0f, 1.0f, 0.05f, postfx_glass.y),
vec4(0.0f, 2.0f, 0.05f, postfx_glass.z),
vec4(0.0f, 1.0f, 0.05f, postfx_glass.w),
vec4(0),
vec4(0),
vec4(0),
vec4(0),
vec4(0), /* moire */
vec4( 0.5f, 1.0f, 0.05f, postfx_moire_h.x),
vec4(-0.5f, 0.5f, 0.05f, postfx_moire_h.y),
@@ -420,7 +439,9 @@ void Render::UpdateVar()
k += 2; /* ghost */
postfx_ghost1 = vec4(setup_var[k].w, setup_var[k + 1].w, setup_var[k + 2].w, setup_var[k + 3].w); k += 4;
postfx_ghost2 = vec4(setup_var[k].w, setup_var[k + 1].w, setup_var[k + 2].w, setup_var[k + 3].w); k += 4;
k += 1; /* moire */
k += 1; /* glass */
postfx_glass = vec4(setup_var[k].w, setup_var[k + 1].w, setup_var[k + 2].w, setup_var[k + 3].w); k += 4;
k += 5; /* moire */
postfx_moire_h = vec4(setup_var[k].w, setup_var[k + 1].w, setup_var[k + 2].w, setup_var[k + 3].w); k += 4;
postfx_moire_v = vec4(setup_var[k].w, setup_var[k + 1].w, setup_var[k + 2].w, setup_var[k + 3].w); k += 4;
k += 1; /* scanline */
@@ -499,6 +520,7 @@ ShaderUniform shader_postfx_texture,
shader_postfx_deform,
shader_postfx_ghost1,
shader_postfx_ghost2,
shader_postfx_glass,
shader_postfx_vignetting,
shader_postfx_aberration,
shader_postfx_moire_h,
@@ -600,6 +622,7 @@ int Render::InitDraw(void)
shader_postfx_deform = shader_postfx->GetUniformLocation("deform");
shader_postfx_ghost1 = shader_postfx->GetUniformLocation("ghost1");
shader_postfx_ghost2 = shader_postfx->GetUniformLocation("ghost2");
shader_postfx_glass = shader_postfx->GetUniformLocation("glass");
shader_postfx_vignetting = shader_postfx->GetUniformLocation("vignetting");
shader_postfx_aberration = shader_postfx->GetUniformLocation("aberration");
shader_postfx_moire_h = shader_postfx->GetUniformLocation("moire_h");
@@ -1309,8 +1332,9 @@ void Render::Draw3D()
shader_postfx->SetUniform(shader_postfx_ratio_2d, (vec2)ratio_2d / 2);
shader_postfx->SetUniform(shader_postfx_time, fx_angle);
shader_postfx->SetUniform(shader_postfx_deform, postfx_deform);
shader_postfx->SetUniform(shader_postfx_ghost1, postfx_ghost1);
shader_postfx->SetUniform(shader_postfx_ghost2, postfx_ghost2);
shader_postfx->SetUniform(shader_postfx_ghost1, vec4(postfx_ghost1.x * 0.01, postfx_ghost1.y * 0.01, postfx_ghost1.z * 0.01, postfx_ghost1.w));
shader_postfx->SetUniform(shader_postfx_ghost2, vec4(postfx_ghost2.x * 0.01, postfx_ghost2.y * 0.01, postfx_ghost2.z * 0.01, postfx_ghost2.w));
shader_postfx->SetUniform(shader_postfx_glass, vec4(postfx_glass.x * 0.01, postfx_glass.y * 0.01, postfx_glass.z * 0.1, postfx_glass.w));
shader_postfx->SetUniform(shader_postfx_vignetting, postfx_vignetting);
shader_postfx->SetUniform(shader_postfx_aberration, postfx_aberration);
shader_postfx->SetUniform(shader_postfx_moire_h, postfx_moire_h);


正在加载...
取消
保存