From 7133838f44731f8376f90e61921897d388ffe7dd Mon Sep 17 00:00:00 2001 From: rez Date: Tue, 2 Oct 2012 23:14:21 +0000 Subject: [PATCH] NEERCS: added a new shader (mirror.lolfx), slightly modified the theme --- neercs/Makefile.am | 2 +- neercs/neercs.vcxproj | 1 + neercs/neercs.vcxproj.filters | 3 ++ neercs/video/mirror.lolfx | 27 +++++++++++ neercs/video/render.cpp | 87 ++++++++++++++++++++--------------- neercs/video/render.h | 1 + 6 files changed, 84 insertions(+), 37 deletions(-) create mode 100644 neercs/video/mirror.lolfx diff --git a/neercs/Makefile.am b/neercs/Makefile.am index c554303..2a9e184 100644 --- a/neercs/Makefile.am +++ b/neercs/Makefile.am @@ -18,7 +18,7 @@ neercs_SOURCES = \ video/simple.lolfx \ video/blurh.lolfx video/blurv.lolfx video/glow.lolfx \ video/remanency.lolfx video/copper.lolfx video/color.lolfx \ - video/noise.lolfx video/postfx.lolfx \ + video/noise.lolfx video/postfx.lolfx video/mirror.lolfx \ video/text.lolfx neercs_CPPFLAGS = @LOL_CFLAGS@ @PIPI_CFLAGS@ @CACA_CFLAGS@ -Iold neercs_LDADD = diff --git a/neercs/neercs.vcxproj b/neercs/neercs.vcxproj index a3efa50..9d70f9d 100644 --- a/neercs/neercs.vcxproj +++ b/neercs/neercs.vcxproj @@ -91,6 +91,7 @@ + {587FCCE9-1D8D-4398-B8B6-E8F4E9A92233} diff --git a/neercs/neercs.vcxproj.filters b/neercs/neercs.vcxproj.filters index 1d7a2d7..2239286 100644 --- a/neercs/neercs.vcxproj.filters +++ b/neercs/neercs.vcxproj.filters @@ -156,5 +156,8 @@ video + + video + \ No newline at end of file diff --git a/neercs/video/mirror.lolfx b/neercs/video/mirror.lolfx new file mode 100644 index 0000000..1e41ddd --- /dev/null +++ b/neercs/video/mirror.lolfx @@ -0,0 +1,27 @@ +[vert.glsl] + +#version 120 + +void main() +{ + gl_Position = gl_Vertex; + gl_TexCoord[0] = gl_MultiTexCoord0; +} + +[frag.glsl] + +#version 120 + +uniform sampler2D texture; +uniform vec2 screen_size; +uniform vec4 mirror; + +void main(void) +{ + vec2 p = gl_TexCoord[0].xy; + vec3 source = texture2D(texture, p).xyz; + + vec3 color = vec3(1.0,0.5,0.75); + + gl_FragColor = vec4(source*color, 1.0); +} \ No newline at end of file diff --git a/neercs/video/render.cpp b/neercs/video/render.cpp index 7c8cd9d..ed4c29c 100644 --- a/neercs/video/render.cpp +++ b/neercs/video/render.cpp @@ -40,6 +40,7 @@ extern char const *lolfx_copper; extern char const *lolfx_color; extern char const *lolfx_noise; extern char const *lolfx_postfx; +extern char const *lolfx_mirror; #define PID M_PI/180.0f // pi ratio @@ -92,14 +93,16 @@ vec2 glow_mix(0.7f,0.3f); // glow mix [source mix,glow mix] vec2 glow_large(3.0f,0.0f); // large glow radius [center,corner] vec2 glow_small(1.5f,0.0f); // small glow radius [center,corner] vec2 blur(0.5f,0.0f); // blur radius [center,corner] -vec3 color_filter(0.9f,0.9f,1.0f); // color filter [red,green,blue] +vec4 copper_copper(0.8f,0.4f,0.42f,4.0f); // copper [base,variable,repeat,color cycle] +vec3 copper_mask_color(4.0f,4.0f,4.0f); // color [red,green,blue] +vec3 color_filter(0.9f,0.95f,0.85f); // color filter [red,green,blue] vec4 color_color(1.5f,1.2f,0.1f,0.35f); // color modifier [brightness,contrast,level,grayscale] -vec2 noise_offset(2.0f,2.0f); // random line [horizontal,vertical] -float noise_noise = 0.25f; // noise -vec3 noise_retrace(1.0f,1.0f,0.5f); // retrace [strength,length,speed] -vec2 postfx_deform(0.7f,0.54f); // deformation [ratio,zoom] -float postfx_vignetting = 0.5f; // vignetting strength -float postfx_aberration = 4.0f; // chromatic aberration +vec2 noise_offset(2.0f,2.0f); // random line [horizontal,vertical] +float noise_noise = 0.25f; // noise +vec3 noise_retrace(1.0f,1.0f,0.5f); // retrace [strength,length,speed] +vec2 postfx_deform(0.8f,0.52f); // deformation [ratio,zoom] +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_moire_h(0.75f,-0.25f,0.0f,1.0f); // vertical moire [base,variable,repeat,shift] @@ -107,16 +110,15 @@ 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_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] +vec4 mirror(0.0f,0.0f,0.0f,0.0f); // /* text variable */ -ivec2 ratio_2d(2,4); // 2d ratio +ivec2 ratio_2d(2,3); // 2d ratio ivec2 map_size(256,256); // texture map size ivec2 font_size(8,8); // font size ivec2 canvas_char(0,0); // canvas char number ivec2 canvas_size(0,0); // caca size /* window variable */ -ivec2 border = vec2(3,1) * ratio_2d * font_size; // border width +ivec2 border = vec2(3,2) * ratio_2d * font_size; // border width /* setup variable */ bool setup_switch = false; // switch [option/item] int setup_n = 0; // item/option number @@ -177,6 +179,15 @@ char const *setup_text[] = { "corner blur", "vignetting", "", + "copper", + "enable", + "base", + "variable", + "repeat", + "color cycle", + "color r", + "color g", + "color b", "color", "filter red", "filter green", @@ -221,16 +232,7 @@ char const *setup_text[] = { "v base", "v variable", "v repeat", - "v shift", - "copper", - "enable", - "base", - "variable", - "repeat", - "color cycle", - "color r", - "color g", - "color b" + "v shift" }; vec4 setup_var[]={ // setup variable [start,end,step,value] @@ -279,6 +281,15 @@ vec4 setup_var[]={ // setup variable [start,end,step,value] vec4(0.0f, 1.0f, 0.05f, postfx_corner.z), vec4(0.0f, 1.0f, 0.10f, postfx_vignetting), vec4(0), + vec4(0), /* copper */ + vec4( 0, 1, 1, 1), + 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.02f, copper_copper.z), + vec4(1.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), /* color */ vec4( 0.0f, 1.0f, 0.05f, color_filter.x), vec4( 0.0f, 1.0f, 0.05f, color_filter.y), @@ -324,15 +335,6 @@ vec4 setup_var[]={ // setup variable [start,end,step,value] vec4(-0.5f, 0.5f, 0.05f, postfx_scanline_v.y), vec4( 0.0f, 4.0f, 0.50f, postfx_scanline_v.z), 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_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) /* ? */ }; @@ -358,6 +360,10 @@ void Render::UpdateVar() postfx_deform = vec2(setup_var[k].w, setup_var[k + 1].w); k += 2; postfx_corner = vec3(setup_var[k].w, setup_var[k + 1].w, setup_var[k + 2].w); k += 3; postfx_vignetting = setup_var[k].w; k++; + k += 1; /* copper */ + m_shader_copper = (setup_var[k].w == 1) ? true : false; k++; + 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; k += 2; /* color */ color_filter = vec3(setup_var[k].w, setup_var[k + 1].w, setup_var[k + 2].w); k += 3; color_color = vec4(setup_var[k].w, setup_var[k + 1].w, setup_var[k + 2].w, setup_var[k + 3].w); k += 4; @@ -376,10 +382,9 @@ void Render::UpdateVar() k += 1; /* scanline */ postfx_scanline_h = vec4(setup_var[k].w, setup_var[k + 1].w, setup_var[k + 2].w, setup_var[k + 3].w); k += 4; 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_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; + k += 1; /* mirror */ + m_shader_mirror = (setup_var[k].w == 1) ? true : false; k++; + mirror = vec4(setup_var[k].w, setup_var[k + 1].w, setup_var[k + 2].w, setup_var[k + 3].w); k += 4; UpdateSize(); } @@ -410,7 +415,7 @@ int calc_item_length() Shader *shader_simple; Shader *shader_blur_h, *shader_blur_v, *shader_glow; Shader *shader_remanency, *shader_copper, *shader_color; -Shader *shader_noise, *shader_postfx; +Shader *shader_noise, *shader_postfx, *shader_mirror; // shader variables ShaderUniform shader_simple_texture; ShaderUniform shader_blur_h_texture, @@ -455,6 +460,9 @@ ShaderUniform shader_postfx_texture, shader_postfx_corner, shader_postfx_sync, shader_postfx_beat; +ShaderUniform shader_mirror_texture, + shader_mirror_screen_size, + shader_mirror_mirror; FrameBuffer *fbo_back, *fbo_front, *fbo_buffer; FrameBuffer *fbo_blur_h, *fbo_blur_v, *fbo_tmp; @@ -547,6 +555,11 @@ int Render::InitDraw(void) shader_postfx_corner = shader_postfx->GetUniformLocation("corner"); shader_postfx_sync = shader_postfx->GetUniformLocation("sync"); shader_postfx_beat = shader_postfx->GetUniformLocation("beat"); + // shader mirror + shader_mirror = Shader::Create(lolfx_mirror); + shader_mirror_texture = shader_mirror->GetUniformLocation("texture"); + shader_mirror_screen_size = shader_mirror->GetUniformLocation("screen_size"); + shader_mirror_mirror = shader_mirror->GetUniformLocation("mirror"); // initialize setup setup_n = calc_item_length(); return true; @@ -573,7 +586,8 @@ Render::Render(caca_canvas_t *caca) m_shader_copper(true), m_shader_color(true), m_shader_noise(true), - m_shader_postfx(true) + m_shader_postfx(true), + m_shader_mirror(true) { m_txt_screen = new TextRender(m_cv_screen, font_size); m_txt_setup = new TextRender(m_cv_setup, font_size); @@ -707,6 +721,7 @@ void Render::TickDraw(float seconds) m_shader_color = !m_shader_color; m_shader_noise = !m_shader_noise; m_shader_postfx = !m_shader_postfx; + m_shader_mirror = !m_shader_mirror; //m_polygon = !m_polygon; //polygon_fillmode = (m_polygon)?GL_FILL:GL_LINE; //glPolygonMode(GL_FRONT, polygon_fillmode); diff --git a/neercs/video/render.h b/neercs/video/render.h index c3ac00f..2ee786f 100644 --- a/neercs/video/render.h +++ b/neercs/video/render.h @@ -45,6 +45,7 @@ private: bool m_shader_color; bool m_shader_noise; bool m_shader_postfx; + bool m_shader_mirror; }; #endif // __VIDEO_RENDER_H__