Changeset 2007


Ignore:
Timestamp:
Oct 11, 2012, 3:01:35 AM (5 years ago)
Author:
rez
Message:

neercs: added radial blur! FUCK YEAH \:D/

Location:
trunk/tools/neercs
Files:
1 added
8 edited

Legend:

Unmodified
Added
Removed
  • trunk/tools/neercs/Makefile.am

    r1981 r2007  
    1818    video/simple.lolfx \
    1919    video/blurh.lolfx video/blurv.lolfx video/glow.lolfx \
    20     video/remanence.lolfx video/copper.lolfx video/color.lolfx \
    21     video/noise.lolfx video/postfx.lolfx video/mirror.lolfx \
     20    video/remanence.lolfx video/copper.lolfx video/color.lolfx video/noise.lolfx \
     21    video/postfx.lolfx video/mirror.lolfx video/radial.lolfx \
    2222    video/text.lolfx
    2323neercs_CPPFLAGS = @LOL_CFLAGS@ @PIPI_CFLAGS@ @CACA_CFLAGS@ -Iold
  • trunk/tools/neercs/neercs.vcxproj

    r1971 r2007  
    9393    <LolFxCompile Include="video\postfx.lolfx" />
    9494    <LolFxCompile Include="video\mirror.lolfx" />
     95    <LolFxCompile Include="video\radial.lolfx" />
    9596  </ItemGroup>
    9697  <PropertyGroup Label="Globals">
  • trunk/tools/neercs/neercs.vcxproj.filters

    r1971 r2007  
    160160      <Filter>video</Filter>
    161161    </LolFxCompile>
     162    <LolFxCompile Include="video\radial.lolfx">
     163      <Filter>video</Filter>
     164    </LolFxCompile>
    162165  </ItemGroup>
    163166</Project>
  • trunk/tools/neercs/video/color.lolfx

    r1962 r2007  
    2424    vec3 c = texture2D(texture,p).xyz;
    2525
    26     float a = (c.x+c.y+c.z)/3.0;
    27     c = mix(c,vec3(a),color.w);                // grayscale
     26    float a = (c.x + c.y + c.z) / 3.0;
     27    c = mix(c, vec3(a), color.w);              // grayscale
    2828    c *= filter;                               // filter
    29     c += color.z*0.1;                          // level
     29    c += color.z * 0.1;                        // level
    3030    c *= color.x;                              // brightness
    31     c = 0.5+(c-0.5)*color.y;                   // contrast
     31    c = 0.5 + (c - 0.5) * color.y;             // contrast
    3232    c += flash;                                // flash
    3333
    34     gl_FragColor = vec4(c,1.0);
     34    gl_FragColor = vec4(c, 1.0);
    3535}
  • trunk/tools/neercs/video/mirror.lolfx

    r1993 r2007  
    2020{
    2121    vec2 p = gl_TexCoord[0].xy;
    22     vec3 source = texture2D(texture, p).xyz;
     22    vec3 s = texture2D(texture, p).xyz;
    2323
    24     vec3 color = vec3(0.0);
    25     if(p.x < mirror.x) color = (texture2D(texture, vec2(mirror.x + (mirror.x - p.x) * mirror.w, p.y)).xyz) * (mirror.z / mirror.x * p.x);
    26     if(p.x > 1.0 - mirror.x) color = (texture2D(texture, vec2(- mirror.x - (mirror.x + p.x) * mirror.w, p.y)).xyz) * (mirror.z / mirror.x * (1.0 - p.x));
    27     if(p.y < mirror.y) color = (texture2D(texture, vec2(p.x, mirror.y + (mirror.y - p.y) * mirror.w)).xyz) * (mirror.z / mirror.y * p.y);
    28     if(p.y > 1.0 - mirror.y) color = (texture2D(texture, vec2(p.x, - mirror.y - (mirror.y + p.y) * mirror.w)).xyz) * (mirror.z / mirror.y * (1.0 - p.y));
     24    vec3 c = vec3(0.0);
     25    if(p.x < mirror.x) c = (texture2D(texture, vec2(mirror.x + (mirror.x - p.x) * mirror.w, p.y)).xyz) * (mirror.z / mirror.x * p.x);
     26    if(p.x > 1.0 - mirror.x) c = (texture2D(texture, vec2(- mirror.x - (mirror.x + p.x) * mirror.w, p.y)).xyz) * (mirror.z / mirror.x * (1.0 - p.x));
     27    if(p.y < mirror.y) c = (texture2D(texture, vec2(p.x, mirror.y + (mirror.y - p.y) * mirror.w)).xyz) * (mirror.z / mirror.y * p.y);
     28    if(p.y > 1.0 - mirror.y) c = (texture2D(texture, vec2(p.x, - mirror.y - (mirror.y + p.y) * mirror.w)).xyz) * (mirror.z / mirror.y * (1.0 - p.y));
    2929
    30     gl_FragColor = vec4(source + color + color * color, 1.0);
     30    gl_FragColor = vec4(s + c, 1.0);
    3131}
  • trunk/tools/neercs/video/postfx.lolfx

    r1962 r2007  
    55void main()
    66{
    7     gl_Position = gl_Vertex;
    8     gl_TexCoord[0] = gl_MultiTexCoord0;
     7    gl_Position=gl_Vertex;
     8    gl_TexCoord[0]=gl_MultiTexCoord0;
    99}
    1010
     
    3131vec2 screen(in vec2 p,in float radius)
    3232{
    33     float d = deform.x+sync*0.0625+beat*0.0375;
     33    float d=deform.x+sync*0.0625+beat*0.0375;
    3434    return p*(1.5-(radius*cos(p.x*d)+radius*cos(p.y*d)))-0.5;
    3535}
     
    4747void main(void)
    4848{
    49     vec2 q = gl_FragCoord.xy/screen_size.xy;
    50     vec2 p = -1.0+2.0*gl_FragCoord.xy/screen_size.xy;
    51     p.y += 0.025*sync;
    52     vec2 z = screen(p,deform.y);
    53     vec2 z1 = screen(p,deform.y+ghost1.z*0.01);
    54     vec2 z2 = screen(p,deform.y+ghost2.z*0.01);
    55     float mask = q.x*(6.0-q.x*6.0)*q.y*(6.0-q.y*6.0);
     49    vec2 q=gl_FragCoord.xy/screen_size.xy;
     50    vec2 p=-1.0+2.0*gl_FragCoord.xy/screen_size.xy;
     51    p.y+=0.025*sync;
     52    vec2 z=screen(p,deform.y);
     53    vec2 z1=screen(p,deform.y+ghost1.z*0.01);
     54    vec2 z2=screen(p,deform.y+ghost2.z*0.01);
     55    float mask=q.x*(6.0-q.x*6.0)*q.y*(6.0-q.y*6.0);
    5656
    57     vec3 source = get_color(texture,z);
    58     vec3 g1 = get_color(texture,z1-ghost1.xy*0.01);
    59     vec3 g2 = get_color(texture,z2-ghost2.xy*0.01);
     57    vec3 source=get_color(texture,z);
     58    vec3 g1=get_color(texture,z1-ghost1.xy*0.01);
     59    vec3 g2=get_color(texture,z2-ghost2.xy*0.01);
    6060
    61     vec3 c = source+g1*ghost1.w+g2*ghost2.w;                   // mix
     61    vec3 c=source+g1*ghost1.w+g2*ghost2.w;                   // mix
    6262
    63     float v = aberration/float(screen_size.x);//+aberration/float(screen_size.x)*(2.0-mask);
    64     vec3 ca1 = get_color(texture,vec2(z.x-v,z.y));
    65     vec3 ca2 = get_color(texture,vec2(z.x+v,z.y));
    66     c += vec3(ca1.x,c.y,ca2.z);                                // chromatic aberration
     63    float v=aberration/float(screen_size.x);//+aberration/float(screen_size.x)*(2.0-mask);
     64    vec3 ca1=get_color(texture,vec2(z.x-v,z.y));
     65    vec3 ca2=get_color(texture,vec2(z.x+v,z.y));
     66    c+=vec3(ca1.x,c.y,ca2.z);                                // chromatic aberration
    6767
    68     c *= moire_h.x+moire_h.y*sin(z.y*float(screen_size.y*moire_h.z))*sin(0.5+z.x*float(screen_size.x*moire_h.w)); // moire h
    69     c *= moire_v.x+moire_v.y*sin(z.x*float(screen_size.x*moire_v.z))*sin(0.5+z.y*float(screen_size.y*moire_v.w)); // moire v
    70     c *= scanline_h.x+scanline_h.y*cos(z.y*float(screen_size.y*scanline_h.z+scanline_h.w)); // scanline h
    71     c *= scanline_v.x+scanline_v.y*cos(z.x*float(screen_size.x*scanline_v.z+scanline_v.w)); // scanline v
    72     c *= mix(1.0,mask,vignetting);                             // vignetting
    73     c *= letterbox(z,corner.x+2.0,corner.y,corner.z);          // corner
    74     gl_FragColor = vec4(c,1.0);
     68    vec3 c1=vec3(0.3,0.2,0.2);
     69    vec3 c2=vec3(1.0,1.0,1.0);
     70    vec3 c3=vec3(0.0,0.4,0.7);
     71
     72    c+=((p.y<0.0)?mix(c1,c2,1.0+p.y):mix(c2,c3,p.y))*0.25;   // reflection
     73
     74    c*=moire_h.x+moire_h.y*sin(z.y*float(screen_size.y*moire_h.z))*sin(0.5+z.x*float(screen_size.x*moire_h.w)); // moire h
     75    c*=moire_v.x+moire_v.y*sin(z.x*float(screen_size.x*moire_v.z))*sin(0.5+z.y*float(screen_size.y*moire_v.w)); // moire v
     76    c*=scanline_h.x+scanline_h.y*cos(z.y*float(screen_size.y*scanline_h.z+scanline_h.w)); // scanline h
     77    c*=scanline_v.x+scanline_v.y*cos(z.x*float(screen_size.x*scanline_v.z+scanline_v.w)); // scanline v
     78    c*=mix(1.0,mask,vignetting);                             // vignetting
     79    c*=letterbox(z,corner.x+2.0,corner.y,corner.z);          // corner
     80    gl_FragColor=vec4(c,1.0);
    7581}
  • trunk/tools/neercs/video/render.cpp

    r2005 r2007  
    4343extern char const *lolfx_postfx;
    4444extern char const *lolfx_mirror;
     45extern char const *lolfx_radial;
    4546
    4647#define PID M_PI/180.0f    // pi ratio
     
    103104vec3 copper_mask_color(4.0f,4.0f,4.0f);         // color [red,green,blue]
    104105vec3 color_filter(0.9f,0.95f,0.85f);            // color filter [red,green,blue]
    105 vec4 color_color(1.4f,1.2f,0.1f,0.35f);         // color modifier [brightness,contrast,level,grayscale]
     106vec4 color_color(1.0f,1.25f,0.0f,0.35f);        // color modifier [brightness,contrast,level,grayscale]
    106107vec2 noise_offset(1.0f,1.0f);                   // random line [horizontal,vertical]
    107108float noise_noise = 0.15f;                      // noise
    108109vec3 noise_retrace(1.0f,1.0f,0.5f);             // retrace [strength,length,speed]
    109 vec2 postfx_deform(0.8f,0.52f);                 // deformation [ratio,zoom]
     110vec2 postfx_deform(0.8f,0.48f);                 // deformation [ratio,zoom]
    110111float postfx_vignetting = 0.5f;                 // vignetting strength
    111112float postfx_aberration = 4.0f;                 // chromatic aberration
     
    117118vec4 postfx_scanline_v(0.75f,-0.25f,2.0f,0.0f); // horizontal scanline [base,variable,repeat,shift]
    118119vec3 postfx_corner(0.0f,0.8f,0.96f);            // corner [width,radius,blur]
    119 vec4 mirror(0.6f,0.6f,0.4f,4.0f);               // mirror [width,height,strength,ratio]
     120vec4 mirror(0.95f,0.9f,0.4f,3.0f);              // mirror [width,height,strength,ratio]
     121vec4 radial(4.0f,0.94f,32,0.25f);               // radial [distance,fade ratio,iteration,strength]
    120122/* text variable */
    121123ivec2 ratio_2d(2,3);            // 2d ratio
     
    124126ivec2 canvas_char(0,0);         // canvas char number
    125127ivec2 canvas_size(0,0);         // caca size
    126 ivec2 border(2 * ratio_2d.x * font_size.x,1 * ratio_2d.x * font_size.y); // border width
     128ivec2 border(2 * ratio_2d.x * font_size.x,1 * ratio_2d.y * font_size.y); // border width
    127129/* setup variable */
    128130bool setup_switch = false;      // switch [option/item]
     
    131133int setup_cursor = 0;           // cursor position
    132134int setup_option_i = 0;         // selected option
    133 int setup_option_n = 12;        // option number
     135int setup_option_n = 13;        // option number
    134136int setup_option_p = 0;         // option position
    135137int setup_item_i = 0;           // selected item
     
    248250        "",
    249251        "",
     252        "",
     253    "radial",
     254        "enable",
     255        "distance",
     256        "fade ratio",
     257        "iteration",
     258        "strength",
     259        "",
     260        "",
    250261        ""
    251262    };
     
    356367        vec4(0.0f, 2.0f, 0.05f, mirror.y),
    357368        vec4(0.0f, 1.0f, 0.05f, mirror.z),
    358         vec4(1.0f, 4.0f, 0.25f, mirror.w),
     369        vec4(1.0f, 8.0f, 1.00f, mirror.w),
     370        vec4(0),
     371        vec4(0),
     372        vec4(0),
     373    vec4(0), /* radial blur */
     374        vec4(0, 1, 1, 1),
     375        vec4(2.0f, 8.0f, 0.25f, radial.x),
     376        vec4(0.5f, 1.0f, 0.01f, radial.y),
     377        vec4(2.0f,64.0f, 2.00f, radial.z),
     378        vec4(0.0f, 1.0f, 0.05f, radial.w),
    359379        vec4(0),
    360380        vec4(0),
     
    410430    m_shader_mirror = (setup_var[k].w == 1) ? true : false; k++;
    411431    mirror = vec4(setup_var[k].w, setup_var[k + 1].w, setup_var[k + 2].w, setup_var[k + 3].w); k += 4;
     432    k += 4; /* radial blur */
     433    m_shader_radial = (setup_var[k].w == 1) ? true : false; k++;
     434    radial = vec4(setup_var[k].w, setup_var[k + 1].w, setup_var[k + 2].w, setup_var[k + 3].w); k += 4;
    412435    UpdateSize();
    413436}
     
    440463Shader *shader_blur_h, *shader_blur_v, *shader_glow;
    441464Shader *shader_remanence, *shader_copper, *shader_color;
    442 Shader *shader_noise, *shader_postfx, *shader_mirror;
     465Shader *shader_noise, *shader_postfx, *shader_mirror, *shader_radial;
    443466// shader variables
    444467ShaderUniform shader_simple_texture;
     
    488511              shader_mirror_screen_size,
    489512              shader_mirror_mirror;
     513ShaderUniform shader_radial_texture,
     514              shader_radial_screen_size,
     515              shader_radial_radial;
    490516
    491517FrameBuffer *fbo_back, *fbo_front, *fbo_screen;
     
    587613    shader_mirror_screen_size = shader_mirror->GetUniformLocation("screen_size");
    588614    shader_mirror_mirror = shader_mirror->GetUniformLocation("mirror");
     615    // shader radial blur
     616    shader_radial = Shader::Create(lolfx_radial);
     617    shader_radial_texture = shader_radial->GetUniformLocation("texture");
     618    shader_radial_screen_size = shader_radial->GetUniformLocation("screen_size");
     619    shader_radial_radial = shader_radial->GetUniformLocation("radial");
    589620    // initialize setup
    590621    setup_n = calc_item_length();
     
    605636    m_ready(false),
    606637    m_pause(false),
    607     m_polygon(true),
    608638    m_shader(true),
    609639    m_shader_glow(true),
     
    614644    m_shader_noise(true),
    615645    m_shader_postfx(true),
    616     m_shader_mirror(true)
     646    m_shader_mirror(true),
     647    m_shader_radial(true)
    617648{
    618649    m_txt_screen = new TextRender(m_cv_screen, font_size);
     
    623654{
    624655    Entity::TickGame(seconds);
    625 
    626     /* draw LOLCUBE */
    627     /*
    628     caca_set_color_argb(m_cv_screen, 0xfff, 0x000);
    629     caca_put_str(m_cv_screen, canvas_char.x -  8, canvas_char.y - 6, "_______");
    630     caca_put_str(m_cv_screen, canvas_char.x -  9, canvas_char.y - 5, "/      /|");
    631     caca_put_str(m_cv_screen, canvas_char.x - 10, canvas_char.y - 4, "/______/ |");
    632     caca_put_str(m_cv_screen, canvas_char.x - 10, canvas_char.y - 3, "|      | |");
    633     caca_put_str(m_cv_screen, canvas_char.x - 10, canvas_char.y - 2, "|  :D  | /");
    634     caca_put_str(m_cv_screen, canvas_char.x - 10, canvas_char.y - 1, "|______|/");
    635     */
    636 
    637656    /* draw setup */
    638657    if (g_setup)
     
    647666        caca_put_str(m_cv_setup, setup_size.x / 2 - 3, 0, "SETUP");
    648667        /* informations */
     668        /*
    649669        int w = caca_get_canvas_width(m_cv_screen);
    650670        int h = caca_get_canvas_height(m_cv_screen);
    651671        caca_set_color_argb(m_cv_setup, setup_color.y, setup_color.x);
    652672        caca_printf(m_cv_setup, 1, 0, "%i*%i", w, h);
     673        */
    653674        /* display option */
    654675        for (int i = 0; i < setup_h; i++)
     
    756777        m_shader_postfx = !m_shader_postfx;
    757778        m_shader_mirror = !m_shader_mirror;
    758         //m_polygon = !m_polygon;
    759         //polygon_fillmode = (m_polygon)?GL_FILL:GL_LINE;
    760         //glPolygonMode(GL_FRONT, polygon_fillmode);
     779        m_shader_radial = !m_shader_radial;
    761780    }
    762781   if (Input::WasPressed(Key::Tab))
     
    10841103
    10851104    /* Clear the back buffer */
     1105    glEnable(GL_TEXTURE_2D);
    10861106    glEnable(GL_BLEND);
    10871107    glBlendFunc(GL_SRC_COLOR, GL_DST_ALPHA);
     
    10941114    if (g_setup)
    10951115        m_txt_setup->Blit((screen_size - setup_canvas_size) / 2, setup_canvas_size);
    1096 
    1097     //if (m_polygon) glEnable(GL_LINE_SMOOTH); else glDisable(GL_LINE_SMOOTH);
    1098     glLineWidth((m_polygon)?2.0f:1.0f);
    1099     fx_angle=main_angle-part_angle;
    1100     if (m_polygon)
    1101         glEnable(GL_TEXTURE_2D);
    11021116
    11031117    glMatrixMode(GL_PROJECTION);
     
    11051119    glLoadMatrixf(&m[0][0]);
    11061120    glMatrixMode(GL_MODELVIEW);
     1121
     1122    fx_angle=main_angle-part_angle;
    11071123}
    11081124
     
    13311347    }
    13321348
     1349    if (m_shader_radial)
     1350    {
     1351        // shader radial blur
     1352        fbo_tmp->Bind();
     1353        shader_radial->Bind();
     1354        shader_radial->SetUniform(shader_radial_texture, fbo_front->GetTexture(), 0);
     1355        shader_radial->SetUniform(shader_radial_screen_size, (vec2)screen_size);
     1356        shader_radial->SetUniform(shader_radial_radial, vec4(radial.x, radial.y, radial.z, radial.w * 0.1f));
     1357        TraceQuad();
     1358        shader_radial->Unbind();
     1359        fbo_tmp->Unbind();
     1360        // shader simple
     1361        fbo_front->Bind();
     1362        ShaderSimple(fbo_tmp, 0);
     1363        fbo_front->Unbind();
     1364    }
     1365
    13331366    // shader simple
    13341367    ShaderSimple(fbo_front, 0);
     
    13431376        Ticker::Unref(m_fps_debug);
    13441377}
    1345 
  • trunk/tools/neercs/video/render.h

    r1999 r2007  
    3838    bool m_ready;
    3939    bool m_pause;
    40     bool m_polygon;
    4140    bool m_shader;
    4241    bool m_shader_glow;
     
    4847    bool m_shader_postfx;
    4948    bool m_shader_mirror;
     49    bool m_shader_radial;
    5050};
    5151
    5252#endif // __VIDEO_RENDER_H__
    53 
Note: See TracChangeset for help on using the changeset viewer.