Changeset 1806


Ignore:
Timestamp:
Aug 24, 2012, 3:21:53 AM (7 years ago)
Author:
rez
Message:

moved noise/offset/retrace into a new shader

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

Legend:

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

    r1656 r1806  
    1212    video/text-render.cpp video/text-render.h \
    1313    video/simple.lolfx \
    14     video/blurh.lolfx video/blurv.lolfx \
    15     video/remanency.lolfx video/glow.lolfx video/postfx.lolfx video/radial.lolfx \
     14    video/blurh.lolfx video/blurv.lolfx video/glow.lolfx video/radial.lolfx \
     15    video/remanency.lolfx video/noise.lolfx video/postfx.lolfx\
    1616    video/text.lolfx
    1717neercs_CPPFLAGS = @LOL_CFLAGS@ @PIPI_CFLAGS@ @CACA_CFLAGS@ -Iold
  • trunk/tools/neercs/neercs.vcxproj

    r1656 r1806  
    7979  </ItemGroup>
    8080  <ItemGroup>
     81    <LolFxCompile Include="video\simple.lolfx" />
     82    <LolFxCompile Include="video\text.lolfx" />
    8183    <LolFxCompile Include="video\blurh.lolfx" />
    8284    <LolFxCompile Include="video\blurv.lolfx" />
    8385    <LolFxCompile Include="video\glow.lolfx" />
    84     <LolFxCompile Include="video\postfx.lolfx" />
    8586    <LolFxCompile Include="video\radial.lolfx" />
    8687    <LolFxCompile Include="video\remanency.lolfx" />
    87     <LolFxCompile Include="video\simple.lolfx" />
    88     <LolFxCompile Include="video\text.lolfx" />
     88    <LolFxCompile Include="video\noise.lolfx" />
     89    <LolFxCompile Include="video\postfx.lolfx" />
    8990  </ItemGroup>
    9091  <PropertyGroup Label="Globals">
  • trunk/tools/neercs/neercs.vcxproj.filters

    r1656 r1806  
    115115  </ItemGroup>
    116116  <ItemGroup>
     117    <LolFxCompile Include="video\simple.lolfx">
     118      <Filter>video</Filter>
     119    </LolFxCompile>
     120    <LolFxCompile Include="video\text.lolfx">
     121      <Filter>video</Filter>
     122    </LolFxCompile>
    117123    <LolFxCompile Include="video\blurh.lolfx">
    118124      <Filter>video</Filter>
     
    124130      <Filter>video</Filter>
    125131    </LolFxCompile>
    126     <LolFxCompile Include="video\postfx.lolfx">
    127       <Filter>video</Filter>
    128     </LolFxCompile>
    129132    <LolFxCompile Include="video\radial.lolfx">
    130133      <Filter>video</Filter>
     
    133136      <Filter>video</Filter>
    134137    </LolFxCompile>
    135     <LolFxCompile Include="video\simple.lolfx">
     138    <LolFxCompile Include="video\noise.lolfx">
    136139      <Filter>video</Filter>
    137140    </LolFxCompile>
    138     <LolFxCompile Include="video\text.lolfx">
     141    <LolFxCompile Include="video\postfx.lolfx">
    139142      <Filter>video</Filter>
    140143    </LolFxCompile>
  • trunk/tools/neercs/video/postfx.lolfx

    r1786 r1806  
    2121uniform vec3 filter;
    2222uniform vec3 color;
    23 uniform vec3 retrace;
    24 uniform vec2 offset;
    25 uniform float noise;
    2623uniform float aberration;
    2724uniform vec4 moire_h;
     
    3431uniform float sync;
    3532
    36 const float PI=3.14159265358979323846;
    37 
    3833vec2 screen(in vec2 p,in float radius)
    3934        {
     
    4540        {
    4641        return texture2D(tex,clamp(p,-1.0,0.0)).xyz;
    47         }
    48 
    49 float rand(in vec2 p)
    50         {
    51         return fract(sin(dot(p,vec2(12.9898,78.233)))*43758.5453);
    5242        }
    5343
     
    6757        float mask=q.x*(6.0-q.x*6.0)*q.y*(6.0-q.y*6.0);
    6858
    69         vec2 rnd=vec2(rand(vec2(p.x+time,p.y-time)),rand(vec2(p.x-time,p.y+time)));
    70 
    71         vec2 o=(offset-offset*2.0*rnd.x)/screen_size;                   // offset
    72         vec3 source=get_color(texture,z+o);                                             // offset added to source
     59        vec3 source=get_color(texture,z);
    7360        vec3 g1=get_color(texture,z1-ghost1.xy);
    7461        vec3 g2=get_color(texture,z2-ghost2.xy);
     
    7764
    7865        vec3 ca;
    79         ca.x=get_color(texture,vec2(z.x+o.x-v,z.y+o.y)).x;
    80         ca.y=get_color(texture,vec2(z.x+o.x  ,z.y+o.y)).y;
    81         ca.z=get_color(texture,vec2(z.x+o.x+v,z.y+o.y)).z;
     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;
    8269
    8370        vec3 c=source+g1*g1*ghost1.w+g2*g2*ghost2.w;                    // mix
     
    9279        c+=flash;                                                                                               // flash
    9380        c+=ca;                                                                                                  // chromatic aberration
    94         c-=retrace.x*mod(z.y*retrace.y+time*retrace.z,1.0);             // retrace
    95         c-=(vec3(rnd.x-rnd.y))*noise;                                                   // noise
    9681        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
    9782        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

    r1803 r1806  
    3232#include "text-render.h"
    3333
     34extern char const *lolfx_simple;
     35extern char const *lolfx_remanency;
    3436extern char const *lolfx_blurh;
    3537extern char const *lolfx_blurv;
    36 extern char const *lolfx_remanency;
    3738extern char const *lolfx_glow;
     39extern char const *lolfx_radial;
     40extern char const *lolfx_noise;
    3841extern char const *lolfx_postfx;
    39 extern char const *lolfx_radial;
    40 extern char const *lolfx_simple;
    4142
    4243#define PID M_PI/180.0f    // pi ratio
     
    9293vec2 glow_small(1.0f,1.0f);     // small glow radius [center,corner]
    9394vec2 blur(0.25f,0.5f);          // glow radius [center,corner]
    94 vec2 postfx_deform(0.7f,0.54f); // deformation [ratio,zoom]
     95vec2 noise_offset(3.0f,3.0f);         // random line [horizontal,vertical]
     96float noise_noise = 0.15f;            // noise
     97vec3 noise_retrace(0.05f,2.0f,4.0f);  // retrace [strength,length,speed]
     98vec2 postfx_deform(0.7f,0.54f);       // deformation [ratio,zoom]
    9599vec3 postfx_filter(0.8f,0.9f,0.4f);   // color filter [red,green,blue]
    96100vec3 postfx_color(1.8f,1.5f,0.5f);    // color modifier [brightness,contrast,grayscale]
    97101vec2 postfx_corner(0.75f,0.95f);      // corner [radius,blur]
    98102float postfx_vignetting = -0.5f;      // vignetting strength
    99 vec3 postfx_retrace(0.05f,2.0f,4.0f); // retrace [strength,length,speed]
    100 vec2 postfx_offset(3.0f,3.0f);  // random line [horizontal,vertical]
    101 float postfx_noise = 0.15f;     // noise
    102 float 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]
     105float postfx_aberration = 4.0f;                 // chromatic aberration
    105106vec4 postfx_moire_h(0.75f,-0.25f,0.0f,1.0f);    // vertical moire [base,variable,repeat x,repeat y]
    106107vec4 postfx_moire_v(0.75f,-0.25f,1.0f,1.5f);    // horizontal moire [base,variable,repeat x,repeat y]
     
    180181        "contrast",
    181182        "grayscale",
    182         "",
     183        "aberration",
    183184        "",
    184185    "noise",
     
    186187        "offset v",
    187188        "noise",
    188         "aberration",
    189189        "retrace strength",
    190190        "retrace length",
    191191        "retrace speed",
     192        "",
    192193        "",
    193194    "ghost",
     
    272273        vec4(0.0f, 4.0f, 0.1f, postfx_color.y),
    273274        vec4(0.0f, 1.5f, 0.1f, postfx_color.z),
    274         vec4(0),
     275        vec4(0.0f, 8.0f, 0.5f, postfx_aberration),
    275276        vec4(0),
    276277    vec4(0), /* noise */
    277         vec4(0.0f, 4.0f, 0.50f, postfx_offset.x),
    278         vec4(0.0f, 4.0f, 0.50f, postfx_offset.y),
    279         vec4(0.0f, 1.0f, 0.05f, postfx_noise),
    280         vec4(0.0f, 8.0f, 0.50f, postfx_aberration),
    281         vec4(0.0f, 0.2f, 0.01f, postfx_retrace.x),
    282         vec4(0.0f, 8.0f, 0.50f, postfx_retrace.y),
    283         vec4(0.0f, 4.0f, 0.25f, postfx_retrace.z),
     278        vec4(0.0f, 4.0f, 0.50f, noise_offset.x),
     279        vec4(0.0f, 4.0f, 0.50f, noise_offset.y),
     280        vec4(0.0f, 1.0f, 0.05f, noise_noise),
     281        vec4(0.0f, 0.2f, 0.01f, noise_retrace.x),
     282        vec4(0.0f, 8.0f, 0.50f, noise_retrace.y),
     283        vec4(0.0f, 4.0f, 0.25f, noise_retrace.z),
     284        vec4(0),
    284285        vec4(0),
    285286    vec4(0), /* ghost */
     
    336337    postfx_filter = vec3(setup_var[k].w, setup_var[k + 1].w, setup_var[k + 2].w); k += 3;
    337338    postfx_color = vec3(setup_var[k].w, setup_var[k + 1].w, setup_var[k + 2].w); k += 3;
    338     k += 3; /* noise */
    339     postfx_offset = vec2(setup_var[k].w, setup_var[k + 1].w); k += 2;
    340     postfx_noise = setup_var[k].w; k++;
    341339    postfx_aberration = setup_var[k].w; k++;
    342     postfx_retrace = vec3(setup_var[k].w, setup_var[k + 1].w, setup_var[k + 2].w); k += 3;
    343     k += 2; /* ghost */
     340    k += 2; /* noise */
     341    noise_offset = vec2(setup_var[k].w, setup_var[k + 1].w); k += 2;
     342    noise_noise = setup_var[k].w; k++;
     343    noise_retrace = vec3(setup_var[k].w, setup_var[k + 1].w, setup_var[k + 2].w); k += 3;
     344    k += 3; /* ghost */
    344345    postfx_ghost1 = vec4(setup_var[k].w, setup_var[k + 1].w, setup_var[k + 2].w, setup_var[k + 3].w); k += 4;
    345346    postfx_ghost2 = vec4(setup_var[k].w, setup_var[k + 1].w, setup_var[k + 2].w, setup_var[k + 3].w); k += 4;
     
    365366
    366367Shader *shader_simple;
    367 Shader *shader_blur_h, *shader_blur_v;
    368 Shader *shader_remanency, *shader_glow, *shader_radial, *shader_postfx;
     368Shader *shader_remanency;
     369Shader *shader_blur_h, *shader_blur_v, *shader_glow, *shader_radial;
     370Shader *shader_noise, *shader_postfx;
    369371// shader variables
    370372ShaderUniform shader_simple_texture;
     
    372374              shader_remanency_buffer,
    373375              shader_remanency_mix;
    374 ShaderUniform shader_glow_glow,
    375               shader_glow_source,
    376               shader_glow_mix;
    377376ShaderUniform shader_blur_h_texture,
    378377              shader_blur_h_radius,
    379378              shader_blur_v_texture,
    380379              shader_blur_v_radius;
     380ShaderUniform shader_glow_glow,
     381              shader_glow_source,
     382              shader_glow_mix;
    381383ShaderUniform shader_radial_texture,
    382384              shader_radial_screen_size,
     
    385387              shader_radial_value2,
    386388              shader_radial_color;
     389ShaderUniform shader_noise_texture,
     390              shader_noise_screen_size,
     391              shader_noise_time,
     392              shader_noise_offset,
     393              shader_noise_noise,
     394              shader_noise_retrace;
    387395ShaderUniform shader_postfx_texture,
    388396              shader_postfx_texture_2d,
     
    396404              shader_postfx_corner,
    397405              shader_postfx_vignetting,
    398               shader_postfx_retrace,
    399               shader_postfx_offset,
    400               shader_postfx_noise,
    401406              shader_postfx_aberration,
    402407              shader_postfx_moire_h,
     
    480485    shader_radial_value2 = shader_radial->GetUniformLocation("value2");
    481486    shader_radial_color = shader_radial->GetUniformLocation("color");
     487    // shader noise
     488    shader_noise = Shader::Create(lolfx_noise);
     489    shader_noise_texture = shader_noise->GetUniformLocation("texture");
     490    shader_noise_screen_size = shader_noise->GetUniformLocation("screen_size");
     491    shader_noise_time = shader_noise->GetUniformLocation("time");
     492    shader_noise_offset = shader_noise->GetUniformLocation("offset");
     493    shader_noise_noise = shader_noise->GetUniformLocation("noise");
     494    shader_noise_retrace = shader_noise->GetUniformLocation("retrace");
    482495    // shader postfx
    483496    shader_postfx = Shader::Create(lolfx_postfx);
     
    493506    shader_postfx_corner = shader_postfx->GetUniformLocation("corner");
    494507    shader_postfx_vignetting = shader_postfx->GetUniformLocation("vignetting");
    495     shader_postfx_retrace = shader_postfx->GetUniformLocation("retrace");
    496     shader_postfx_offset = shader_postfx->GetUniformLocation("offset");
    497     shader_postfx_noise = shader_postfx->GetUniformLocation("noise");
    498     shader_postfx_aberration = shader_postfx->GetUniformLocation("aberration");
     508    shader_postfx_aberration = shader_noise->GetUniformLocation("aberration");
    499509    shader_postfx_moire_h = shader_postfx->GetUniformLocation("moire_h");
    500510    shader_postfx_moire_v = shader_postfx->GetUniformLocation("moire_v");
     
    538548    m_shader_glow(true),
    539549    m_shader_blur(true),
     550    m_shader_noise(true),
    540551    m_shader_postfx(true)
    541552{
     
    572583        glPolygonMode(GL_FRONT, polygon_fillmode);
    573584    }
    574     if (Input::WasPressed(Key::F3))
    575     {
    576         m_shader_glow = !m_shader_glow;
    577         m_shader_blur = !m_shader_blur;
    578     }
    579     if (Input::WasPressed(Key::F4))
    580     {
    581         m_shader_postfx = !m_shader_postfx;
    582     }
    583     if (Input::WasPressed(Key::F5))
    584     {
    585         Pause();
    586     }
    587585   if (Input::WasPressed(Key::Tab))
    588586    {
     
    674672        }
    675673    }
     674    if (Input::WasPressed(Key::Home))
     675    {
     676        if (m_setup && setup_switch)
     677        {
     678            setup_var[setup_item_key].w = setup_var[setup_item_key].x;
     679            Render::UpdateVar();
     680        }
     681    }
     682    if (Input::WasPressed(Key::End))
     683    {
     684        if (m_setup && setup_switch)
     685        {
     686            setup_var[setup_item_key].w = setup_var[setup_item_key].y;
     687            Render::UpdateVar();
     688        }
     689    }
    676690    if (Input::WasPressed(Key::Return))
    677691    {
    678         sync_flag = true;
    679         sync_angle = main_angle;
     692        fade_flag = true;
     693        fade_angle = main_angle;
    680694    }
    681695
     
    958972    }
    959973
     974    if (m_shader_noise)
     975    {
     976        // shader noise
     977        fbo_ping->Bind();
     978        shader_noise->Bind();
     979        shader_noise->SetUniform(shader_noise_texture, fbo_front->GetTexture(), 0);
     980        shader_noise->SetUniform(shader_noise_screen_size, (vec2)screen_size);
     981        shader_noise->SetUniform(shader_noise_time, fx_angle);
     982        shader_noise->SetUniform(shader_noise_offset, noise_offset);
     983        shader_noise->SetUniform(shader_noise_noise, noise_noise);
     984        shader_noise->SetUniform(shader_noise_retrace, noise_retrace);
     985        fs_quad();
     986        shader_noise->Unbind();
     987        fbo_ping->Unbind();
     988        // shader simple
     989        fbo_front->Bind();
     990        draw_shader_simple(fbo_ping, 0);
     991        fbo_front->Unbind();
     992    }
     993
    960994    if (m_shader_postfx)
    961995    {
     
    9721006        shader_postfx->SetUniform(shader_postfx_corner, postfx_corner);
    9731007        shader_postfx->SetUniform(shader_postfx_vignetting, postfx_vignetting);
    974         shader_postfx->SetUniform(shader_postfx_retrace, postfx_retrace);
    975         shader_postfx->SetUniform(shader_postfx_offset, postfx_offset);
    976         shader_postfx->SetUniform(shader_postfx_noise, postfx_noise);
    9771008        shader_postfx->SetUniform(shader_postfx_aberration, postfx_aberration);
    9781009        shader_postfx->SetUniform(shader_postfx_moire_h, postfx_moire_h);
  • trunk/tools/neercs/video/render.h

    r1736 r1806  
    3737    bool m_shader_blur;
    3838    bool m_shader_glow;
     39    bool m_shader_radial;
     40    bool m_shader_noise;
    3941    bool m_shader_postfx;
    4042};
  • trunk/tools/neercs/video/simple.lolfx

    r1582 r1806  
    44
    55void main()
    6 {
    7     gl_Position = gl_Vertex;
    8     gl_TexCoord[0] = gl_MultiTexCoord0;
    9 }
     6        {
     7        gl_Position = gl_Vertex;
     8        gl_TexCoord[0] = gl_MultiTexCoord0;
     9        }
    1010
    1111-- GLSL.Frag --
     
    1616
    1717void main(void)
    18 {
    19     gl_FragColor = texture2D(texture, gl_TexCoord[0].xy);
    20 }
    21 
     18        {
     19        gl_FragColor = texture2D(texture, gl_TexCoord[0].xy);
     20        }
Note: See TracChangeset for help on using the changeset viewer.