Changeset 1665


Ignore:
Timestamp:
Jul 25, 2012, 2:36:30 AM (8 years ago)
Author:
rez
Message:

modified A LOT postfx, added MOAR controls to all effects, especially for moire/scanline

Location:
trunk/tools/neercs/video
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/tools/neercs/video/postfx.lolfx

    r1663 r1665  
    1616uniform vec2 screen_size;
    1717uniform float time;
     18uniform float deform;
     19uniform vec3 filter;
     20uniform vec3 retrace;
    1821uniform float noise;
    1922uniform float noise_h;
    2023uniform float noise_v;
    2124uniform float aberration;
    22 uniform float deform;
     25uniform bool moire;
     26uniform vec4 moire_h;
     27uniform vec4 moire_v;
    2328uniform bool scanline;
    24 uniform float scanline_h_base;
    25 uniform float scanline_h_var;
    26 uniform float scanline_h_repeat_x;
    27 uniform float scanline_h_repeat_y;
    28 uniform float scanline_v_base;
    29 uniform float scanline_v_var;
    30 uniform float scanline_v_repeat_x;
    31 uniform float scanline_v_repeat_y;
     29uniform vec4 scanline_h;
     30uniform vec4 scanline_v;
    3231uniform float flash;
    3332uniform float sync;
     
    8281        float v=aberration/float(screen_size.x)+aberration/float(screen_size.x)*(2.0-mask);
    8382
    84         vec3 noise;
    85         noise.x=get_color(texture,vec2(z.x+d1-v,z.y+d2)).x;
    86         noise.y=get_color(texture,vec2(z.x+d1  ,z.y+d2)).y;
    87         noise.z=get_color(texture,vec2(z.x+d1+v,z.y+d2)).z;
     83        vec3 scramble;
     84        scramble.x=get_color(texture,vec2(z.x+d1-v,z.y+d2)).x;
     85        scramble.y=get_color(texture,vec2(z.x+d1  ,z.y+d2)).y;
     86        scramble.z=get_color(texture,vec2(z.x+d1+v,z.y+d2)).z;
    8887
    89         vec3 color=source+glass1*glass1*0.25+glass2*glass2*0.25+(scanline?noise:source);
     88        vec3 color=source+glass1*glass1*0.25+glass2*glass2*0.25;
    9089
    9190        color+=flash;                                                                                                   // flash
    92         if(scanline)
     91        color+=scramble;                                                                                                // scramble
     92        color-=retrace.x*mod(z.y*retrace.y+time*retrace.z,1.0);                 // retrace
     93        color-=(vec3(rnd1,rnd1,rnd1)-vec3(rnd2,rnd2,rnd2))*noise;               // noise
     94        if(moire)
    9395                {
    94                 color-=0.0125*mod(z.y*4.0+time*0.25,1.0);                                       // electron beam
    95                 color-=(vec3(rnd1,rnd1,rnd1)-vec3(rnd2,rnd2,rnd2))*noise;       // noise
    96                 color*=scanline_h_base+scanline_h_var*cos(z.x*float(screen_size.x*scanline_h_repeat_x))*sin(z.y*float(screen_size.y*scanline_h_repeat_y));      // scanline w
    97                 color*=scanline_v_base+scanline_v_var*sin(z.y*float(screen_size.x*scanline_v_repeat_x))*cos(z.y*float(screen_size.y*scanline_v_repeat_y));      // scanline h
     96                color*=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
     97                color*=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
    9898                }
    9999        else
    100100                {
    101                 color*=0.675;
     101                color*=(moire_h.x+moire_v.x)*0.5;
    102102                }
    103         color=vec3(color.x*0.875,color.y*1.0,color.z*0.75);                             // hue
     103        if(scanline)
     104                {
     105                color*=scanline_h.x+scanline_h.y*cos(z.y*float(screen_size.y*scanline_h.z+scanline_h.w));       // scanline h
     106                color*=scanline_v.x+scanline_v.y*cos(z.x*float(screen_size.x*scanline_v.z+scanline_v.w));       // scanline v
     107                }
     108        else
     109                {
     110                color*=(scanline_h.x+scanline_v.x)*0.5;
     111                }
     112        color*=filter;                                                                                                  // hue
    104113        color*=mask;                                                                                                    // vignetting
    105114        color*=letterbox(z,-0.75,0.95);                                                                 // letterbox
  • trunk/tools/neercs/video/render.cpp

    r1663 r1665  
    100100float blur_radius_deform = 0.625f;// glow radius deform
    101101int glow_fbo_size = 2;          // glow fbo size
    102 float glow_smoothstep = 0.0f;   // glow smoothstep value (try 0.025f)
    103 float glow_mix_ratio1 = 0.375f; // glow mixing ratio
    104 float glow_mix_ratio2 = 0.625f; // source mixing ratio
    105 float glow_radius1 = 2.0f;      // large glow radius
    106 float glow_radius2 = 1.0f;      // small glow radius
    107 float glow_radius_deform1 = 3.0f;// large glow radius deform
    108 float glow_radius_deform2 = 1.5f;// small glow radius deform
     102float glow_smoothstep = 0.1f;   // glow smoothstep value (try 0.025f)
     103vec3 glow_large(0.75f,2.0f,3.0f);// large glow [mix,ratio normal,ratio deform]
     104vec3 glow_small(0.50f,1.0f,1.5f);// small glow [mix,ratio normal,ratio deform]
     105//---------------------------------[IDEAS] http://www.youtube.com/watch?v=d1qEP2vMe-I
    109106float postfx_deform = 0.625f;   // deformation ratio
     107vec3 postfx_filter(0.875f,1.0f,0.75f);// color filter
     108vec3 postfx_retrace(0.025f,2.0f,2.0f);// retrace [color,repeat,speed]
    110109float postfx_noise = 0.125f;    // global noise
    111110float postfx_noise_h = 3.0f;    // horizontal noise
    112111float postfx_noise_v = 3.0f;    // vertical noise
    113112float postfx_aberration = 3.0f; // chromatic aberration
     113bool postfx_moire = true;       // moire
     114vec4 postfx_moire_h(0.75f,0.25f,1.5f,2.0f);
     115vec4 postfx_moire_v(0.75f,0.25f,1.5f,1.0f);
    114116bool postfx_scanline = true;    // scanline
    115 float postfx_scanline_h_base = 0.75f;
    116 float postfx_scanline_h_var = 0.25f;
    117 float postfx_scanline_h_repeat_x = 1.0f;
    118 float postfx_scanline_h_repeat_y = 1.0f;
    119 float postfx_scanline_v_base = 0.75f;
    120 float postfx_scanline_v_var = 0.5f;
    121 float postfx_scanline_v_repeat_x = 0.0f;
    122 float postfx_scanline_v_repeat_y = 1.0f;
     117vec4 postfx_scanline_h(0.5f,0.5f,2.0f,0.0f);
     118vec4 postfx_scanline_v(1.0f,0.0f,0.0f,0.0f);
    123119//float radial_value1 = 2.0f;
    124120//float radial_value2 = 0.8f;
     
    162158              shader_postfx_time,
    163159              shader_postfx_deform,
     160              shader_postfx_filter,
     161              shader_postfx_retrace,
    164162              shader_postfx_noise,
    165163              shader_postfx_noise_h,
    166164              shader_postfx_noise_v,
    167165              shader_postfx_aberration,
     166              shader_postfx_moire,
     167              shader_postfx_moire_h,
     168              shader_postfx_moire_v,
    168169              shader_postfx_scanline,
    169               shader_postfx_scanline_h_base,
    170               shader_postfx_scanline_h_var,
    171               shader_postfx_scanline_h_repeat_x,
    172               shader_postfx_scanline_h_repeat_y,
    173               shader_postfx_scanline_v_base,
    174               shader_postfx_scanline_v_var,
    175               shader_postfx_scanline_v_repeat_x,
    176               shader_postfx_scanline_v_repeat_y,
     170              shader_postfx_scanline_h,
     171              shader_postfx_scanline_v,
    177172              shader_postfx_flash,
    178173              shader_postfx_sync;
     
    269264    shader_postfx_time = shader_postfx->GetUniformLocation("time");
    270265    shader_postfx_deform = shader_postfx->GetUniformLocation("deform");
     266    shader_postfx_filter = shader_postfx->GetUniformLocation("filter");
     267    shader_postfx_retrace = shader_postfx->GetUniformLocation("retrace");
    271268    shader_postfx_noise = shader_postfx->GetUniformLocation("noise");
    272269    shader_postfx_noise_h = shader_postfx->GetUniformLocation("noise_h");
    273270    shader_postfx_noise_v = shader_postfx->GetUniformLocation("noise_v");
    274271    shader_postfx_aberration = shader_postfx->GetUniformLocation("aberration");
     272    shader_postfx_moire = shader_postfx->GetUniformLocation("moire");
     273    shader_postfx_moire_h = shader_postfx->GetUniformLocation("moire_h");
     274    shader_postfx_moire_v = shader_postfx->GetUniformLocation("moire_v");
    275275    shader_postfx_scanline = shader_postfx->GetUniformLocation("scanline");
    276     shader_postfx_scanline_h_base = shader_postfx->GetUniformLocation("scanline_h_base");
    277     shader_postfx_scanline_h_var = shader_postfx->GetUniformLocation("scanline_h_var");
    278     shader_postfx_scanline_h_repeat_x = shader_postfx->GetUniformLocation("scanline_h_repeat_x");
    279     shader_postfx_scanline_h_repeat_y = shader_postfx->GetUniformLocation("scanline_h_repeat_y");
    280     shader_postfx_scanline_v_base = shader_postfx->GetUniformLocation("scanline_v_base");
    281     shader_postfx_scanline_v_var = shader_postfx->GetUniformLocation("scanline_v_var");
    282     shader_postfx_scanline_v_repeat_x = shader_postfx->GetUniformLocation("scanline_v_repeat_x");
    283     shader_postfx_scanline_v_repeat_y = shader_postfx->GetUniformLocation("scanline_v_repeat_y");
     276    shader_postfx_scanline_h = shader_postfx->GetUniformLocation("scanline_h");
     277    shader_postfx_scanline_v = shader_postfx->GetUniformLocation("scanline_v");
    284278    shader_postfx_flash = shader_postfx->GetUniformLocation("flash");
    285279    shader_postfx_sync = shader_postfx->GetUniformLocation("sync");
     
    542536        shader_blur_h->SetTexture(shader_blur_h_texture, fbo_ping->GetTexture(), 0);
    543537        shader_blur_h->SetUniform(shader_blur_h_screen_size, vec2(1.0f / glow_fbo_size));
    544         shader_blur_h->SetUniform(shader_blur_h_blur, glow_radius1 / screen_size.x);
    545         shader_blur_h->SetUniform(shader_blur_h_deform, glow_radius_deform1 / screen_size.x);
     538        shader_blur_h->SetUniform(shader_blur_h_blur, glow_large.y / screen_size.x);
     539        shader_blur_h->SetUniform(shader_blur_h_deform, glow_large.z / screen_size.x);
    546540        fs_quad();
    547541        shader_blur_h->Unbind();
     
    552546        shader_blur_v->SetTexture(shader_blur_v_texture, fbo_blur_h->GetTexture(), 0);
    553547        shader_blur_v->SetUniform(shader_blur_v_screen_size, vec2(1.0f / glow_fbo_size));
    554         shader_blur_v->SetUniform(shader_blur_v_blur, glow_radius1 / screen_size.y);
    555         shader_blur_v->SetUniform(shader_blur_v_deform, glow_radius_deform1 / screen_size.y);
     548        shader_blur_v->SetUniform(shader_blur_v_blur, glow_large.y / screen_size.y);
     549        shader_blur_v->SetUniform(shader_blur_v_deform, glow_large.z / screen_size.y);
    556550        fs_quad();
    557551        shader_blur_v->Unbind();
     
    562556        shader_blur_h->SetTexture(shader_blur_h_texture, fbo_blur_v->GetTexture(), 0);
    563557        shader_blur_h->SetUniform(shader_blur_h_screen_size, vec2(1.0f / glow_fbo_size));
    564         shader_blur_h->SetUniform(shader_blur_h_blur, glow_radius2 / screen_size.x);
    565         shader_blur_h->SetUniform(shader_blur_h_deform, glow_radius_deform2 / screen_size.x);
     558        shader_blur_h->SetUniform(shader_blur_h_blur, glow_small.y / screen_size.x);
     559        shader_blur_h->SetUniform(shader_blur_h_deform, glow_small.z / screen_size.x);
    566560        fs_quad();
    567561        shader_blur_h->Unbind();
     
    572566        shader_blur_v->SetTexture(shader_blur_v_texture, fbo_blur_h->GetTexture(), 0);
    573567        shader_blur_v->SetUniform(shader_blur_v_screen_size, vec2(1.0f / glow_fbo_size));
    574         shader_blur_v->SetUniform(shader_blur_v_blur, glow_radius2 / screen_size.y);
    575         shader_blur_h->SetUniform(shader_blur_v_deform, glow_radius_deform2 / screen_size.y);
     568        shader_blur_v->SetUniform(shader_blur_v_blur, glow_small.y / screen_size.y);
     569        shader_blur_h->SetUniform(shader_blur_v_deform, glow_small.z / screen_size.y);
    576570        fs_quad();
    577571        shader_blur_v->Unbind();
     
    585579        shader_glow->SetUniform(shader_glow_time, fx_angle);
    586580        shader_glow->SetUniform(shader_glow_step, glow_smoothstep);
    587         shader_glow->SetUniform(shader_glow_value1, glow_mix_ratio1);
    588         shader_glow->SetUniform(shader_glow_value2, glow_mix_ratio2);
     581        shader_glow->SetUniform(shader_glow_value1, glow_large.x);
     582        shader_glow->SetUniform(shader_glow_value2, glow_small.x);
    589583        fs_quad();
    590584        shader_glow->Unbind();
     
    605599        shader_postfx->SetUniform(shader_postfx_time, fx_angle);
    606600        shader_postfx->SetUniform(shader_postfx_deform, postfx_deform);
     601        shader_postfx->SetUniform(shader_postfx_filter, postfx_filter);
     602        shader_postfx->SetUniform(shader_postfx_retrace, postfx_retrace);
    607603        shader_postfx->SetUniform(shader_postfx_noise, postfx_noise);
    608604        shader_postfx->SetUniform(shader_postfx_noise_h, postfx_noise_h);
    609605        shader_postfx->SetUniform(shader_postfx_noise_v, postfx_noise_v);
    610606        shader_postfx->SetUniform(shader_postfx_aberration, postfx_aberration);
     607        shader_postfx->SetUniform(shader_postfx_moire, postfx_moire);
     608        shader_postfx->SetUniform(shader_postfx_moire_h, postfx_moire_h);
     609        shader_postfx->SetUniform(shader_postfx_moire_v, postfx_moire_v);
    611610        shader_postfx->SetUniform(shader_postfx_scanline, postfx_scanline);
    612         shader_postfx->SetUniform(shader_postfx_scanline_h_base, postfx_scanline_h_base);
    613         shader_postfx->SetUniform(shader_postfx_scanline_h_var, postfx_scanline_h_var);
    614         shader_postfx->SetUniform(shader_postfx_scanline_h_repeat_x, postfx_scanline_h_repeat_x);
    615         shader_postfx->SetUniform(shader_postfx_scanline_h_repeat_y, postfx_scanline_h_repeat_y);
    616         shader_postfx->SetUniform(shader_postfx_scanline_v_base, postfx_scanline_v_base);
    617         shader_postfx->SetUniform(shader_postfx_scanline_v_var, postfx_scanline_v_var);
    618         shader_postfx->SetUniform(shader_postfx_scanline_v_repeat_x, postfx_scanline_v_repeat_x);
    619         shader_postfx->SetUniform(shader_postfx_scanline_v_repeat_y, postfx_scanline_v_repeat_y);
     611        shader_postfx->SetUniform(shader_postfx_scanline_h, postfx_scanline_h);
     612        shader_postfx->SetUniform(shader_postfx_scanline_v, postfx_scanline_v);
    620613        shader_postfx->SetUniform(shader_postfx_flash, flash_value);
    621614        shader_postfx->SetUniform(shader_postfx_sync, (float)fabs(beat_value*cosf((main_angle-beat_angle)*8.0f)));
Note: See TracChangeset for help on using the changeset viewer.