From 3321f8908ac6052d7fa3c0ad70b15cba666697eb Mon Sep 17 00:00:00 2001 From: rez Date: Wed, 25 Jul 2012 23:43:39 +0000 Subject: [PATCH] updated postfx.lol --- neercs/video/postfx.lolfx | 31 ++++++++++++------------------- neercs/video/render.cpp | 24 ++++++++++-------------- 2 files changed, 22 insertions(+), 33 deletions(-) diff --git a/neercs/video/postfx.lolfx b/neercs/video/postfx.lolfx index 02303ab..c8fc82e 100644 --- a/neercs/video/postfx.lolfx +++ b/neercs/video/postfx.lolfx @@ -18,9 +18,8 @@ uniform float time; uniform float deform; uniform vec3 filter; uniform vec3 retrace; -uniform float noise; -uniform float noise_h; -uniform float noise_v; +uniform vec2 offset; +uniform vec2 noise; uniform float aberration; uniform bool moire; uniform vec4 moire_h; @@ -65,32 +64,26 @@ void main(void) vec2 z2=zoom(p,0.5275); float mask=q.x*(6.0-q.x*6.0)*q.y*(6.0-q.y*6.0); - float rnd1=rand(vec2(p.x+time,p.y-time)); - float rnd2=rand(vec2(p.x-time,p.y+time)); - float d1=(noise_h-noise_h*2.0*rnd1)/float(screen_size.x); - float d2=(noise_v-noise_v*2.0*rnd1)/float(screen_size.y); - - vec3 source; - source.x=get_color(texture,vec2(z.x+d1,z.y)).x; - source.y=get_color(texture,vec2(z.x+d1,z.y)).y; - source.z=get_color(texture,vec2(z.x+d1,z.y)).z; + vec2 rnd=vec2(rand(vec2(p.x+time,p.y-time)),rand(vec2(p.x-time,p.y+time))); + vec2 o=(offset-offset*2.0*rnd.x)/screen_size; // offset + vec3 source=get_color(texture,z+o); // offset added to source vec3 glass1=get_color(texture,z1); vec3 glass2=get_color(texture,z2); float v=aberration/float(screen_size.x)+aberration/float(screen_size.x)*(2.0-mask); - vec3 scramble; - scramble.x=get_color(texture,vec2(z.x+d1-v,z.y+d2)).x; - scramble.y=get_color(texture,vec2(z.x+d1 ,z.y+d2)).y; - scramble.z=get_color(texture,vec2(z.x+d1+v,z.y+d2)).z; + vec3 ca; + ca.x=get_color(texture,vec2(z.x+o.x-v,z.y+o.y)).x; + ca.y=get_color(texture,vec2(z.x+o.x ,z.y+o.y)).y; + ca.z=get_color(texture,vec2(z.x+o.x+v,z.y+o.y)).z; vec3 color=source+glass1*glass1*0.25+glass2*glass2*0.25; color+=flash; // flash - color+=scramble; // scramble + color+=ca; // chromatic aberration color-=retrace.x*mod(z.y*retrace.y+time*retrace.z,1.0); // retrace - color-=(vec3(rnd1,rnd1,rnd1)-vec3(rnd2,rnd2,rnd2))*noise; // noise + color-=(vec3(rnd.x,rnd.x,rnd.x)-vec3(rnd.y,rnd.y,rnd.y))*noise.y;// noise if(moire) { 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 @@ -111,6 +104,6 @@ void main(void) } color*=filter; // hue color*=mask; // vignetting - color*=letterbox(z,-0.75,0.95); // letterbox + color*=letterbox(z,-0.75,0.95); // letnoiseterbox gl_FragColor=vec4(color,1.0); } \ No newline at end of file diff --git a/neercs/video/render.cpp b/neercs/video/render.cpp index e03f716..cd480ec 100644 --- a/neercs/video/render.cpp +++ b/neercs/video/render.cpp @@ -104,17 +104,16 @@ vec3 glow_large(0.75f,2.0f,3.0f);// large glow [mix,ratio normal,ratio deform] vec3 glow_small(0.50f,1.0f,1.5f);// small glow [mix,ratio normal,ratio deform] //---------------------------------[IDEAS] http://www.youtube.com/watch?v=d1qEP2vMe-I float postfx_deform = 0.625f; // deformation ratio -vec3 postfx_filter(0.875f,1.0f,0.75f);// color filter -vec3 postfx_retrace(0.025f,2.0f,2.0f);// retrace [color,repeat,speed] -float postfx_noise = 0.125f; // global noise -float postfx_noise_h = 3.0f; // horizontal noise -float postfx_noise_v = 3.0f; // vertical noise +vec3 postfx_filter(0.875f,1.0f,0.75f);// color filter [red,green,blue] +vec3 postfx_retrace(0.025f,2.0f,4.0f);// retrace [color,length,speed] +vec2 postfx_offset(3.0f,3.0f); // random line [horizontal,vertical] +vec2 postfx_noise(0,0.125f); // noise [0=grey/1=color,mix] float postfx_aberration = 3.0f; // chromatic aberration bool postfx_moire = true; // moire -vec4 postfx_moire_h(0.75f,0.25f,1.5f,2.0f); -vec4 postfx_moire_v(0.75f,0.25f,1.5f,1.0f); +vec4 postfx_moire_h(0.75f,0.25f,0.5f,1.5f); +vec4 postfx_moire_v(0.75f,0.25f,0.5f,1.5f); bool postfx_scanline = true; // scanline -vec4 postfx_scanline_h(0.5f,0.5f,2.0f,0.0f); +vec4 postfx_scanline_h(0.75f,0.25f,1.0f,0.0f);// vertical scanline [base,variable,repeat] vec4 postfx_scanline_v(1.0f,0.0f,0.0f,0.0f); //float radial_value1 = 2.0f; //float radial_value2 = 0.8f; @@ -159,9 +158,8 @@ ShaderUniform shader_postfx_texture, shader_postfx_deform, shader_postfx_filter, shader_postfx_retrace, + shader_postfx_offset, shader_postfx_noise, - shader_postfx_noise_h, - shader_postfx_noise_v, shader_postfx_aberration, shader_postfx_moire, shader_postfx_moire_h, @@ -265,9 +263,8 @@ int Render::InitDraw(void) shader_postfx_deform = shader_postfx->GetUniformLocation("deform"); shader_postfx_filter = shader_postfx->GetUniformLocation("filter"); shader_postfx_retrace = shader_postfx->GetUniformLocation("retrace"); + shader_postfx_offset = shader_postfx->GetUniformLocation("offset"); shader_postfx_noise = shader_postfx->GetUniformLocation("noise"); - shader_postfx_noise_h = shader_postfx->GetUniformLocation("noise_h"); - shader_postfx_noise_v = shader_postfx->GetUniformLocation("noise_v"); shader_postfx_aberration = shader_postfx->GetUniformLocation("aberration"); shader_postfx_moire = shader_postfx->GetUniformLocation("moire"); shader_postfx_moire_h = shader_postfx->GetUniformLocation("moire_h"); @@ -600,9 +597,8 @@ void Render::Draw3D() shader_postfx->SetUniform(shader_postfx_deform, postfx_deform); shader_postfx->SetUniform(shader_postfx_filter, postfx_filter); shader_postfx->SetUniform(shader_postfx_retrace, postfx_retrace); + shader_postfx->SetUniform(shader_postfx_offset, postfx_offset); shader_postfx->SetUniform(shader_postfx_noise, postfx_noise); - shader_postfx->SetUniform(shader_postfx_noise_h, postfx_noise_h); - shader_postfx->SetUniform(shader_postfx_noise_v, postfx_noise_v); shader_postfx->SetUniform(shader_postfx_aberration, postfx_aberration); shader_postfx->SetUniform(shader_postfx_moire, postfx_moire); shader_postfx->SetUniform(shader_postfx_moire_h, postfx_moire_h);