Ignore:
Timestamp:
Aug 27, 2012, 2:06:44 AM (9 years ago)
Author:
rez
Message:

moved some code from postfx to a new shader -> color.lolfx

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/tools/neercs/video/render.cpp

    r1814 r1820  
    3737extern char const *lolfx_blurv;
    3838extern char const *lolfx_glow;
    39 extern char const *lolfx_radial;
     39extern char const *lolfx_color;
    4040extern char const *lolfx_noise;
    4141extern char const *lolfx_postfx;
     
    8888/* shader variable */
    8989vec2 buffer(0.7f,0.3f);         // [new frame mix,old frame mix]
    90 vec2 remanency(0.3f,0.7f);      // remanency [source mix,buffer mix]
     90vec2 remanency(0.5f,0.5f);      // remanency [source mix,buffer mix]
    9191vec2 glow_mix(0.6f,0.4f);       // glow mix [source mix,glow mix]
    9292vec2 glow_large(2.0f,2.0f);     // large glow radius [center,corner]
    9393vec2 glow_small(1.0f,1.0f);     // small glow radius [center,corner]
    94 vec2 blur(0.25f,0.5f);          // glow radius [center,corner]
    95 vec2 noise_offset(1.5f,1.5f);         // random line [horizontal,vertical]
    96 float noise_noise = 0.15f;            // noise
    97 vec3 noise_retrace(0.02f,1.0f,0.5f);  // retrace [strength,length,speed]
     94vec2 blur(0.5f,0.5f);           // blur radius [center,corner]
     95vec3 color_filter(0.9f,1.0f,0.7f);    // color filter [red,green,blue]
     96vec3 color_color(1.1f,1.1f,0.25f);    // color modifier [brightness,contrast,grayscale]
     97vec2 noise_offset(2.0f,2.0f);         // random line [horizontal,vertical]
     98float noise_noise = 0.25f;            // noise
     99vec3 noise_retrace(1.0f,1.0f,0.5f);   // retrace [strength,length,speed]
    98100vec2 postfx_deform(0.7f,0.54f);       // deformation [ratio,zoom]
    99 vec3 postfx_filter(0.8f,0.9f,0.4f);   // color filter [red,green,blue]
    100 vec3 postfx_color(1.8f,1.5f,0.5f);    // color modifier [brightness,contrast,grayscale]
    101 vec2 postfx_corner(0.75f,0.95f);      // corner [radius,blur]
    102101float postfx_vignetting = -0.5f;      // vignetting strength
     102float postfx_aberration = 4.0f;       // chromatic aberration
    103103vec4 postfx_ghost1(0.01f,0.0f,0.1f,-0.4f);      // ghost picture 1 [position x,position y,position z,strength]
    104104vec4 postfx_ghost2(0.02f,0.0f,0.1f,0.4f);       // ghost picture 2 [position x,position y,position z,strength]
    105 float postfx_aberration = 4.0f;                 // chromatic aberration
    106105vec4 postfx_moire_h(0.75f,-0.25f,0.0f,1.0f);    // vertical moire [base,variable,repeat x,repeat y]
    107106vec4 postfx_moire_v(0.75f,-0.25f,1.0f,1.5f);    // horizontal moire [base,variable,repeat x,repeat y]
    108107vec4 postfx_scanline_h(0.75f, 0.25f,0.0f,2.0f); // vertical scanline [base,variable,repeat x,repeat y]
    109108vec4 postfx_scanline_v(0.75f,-0.25f,2.0f,0.0f); // horizontal scanline [base,variable,repeat x,repeat y]
     109vec2 postfx_corner(0.75f,0.95f);      // corner [radius,blur]
    110110/* window variable */
    111111ivec2 border;              // border width
     
    127127ivec3 setup_size(30,0,12);      // size [w,h,split]
    128128ivec2 setup_color(0x678,0x234); // color [foreground,background]
    129 //vec3 radial(2.0f,0.8f,0);     // radial [mix,strength,color mode]
    130129char const *setup_text[] = {
    131130    "theme",
     
    267266        vec4(0),
    268267    vec4(0), /* color */
    269         vec4(0.0f, 1.0f, 0.1f, postfx_filter.x),
    270         vec4(0.0f, 1.0f, 0.1f, postfx_filter.y),
    271         vec4(0.0f, 1.0f, 0.1f, postfx_filter.z),
    272         vec4(0.0f, 4.0f, 0.1f, postfx_color.x),
    273         vec4(0.0f, 4.0f, 0.1f, postfx_color.y),
    274         vec4(0.0f, 1.5f, 0.1f, postfx_color.z),
    275         vec4(0.0f, 8.0f, 0.5f, postfx_aberration),
     268        vec4(0.0f, 1.0f, 0.05f, color_filter.x),
     269        vec4(0.0f, 1.0f, 0.05f, color_filter.y),
     270        vec4(0.0f, 1.0f, 0.05f, color_filter.z),
     271        vec4(0.0f, 2.0f, 0.05f, color_color.x),
     272        vec4(0.0f, 2.0f, 0.05f, color_color.y),
     273        vec4(0.0f, 1.0f, 0.05f, color_color.z),
     274        vec4(0.0f, 8.0f, 0.50f, postfx_aberration),
    276275        vec4(0),
    277276    vec4(0), /* noise */
     
    279278        vec4(0.0f, 4.0f, 0.50f, noise_offset.x),
    280279        vec4(0.0f, 4.0f, 0.50f, noise_offset.y),
    281         vec4(0.0f, 0.5f, 0.25f, noise_noise),
    282         vec4(0.0f, 0.2f, 0.01f, noise_retrace.x),
     280        vec4(0.0f, 0.5f, 0.05f, noise_noise),
     281        vec4(0.0f, 4.0f, 0.25f, noise_retrace.x),
    283282        vec4(0.0f, 8.0f, 0.50f, noise_retrace.y),
    284283        vec4(0.0f, 4.0f, 0.25f, noise_retrace.z),
     
    335334    postfx_vignetting = setup_var[k].w; k++;
    336335    k += 3; /* color */
    337     postfx_filter = vec3(setup_var[k].w, setup_var[k + 1].w, setup_var[k + 2].w); k += 3;
    338     postfx_color = vec3(setup_var[k].w, setup_var[k + 1].w, setup_var[k + 2].w); k += 3;
     336    color_filter = vec3(setup_var[k].w, setup_var[k + 1].w, setup_var[k + 2].w); k += 3;
     337    color_color = vec3(setup_var[k].w, setup_var[k + 1].w, setup_var[k + 2].w); k += 3;
    339338    postfx_aberration = setup_var[k].w; k++;
    340339    k += 2; /* noise */
     
    357356{
    358357    int n = !setup_switch ? setup_option_n : setup_item_n;
    359     int v = 0;
    360358    for (int i = 0; i < n; i++)
    361359    {
     
    368366Shader *shader_simple;
    369367Shader *shader_remanency;
    370 Shader *shader_blur_h, *shader_blur_v, *shader_glow, *shader_radial;
     368Shader *shader_blur_h, *shader_blur_v, *shader_glow, *shader_color;
    371369Shader *shader_noise, *shader_postfx;
    372370// shader variables
     
    382380              shader_glow_source,
    383381              shader_glow_mix;
    384 ShaderUniform shader_radial_texture,
    385               shader_radial_screen_size,
    386               shader_radial_time,
    387               shader_radial_value1,
    388               shader_radial_value2,
    389               shader_radial_color;
     382ShaderUniform shader_color_texture,
     383              shader_color_screen_size,
     384              shader_color_filter,
     385              shader_color_color,
     386              shader_color_flash;
    390387ShaderUniform shader_noise_texture,
    391388              shader_noise_screen_size,
     
    401398              shader_postfx_ghost1,
    402399              shader_postfx_ghost2,
    403               shader_postfx_filter,
    404               shader_postfx_color,
    405               shader_postfx_corner,
    406400              shader_postfx_vignetting,
    407401              shader_postfx_aberration,
     
    410404              shader_postfx_scanline_h,
    411405              shader_postfx_scanline_v,
    412               shader_postfx_flash,
     406              shader_postfx_corner,
    413407              shader_postfx_sync;
    414408
     
    478472    shader_blur_v_texture = shader_blur_v->GetUniformLocation("texture");
    479473    shader_blur_v_radius = shader_blur_v->GetUniformLocation("radius");
    480     // shader radial
    481     shader_radial = Shader::Create(lolfx_radial);
    482     shader_radial_texture = shader_radial->GetUniformLocation("texture");
    483     shader_radial_screen_size = shader_radial->GetUniformLocation("screen_size");
    484     shader_radial_time = shader_radial->GetUniformLocation("time");
    485     shader_radial_value1 = shader_radial->GetUniformLocation("value1");
    486     shader_radial_value2 = shader_radial->GetUniformLocation("value2");
    487     shader_radial_color = shader_radial->GetUniformLocation("color");
     474    // shader color
     475    shader_color = Shader::Create(lolfx_color);
     476    shader_color_texture = shader_color->GetUniformLocation("texture");
     477    shader_color_screen_size = shader_color->GetUniformLocation("screen_size");
     478    shader_color_filter = shader_color->GetUniformLocation("filter");
     479    shader_color_color = shader_color->GetUniformLocation("color");
     480    shader_color_flash = shader_color->GetUniformLocation("flash");
    488481    // shader noise
    489482    shader_noise = Shader::Create(lolfx_noise);
     
    503496    shader_postfx_ghost1 = shader_postfx->GetUniformLocation("ghost1");
    504497    shader_postfx_ghost2 = shader_postfx->GetUniformLocation("ghost2");
    505     shader_postfx_filter = shader_postfx->GetUniformLocation("filter");
    506     shader_postfx_color = shader_postfx->GetUniformLocation("color");
    507     shader_postfx_corner = shader_postfx->GetUniformLocation("corner");
    508498    shader_postfx_vignetting = shader_postfx->GetUniformLocation("vignetting");
    509     shader_postfx_aberration = shader_noise->GetUniformLocation("aberration");
     499    shader_postfx_aberration = shader_postfx->GetUniformLocation("aberration");
    510500    shader_postfx_moire_h = shader_postfx->GetUniformLocation("moire_h");
    511501    shader_postfx_moire_v = shader_postfx->GetUniformLocation("moire_v");
    512502    shader_postfx_scanline_h = shader_postfx->GetUniformLocation("scanline_h");
    513503    shader_postfx_scanline_v = shader_postfx->GetUniformLocation("scanline_v");
    514     shader_postfx_flash = shader_postfx->GetUniformLocation("flash");
     504    shader_postfx_corner = shader_postfx->GetUniformLocation("corner");
    515505    shader_postfx_sync = shader_postfx->GetUniformLocation("sync");
    516506
     
    549539    m_shader_glow(true),
    550540    m_shader_blur(true),
     541    m_shader_color(true),
    551542    m_shader_noise(true),
    552543    m_shader_postfx(true)
     
    806797            int bar_w = w / (setup_var[setup_item_key].y - setup_var[setup_item_key].x);
    807798            int bar_x = bar_w * setup_var[setup_item_key].x;
    808             if ((setup_var[setup_item_key].y - setup_var[setup_item_key].x) / setup_var[setup_item_key].z > 2)
     799            if ((setup_var[setup_item_key].y - setup_var[setup_item_key].x) / setup_var[setup_item_key].z > 1)
    809800            {
    810801                caca_printf(m_caca, setup_p.x + setup_size.x - 4, y, "%4.2f", setup_var[setup_item_key].w);
     
    953944    }
    954945
    955     if (m_shader_blur)
    956     {
    957         // shader blur horizontal
     946    if (m_shader_color)
     947    {
     948        // shader color
    958949        fbo_ping->Bind();
    959         shader_blur_h->Bind();
    960         shader_blur_h->SetUniform(shader_blur_h_texture, fbo_front->GetTexture(), 0);
    961         shader_blur_h->SetUniform(shader_blur_h_radius, blur / screen_size.x);
    962         fs_quad();
    963         shader_blur_h->Unbind();
     950        shader_color->Bind();
     951        shader_color->SetUniform(shader_color_texture, fbo_front->GetTexture(), 0);
     952        shader_color->SetUniform(shader_color_screen_size, (vec2)screen_size);
     953        shader_color->SetUniform(shader_color_filter, color_filter);
     954        shader_color->SetUniform(shader_color_color, color_color);
     955        shader_color->SetUniform(shader_color_flash, flash_value);
     956        fs_quad();
     957        shader_color->Unbind();
    964958        fbo_ping->Unbind();
    965         // shader blur vertical
     959        // shader simple
    966960        fbo_front->Bind();
    967         shader_blur_v->Bind();
    968         shader_blur_v->SetUniform(shader_blur_v_texture, fbo_ping->GetTexture(), 0);
    969         shader_blur_v->SetUniform(shader_blur_v_radius, blur / screen_size.y);
    970         fs_quad();
    971         shader_blur_v->Unbind();
     961        draw_shader_simple(fbo_ping, 0);
    972962        fbo_front->Unbind();
    973963    }
     
    993983    }
    994984
     985    if (m_shader_blur)
     986    {
     987        // shader blur horizontal
     988        fbo_ping->Bind();
     989        shader_blur_h->Bind();
     990        shader_blur_h->SetUniform(shader_blur_h_texture, fbo_front->GetTexture(), 0);
     991        shader_blur_h->SetUniform(shader_blur_h_radius, blur / screen_size.x);
     992        fs_quad();
     993        shader_blur_h->Unbind();
     994        fbo_ping->Unbind();
     995        // shader blur vertical
     996        fbo_front->Bind();
     997        shader_blur_v->Bind();
     998        shader_blur_v->SetUniform(shader_blur_v_texture, fbo_ping->GetTexture(), 0);
     999        shader_blur_v->SetUniform(shader_blur_v_radius, blur / screen_size.y);
     1000        fs_quad();
     1001        shader_blur_v->Unbind();
     1002        fbo_front->Unbind();
     1003    }
     1004
    9951005    if (m_shader_postfx)
    9961006    {
     
    10031013        shader_postfx->SetUniform(shader_postfx_ghost1, postfx_ghost1);
    10041014        shader_postfx->SetUniform(shader_postfx_ghost2, postfx_ghost2);
    1005         shader_postfx->SetUniform(shader_postfx_filter, postfx_filter);
    1006         shader_postfx->SetUniform(shader_postfx_color, postfx_color);
    1007         shader_postfx->SetUniform(shader_postfx_corner, postfx_corner);
    10081015        shader_postfx->SetUniform(shader_postfx_vignetting, postfx_vignetting);
    10091016        shader_postfx->SetUniform(shader_postfx_aberration, postfx_aberration);
     
    10121019        shader_postfx->SetUniform(shader_postfx_scanline_h, postfx_scanline_h);
    10131020        shader_postfx->SetUniform(shader_postfx_scanline_v, postfx_scanline_v);
    1014         shader_postfx->SetUniform(shader_postfx_flash, flash_value);
     1021        shader_postfx->SetUniform(shader_postfx_corner, postfx_corner);
    10151022        shader_postfx->SetUniform(shader_postfx_sync, (float)fabs(sync_value*cosf((main_angle-sync_angle)*6.0f)));
    10161023        fs_quad();
Note: See TracChangeset for help on using the changeset viewer.