From 667324f9c547bdc601b485ff02538ef3f1fa47b8 Mon Sep 17 00:00:00 2001 From: rez Date: Sun, 30 Sep 2012 23:16:42 +0000 Subject: [PATCH] NEERCS: fixed setup value bar length / fixed copper setup --- neercs/term/term.cpp | 3 +-- neercs/video/color.lolfx | 2 +- neercs/video/copper.lolfx | 20 ++++++++--------- neercs/video/noise.lolfx | 3 +-- neercs/video/postfx.lolfx | 3 +-- neercs/video/render.cpp | 45 ++++++++++++++++++++++----------------- 6 files changed, 39 insertions(+), 37 deletions(-) diff --git a/neercs/term/term.cpp b/neercs/term/term.cpp index 3ba4c8b..4bbf96b 100644 --- a/neercs/term/term.cpp +++ b/neercs/term/term.cpp @@ -181,8 +181,7 @@ void Term::DrawFancyShit() caca_set_color_argb(m_caca, hex_color(0.6f + 0.4f * lol::cos(m_time * 2), 0.2f, 0.2f), bg_color); caca_put_str(m_caca, w - 12, h - 2, "CACA RULEZ"); -/* - _______ +/*_______ / /| /______/ | | | | diff --git a/neercs/video/color.lolfx b/neercs/video/color.lolfx index 737b794..c186810 100644 --- a/neercs/video/color.lolfx +++ b/neercs/video/color.lolfx @@ -32,4 +32,4 @@ void main(void) c += flash; // flash gl_FragColor = vec4(c,1.0); -} +} \ No newline at end of file diff --git a/neercs/video/copper.lolfx b/neercs/video/copper.lolfx index 5ee98c3..95a6d90 100644 --- a/neercs/video/copper.lolfx +++ b/neercs/video/copper.lolfx @@ -16,23 +16,23 @@ uniform sampler2D texture; uniform vec2 screen_size; uniform float time; uniform vec4 copper; +uniform vec3 mask_color; void main(void) { vec2 p = gl_TexCoord[0].xy; - vec3 source = texture2D(texture,p).xyz; + vec3 source = texture2D(texture, p).xyz; vec3 color = vec3(0.5); - color.x += 0.5*cos(p.y*float(screen_size.y/copper.z)+time); - color.z += 0.5*sin(p.y*float(screen_size.y/copper.z)+time); + color.x += 0.5 * cos(p.y*float(screen_size.y / copper.w) + time); + color.z += 0.5 * sin(p.y*float(screen_size.y / copper.w) + time); - color *= copper.x+copper.y*cos(p.y*float(screen_size.x/copper.w)-time); + color *= copper.x + copper.y * cos(p.y * float(screen_size.x / copper.z));// - time); - color.x = float(int(color.x*8.0)*32)/256.0; - color.y = float(int(color.y*8.0)*32)/256.0; - color.z = float(int(color.z*8.0)*32)/256.0; - - gl_FragColor = vec4((source==1.0)?color:source,1.0); -} + color.x = float(int(color.x * 8.0) * 32) / 256.0; + color.y = float(int(color.y * 8.0) * 32) / 256.0; + color.z = float(int(color.z * 8.0) * 32) / 256.0; + gl_FragColor = vec4((source == mask_color) ? color : source, 1.0); +} \ No newline at end of file diff --git a/neercs/video/noise.lolfx b/neercs/video/noise.lolfx index e3ec7db..6b354bf 100644 --- a/neercs/video/noise.lolfx +++ b/neercs/video/noise.lolfx @@ -36,5 +36,4 @@ void main(void) c *= 1.0+(noise-noise*2.0*r1); // noise c -= retrace.x*0.01*mod(p.y*retrace.y+time*retrace.z,1.0); // retrace gl_FragColor = vec4(c,1.0); -} - +} \ No newline at end of file diff --git a/neercs/video/postfx.lolfx b/neercs/video/postfx.lolfx index de31fc2..0b81848 100644 --- a/neercs/video/postfx.lolfx +++ b/neercs/video/postfx.lolfx @@ -72,5 +72,4 @@ void main(void) c *= mix(1.0,mask,vignetting); // vignetting c *= letterbox(z,corner.x+2.0,corner.y,corner.z); // corner gl_FragColor = vec4(c,1.0); -} - +} \ No newline at end of file diff --git a/neercs/video/render.cpp b/neercs/video/render.cpp index f370a78..8ec9e65 100644 --- a/neercs/video/render.cpp +++ b/neercs/video/render.cpp @@ -107,7 +107,8 @@ vec4 postfx_moire_v(0.75f,-0.25f,1.0f,1.5f); // horizontal moire [base,variab vec4 postfx_scanline_h(0.75f,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.75f,0.95f); // corner [width,radius,blur] -vec4 copper(0.75f,0.25f,2.0f,0.40f); // copper [base,variable,repeat x,repeat y] +vec4 copper_copper(0.8f,0.4f,0.42f,3.0f); // copper [base,variable,repeat,color cycle] +vec3 copper_mask_color(4.0f,4.0f,4.0f); // color [red,green,blue] /* text variable */ ivec2 ratio_2d(2,4); // 2d ratio ivec2 map_size(256,256); // texture map size @@ -226,11 +227,11 @@ char const *setup_text[] = { "enable", "base", "variable", - "color repeat", - "copper height", - "", - "", - "" + "repeat", + "color cycle", + "color r", + "color g", + "color b" }; vec4 setup_var[]={ // setup variable [start,end,step,value] @@ -326,13 +327,13 @@ vec4 setup_var[]={ // setup variable [start,end,step,value] vec4( 0.0f, 4.0f, 0.50f, postfx_scanline_v.w), vec4(0), /* copper */ vec4( 0, 1, 1, 1), - vec4(0.0f, 1.0f, 0.05f, copper.x), - vec4(0.0f, 1.0f, 0.05f, copper.y), - vec4(1.0f, 5.0f, 0.10f, copper.z), - vec4(0.0f, 1.0f, 0.05f, copper.w), - vec4(0), - vec4(0), - vec4(0), + vec4(0.0f, 1.0f, 0.05f, copper_copper.x), + vec4(0.0f, 1.0f, 0.05f, copper_copper.y), + vec4(0.0f, 1.0f, 0.01f, copper_copper.z), + vec4(0.0f, 8.0f, 0.25f, copper_copper.w), + vec4(0.0f, 4.0f, 0.25f, copper_mask_color.x), + vec4(0.0f, 4.0f, 0.25f, copper_mask_color.y), + vec4(0.0f, 4.0f, 0.25f, copper_mask_color.z), vec4(0) /* ? */ }; @@ -378,7 +379,8 @@ void Render::UpdateVar() postfx_scanline_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; /* copper */ m_shader_copper = (setup_var[k].w == 1) ? true : false; k++; - copper = vec4(setup_var[k].w, setup_var[k + 1].w, setup_var[k + 2].w, setup_var[k + 3].w); k += 4; + copper_copper = vec4(setup_var[k].w, setup_var[k + 1].w, setup_var[k + 2].w, setup_var[k + 3].w); k += 4; + copper_mask_color = vec3(setup_var[k].w, setup_var[k + 1].w, setup_var[k + 2].w); k += 3; UpdateSize(); } @@ -427,7 +429,8 @@ ShaderUniform shader_remanency_source, ShaderUniform shader_copper_texture, shader_copper_screen_size, shader_copper_time, - shader_copper_copper; + shader_copper_copper, + shader_copper_mask_color; ShaderUniform shader_color_texture, shader_color_screen_size, shader_color_filter, @@ -515,6 +518,7 @@ int Render::InitDraw(void) shader_copper_screen_size = shader_copper->GetUniformLocation("screen_size"); shader_copper_time = shader_copper->GetUniformLocation("time"); shader_copper_copper = shader_copper->GetUniformLocation("copper"); + shader_copper_mask_color = shader_copper->GetUniformLocation("mask_color"); // shader color shader_color = Shader::Create(lolfx_color); shader_color_texture = shader_color->GetUniformLocation("texture"); @@ -645,14 +649,14 @@ void Render::TickGame(float seconds) { int x = setup_p.x + 1; int w = setup_size.x - 3 - 4; - int bar_w = w / (setup_var[setup_item_key].y - setup_var[setup_item_key].x); + float bar_w = w / (setup_var[setup_item_key].y - setup_var[setup_item_key].x); int bar_x = bar_w * setup_var[setup_item_key].x; if ((setup_var[setup_item_key].y - setup_var[setup_item_key].x) / setup_var[setup_item_key].z > 1) { /* Work around a bug in libcaca */ if (setup_p.x + setup_size.x - 4 < caca_get_canvas_width(m_caca)) caca_printf(m_caca, setup_p.x + setup_size.x - 4, y, "%4.2f", setup_var[setup_item_key].w); - caca_draw_line(m_caca, x, y, x - bar_x + bar_w * setup_var[setup_item_key].y, y,'.'); - if (setup_var[setup_item_key].w != setup_var[setup_item_key].x) caca_draw_line(m_caca, x, y, x - bar_x + bar_w * setup_var[setup_item_key].w, y, 'x'); + caca_draw_line(m_caca, x, y, x - bar_x + int(bar_w * setup_var[setup_item_key].y), y,'.'); + if (setup_var[setup_item_key].w != setup_var[setup_item_key].x) caca_draw_line(m_caca, x, y, x - bar_x + int(bar_w * setup_var[setup_item_key].w), y, 'x'); } else { @@ -664,7 +668,7 @@ void Render::TickGame(float seconds) } else { - caca_printf(m_caca, setup_p.x + 1, y, "%d/%d [%d]", setup_option_i, setup_n, setup_option_p); + caca_printf(m_caca, setup_p.x + 1, y, "%d/%d", setup_option_i, setup_n); } /* informations */ @@ -1071,7 +1075,8 @@ void Render::Draw3D() shader_copper->SetUniform(shader_copper_texture, fbo_back->GetTexture(), 0); shader_copper->SetUniform(shader_copper_screen_size, (vec2)screen_size); shader_copper->SetUniform(shader_copper_time, fx_angle * 2.0f); - shader_copper->SetUniform(shader_copper_copper, vec4(copper.x, copper.y, copper.z * 16.0f, copper.w * 16.0f)); + shader_copper->SetUniform(shader_copper_copper, vec4(copper_copper.x, copper_copper.y, copper_copper.z * 16.0f, copper_copper.w * 16.0f)); + shader_copper->SetUniform(shader_copper_mask_color, copper_mask_color / 4.0f); TraceQuad(); shader_color->Unbind(); fbo_tmp->Unbind();