Changeset 1820


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

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

Location:
trunk/tools/neercs
Files:
7 edited
1 moved

Legend:

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

    r1806 r1820  
    1212    video/text-render.cpp video/text-render.h \
    1313    video/simple.lolfx \
    14     video/blurh.lolfx video/blurv.lolfx video/glow.lolfx video/radial.lolfx \
     14    video/blurh.lolfx video/blurv.lolfx video/glow.lolfx video/color.lolfx \
    1515    video/remanency.lolfx video/noise.lolfx video/postfx.lolfx\
    1616    video/text.lolfx
  • trunk/tools/neercs/neercs.vcxproj

    r1806 r1820  
    8484    <LolFxCompile Include="video\blurv.lolfx" />
    8585    <LolFxCompile Include="video\glow.lolfx" />
    86     <LolFxCompile Include="video\radial.lolfx" />
     86    <LolFxCompile Include="video\color.lolfx" />
    8787    <LolFxCompile Include="video\remanency.lolfx" />
    8888    <LolFxCompile Include="video\noise.lolfx" />
  • trunk/tools/neercs/neercs.vcxproj.filters

    r1806 r1820  
    130130      <Filter>video</Filter>
    131131    </LolFxCompile>
    132     <LolFxCompile Include="video\radial.lolfx">
     132    <LolFxCompile Include="video\color.lolfx">
    133133      <Filter>video</Filter>
    134134    </LolFxCompile>
  • trunk/tools/neercs/video/color.lolfx

    r1819 r1820  
    1515uniform sampler2D texture;
    1616uniform vec2 screen_size;
    17 uniform float time;
    18 uniform float value1;
    19 uniform float value2;
    20 uniform float color;
    21 
    22 float PI=3.14159265358979323846;
    23 
    24 vec3 deform(in vec2 p)
    25         {
    26         vec2 uv;
    27         float zoom=0.5;
    28         uv.x=p.x*zoom-0.5;
    29         uv.y=p.y*zoom-0.5;
    30         return texture2D(texture,uv).xyz;
    31         }
     17uniform vec3 filter;
     18uniform vec3 color;
     19uniform float flash;
    3220
    3321void main(void)
    3422        {
    35         int n=32;
     23        vec2 p=gl_FragCoord.xy/screen_size.xy;
     24        vec3 c=texture2D(texture,p).xyz;
    3625
    37         vec2 p=-1.0+4.0*gl_TexCoord[0].xy;
    38         vec2 s=p;
    39         vec3 source=deform(s);
     26        float a=(c.x+c.y+c.z)/3.0;
     27        c=mix(c,vec3(a),color.z);                                                               // grayscale
     28        c*=filter;                                                                                              // filter
     29        c*=color.x;                                                                                             // brightness
     30        c=0.5+(c-0.5)*color.y;                                                                  // contrast
     31        c+=flash;                                                                                               // flash
    4032
    41         vec3 total=vec3(0,1.0,1.0);
    42 
    43         vec2 d=-p/float(n*2);
    44         float w=value1;
    45         for(int i=0;i<n;i++)
    46                 {
    47                 vec3 c=deform(s);
    48                 vec3 data=c+vec3(c.x*color-p.x*color,c.z*color+p.y*color,c.y*color+p.x*color);
    49                 total+=data*w;
    50                 w*=value2;
    51                 s+=d;
    52                 }
    53         gl_FragColor=vec4(source*0.625+total*0.025,1.0);
     33        gl_FragColor=vec4(c,1.0);
    5434        }
  • trunk/tools/neercs/video/noise.lolfx

    r1814 r1820  
    3333        vec2 o=(offset-offset*2.0*r1)/screen_size;
    3434
    35         vec3 c=texture2D(texture,p+o).xyz;                                              // offset
    36         c*=1.0+(noise-noise*2.0*r1);                                                    // noise
    37         c-=retrace.x*mod(p.y*retrace.y+time*retrace.z,1.0);             // retrace
     35        vec3 c=texture2D(texture,p+o).xyz;                                                      // offset
     36        c*=1.0+(noise-noise*2.0*r1);                                                            // noise
     37        c-=retrace.x*0.01*mod(p.y*retrace.y+time*retrace.z,1.0);        // retrace
    3838        gl_FragColor=vec4(c,1.0);
    3939        }
  • trunk/tools/neercs/video/postfx.lolfx

    r1810 r1820  
    1919uniform vec4 ghost1;
    2020uniform vec4 ghost2;
    21 uniform vec3 filter;
    22 uniform vec3 color;
     21uniform float vignetting;
    2322uniform float aberration;
    2423uniform vec4 moire_h;
     
    2726uniform vec4 scanline_v;
    2827uniform vec2 corner;
    29 uniform float vignetting;
    30 uniform float flash;
    3128uniform float sync;
    3229
     
    5249        vec2 p=-1.0+2.0*gl_FragCoord.xy/screen_size.xy;
    5350        p.y+=0.025*sync;
    54         vec2 z =screen(p,deform.y);
     51        vec2 z=screen(p,deform.y);
    5552        vec2 z1=screen(p,deform.y+ghost1.z*0.01);
    5653        vec2 z2=screen(p,deform.y+ghost2.z*0.01);
     
    6158        vec3 g2=get_color(texture,z2-ghost2.xy);
    6259
    63         float v=aberration/float(screen_size.x)+aberration/float(screen_size.x)*(2.0-mask);
    64 
    65         vec3 ca;
    66         ca.x=get_color(texture,vec2(z.x-v,z.y)).x;
    67         ca.y=get_color(texture,vec2(z.x  ,z.y)).y;
    68         ca.z=get_color(texture,vec2(z.x+v,z.y)).z;
    69 
    7060        vec3 c=source+g1*g1*ghost1.w+g2*g2*ghost2.w;                    // mix
    7161
    72         float a=(c.x+c.y+c.z)/3.0;
    73         vec3 g=vec3(a,a,a);
    74         c=mix(c,g,color.z);                                                                             // gray
    75         c*=filter;                                                                                              // filter
    76         c*=color.x;                                                                                             // brightness
    77         c=0.5+(c-0.5)*color.y;                                                                  // contrast
     62        float v=aberration/float(screen_size.x)+aberration/float(screen_size.x)*(2.0-mask);
     63        vec3 ca1=get_color(texture,vec2(z.x-v,z.y));
     64        vec3 ca2=get_color(texture,vec2(z.x+v,z.y));
     65        c+=vec3(ca1.x,c.y,ca2.z);                                                               // chromatic aberration
    7866
    79         c+=flash;                                                                                               // flash
    80         c+=ca;                                                                                                  // chromatic aberration
    8167        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
    8268        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
  • 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();
  • trunk/tools/neercs/video/render.h

    r1806 r1820  
    3535    bool m_shader;
    3636    bool m_shader_remanency;
     37    bool m_shader_glow;
    3738    bool m_shader_blur;
    38     bool m_shader_glow;
    39     bool m_shader_radial;
     39    bool m_shader_color;
    4040    bool m_shader_noise;
    4141    bool m_shader_postfx;
Note: See TracChangeset for help on using the changeset viewer.