Bläddra i källkod

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

master
förälder
incheckning
329ffc79c6
2 ändrade filer med 71 tillägg och 69 borttagningar
  1. +29
    -20
      neercs/video/postfx.lolfx
  2. +42
    -49
      neercs/video/render.cpp

+ 29
- 20
neercs/video/postfx.lolfx Visa fil

@@ -15,20 +15,19 @@ void main()
uniform sampler2D texture;
uniform vec2 screen_size;
uniform float time;
uniform float deform;
uniform vec3 filter;
uniform vec3 retrace;
uniform float noise;
uniform float noise_h;
uniform float noise_v;
uniform float aberration;
uniform float deform;
uniform bool moire;
uniform vec4 moire_h;
uniform vec4 moire_v;
uniform bool scanline;
uniform float scanline_h_base;
uniform float scanline_h_var;
uniform float scanline_h_repeat_x;
uniform float scanline_h_repeat_y;
uniform float scanline_v_base;
uniform float scanline_v_var;
uniform float scanline_v_repeat_x;
uniform float scanline_v_repeat_y;
uniform vec4 scanline_h;
uniform vec4 scanline_v;
uniform float flash;
uniform float sync;

@@ -81,26 +80,36 @@ void main(void)

float v=aberration/float(screen_size.x)+aberration/float(screen_size.x)*(2.0-mask);

vec3 noise;
noise.x=get_color(texture,vec2(z.x+d1-v,z.y+d2)).x;
noise.y=get_color(texture,vec2(z.x+d1 ,z.y+d2)).y;
noise.z=get_color(texture,vec2(z.x+d1+v,z.y+d2)).z;
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 color=source+glass1*glass1*0.25+glass2*glass2*0.25+(scanline?noise:source);
vec3 color=source+glass1*glass1*0.25+glass2*glass2*0.25;

color+=flash; // flash
color+=scramble; // scramble
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
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
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
}
else
{
color*=(moire_h.x+moire_v.x)*0.5;
}
if(scanline)
{
color-=0.0125*mod(z.y*4.0+time*0.25,1.0); // electron beam
color-=(vec3(rnd1,rnd1,rnd1)-vec3(rnd2,rnd2,rnd2))*noise; // noise
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
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
color*=scanline_h.x+scanline_h.y*cos(z.y*float(screen_size.y*scanline_h.z+scanline_h.w)); // scanline h
color*=scanline_v.x+scanline_v.y*cos(z.x*float(screen_size.x*scanline_v.z+scanline_v.w)); // scanline v
}
else
{
color*=0.675;
color*=(scanline_h.x+scanline_v.x)*0.5;
}
color=vec3(color.x*0.875,color.y*1.0,color.z*0.75); // hue
color*=filter; // hue
color*=mask; // vignetting
color*=letterbox(z,-0.75,0.95); // letterbox
gl_FragColor=vec4(color,1.0);

+ 42
- 49
neercs/video/render.cpp Visa fil

@@ -99,27 +99,23 @@ float remanency_old_frame_mix = 0.25f;
float blur_radius = 0.25f; // glow radius
float blur_radius_deform = 0.625f;// glow radius deform
int glow_fbo_size = 2; // glow fbo size
float glow_smoothstep = 0.0f; // glow smoothstep value (try 0.025f)
float glow_mix_ratio1 = 0.375f; // glow mixing ratio
float glow_mix_ratio2 = 0.625f; // source mixing ratio
float glow_radius1 = 2.0f; // large glow radius
float glow_radius2 = 1.0f; // small glow radius
float glow_radius_deform1 = 3.0f;// large glow radius deform
float glow_radius_deform2 = 1.5f;// small glow radius deform
float glow_smoothstep = 0.1f; // glow smoothstep value (try 0.025f)
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
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);
bool postfx_scanline = true; // scanline
float postfx_scanline_h_base = 0.75f;
float postfx_scanline_h_var = 0.25f;
float postfx_scanline_h_repeat_x = 1.0f;
float postfx_scanline_h_repeat_y = 1.0f;
float postfx_scanline_v_base = 0.75f;
float postfx_scanline_v_var = 0.5f;
float postfx_scanline_v_repeat_x = 0.0f;
float postfx_scanline_v_repeat_y = 1.0f;
vec4 postfx_scanline_h(0.5f,0.5f,2.0f,0.0f);
vec4 postfx_scanline_v(1.0f,0.0f,0.0f,0.0f);
//float radial_value1 = 2.0f;
//float radial_value2 = 0.8f;
//float radial_color = 0;
@@ -161,19 +157,18 @@ ShaderUniform shader_postfx_texture,
shader_postfx_screen_size,
shader_postfx_time,
shader_postfx_deform,
shader_postfx_filter,
shader_postfx_retrace,
shader_postfx_noise,
shader_postfx_noise_h,
shader_postfx_noise_v,
shader_postfx_aberration,
shader_postfx_moire,
shader_postfx_moire_h,
shader_postfx_moire_v,
shader_postfx_scanline,
shader_postfx_scanline_h_base,
shader_postfx_scanline_h_var,
shader_postfx_scanline_h_repeat_x,
shader_postfx_scanline_h_repeat_y,
shader_postfx_scanline_v_base,
shader_postfx_scanline_v_var,
shader_postfx_scanline_v_repeat_x,
shader_postfx_scanline_v_repeat_y,
shader_postfx_scanline_h,
shader_postfx_scanline_v,
shader_postfx_flash,
shader_postfx_sync;

@@ -268,19 +263,18 @@ int Render::InitDraw(void)
shader_postfx_screen_size = shader_postfx->GetUniformLocation("screen_size");
shader_postfx_time = shader_postfx->GetUniformLocation("time");
shader_postfx_deform = shader_postfx->GetUniformLocation("deform");
shader_postfx_filter = shader_postfx->GetUniformLocation("filter");
shader_postfx_retrace = shader_postfx->GetUniformLocation("retrace");
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");
shader_postfx_moire_v = shader_postfx->GetUniformLocation("moire_v");
shader_postfx_scanline = shader_postfx->GetUniformLocation("scanline");
shader_postfx_scanline_h_base = shader_postfx->GetUniformLocation("scanline_h_base");
shader_postfx_scanline_h_var = shader_postfx->GetUniformLocation("scanline_h_var");
shader_postfx_scanline_h_repeat_x = shader_postfx->GetUniformLocation("scanline_h_repeat_x");
shader_postfx_scanline_h_repeat_y = shader_postfx->GetUniformLocation("scanline_h_repeat_y");
shader_postfx_scanline_v_base = shader_postfx->GetUniformLocation("scanline_v_base");
shader_postfx_scanline_v_var = shader_postfx->GetUniformLocation("scanline_v_var");
shader_postfx_scanline_v_repeat_x = shader_postfx->GetUniformLocation("scanline_v_repeat_x");
shader_postfx_scanline_v_repeat_y = shader_postfx->GetUniformLocation("scanline_v_repeat_y");
shader_postfx_scanline_h = shader_postfx->GetUniformLocation("scanline_h");
shader_postfx_scanline_v = shader_postfx->GetUniformLocation("scanline_v");
shader_postfx_flash = shader_postfx->GetUniformLocation("flash");
shader_postfx_sync = shader_postfx->GetUniformLocation("sync");

@@ -541,8 +535,8 @@ void Render::Draw3D()
shader_blur_h->Bind();
shader_blur_h->SetTexture(shader_blur_h_texture, fbo_ping->GetTexture(), 0);
shader_blur_h->SetUniform(shader_blur_h_screen_size, vec2(1.0f / glow_fbo_size));
shader_blur_h->SetUniform(shader_blur_h_blur, glow_radius1 / screen_size.x);
shader_blur_h->SetUniform(shader_blur_h_deform, glow_radius_deform1 / screen_size.x);
shader_blur_h->SetUniform(shader_blur_h_blur, glow_large.y / screen_size.x);
shader_blur_h->SetUniform(shader_blur_h_deform, glow_large.z / screen_size.x);
fs_quad();
shader_blur_h->Unbind();
fbo_blur_h->Unbind();
@@ -551,8 +545,8 @@ void Render::Draw3D()
shader_blur_v->Bind();
shader_blur_v->SetTexture(shader_blur_v_texture, fbo_blur_h->GetTexture(), 0);
shader_blur_v->SetUniform(shader_blur_v_screen_size, vec2(1.0f / glow_fbo_size));
shader_blur_v->SetUniform(shader_blur_v_blur, glow_radius1 / screen_size.y);
shader_blur_v->SetUniform(shader_blur_v_deform, glow_radius_deform1 / screen_size.y);
shader_blur_v->SetUniform(shader_blur_v_blur, glow_large.y / screen_size.y);
shader_blur_v->SetUniform(shader_blur_v_deform, glow_large.z / screen_size.y);
fs_quad();
shader_blur_v->Unbind();
fbo_blur_v->Unbind();
@@ -561,8 +555,8 @@ void Render::Draw3D()
shader_blur_h->Bind();
shader_blur_h->SetTexture(shader_blur_h_texture, fbo_blur_v->GetTexture(), 0);
shader_blur_h->SetUniform(shader_blur_h_screen_size, vec2(1.0f / glow_fbo_size));
shader_blur_h->SetUniform(shader_blur_h_blur, glow_radius2 / screen_size.x);
shader_blur_h->SetUniform(shader_blur_h_deform, glow_radius_deform2 / screen_size.x);
shader_blur_h->SetUniform(shader_blur_h_blur, glow_small.y / screen_size.x);
shader_blur_h->SetUniform(shader_blur_h_deform, glow_small.z / screen_size.x);
fs_quad();
shader_blur_h->Unbind();
fbo_blur_h->Unbind();
@@ -571,8 +565,8 @@ void Render::Draw3D()
shader_blur_v->Bind();
shader_blur_v->SetTexture(shader_blur_v_texture, fbo_blur_h->GetTexture(), 0);
shader_blur_v->SetUniform(shader_blur_v_screen_size, vec2(1.0f / glow_fbo_size));
shader_blur_v->SetUniform(shader_blur_v_blur, glow_radius2 / screen_size.y);
shader_blur_h->SetUniform(shader_blur_v_deform, glow_radius_deform2 / screen_size.y);
shader_blur_v->SetUniform(shader_blur_v_blur, glow_small.y / screen_size.y);
shader_blur_h->SetUniform(shader_blur_v_deform, glow_small.z / screen_size.y);
fs_quad();
shader_blur_v->Unbind();
fbo_blur_v->Unbind();
@@ -584,8 +578,8 @@ void Render::Draw3D()
shader_glow->SetUniform(shader_glow_screen_size, vec2(1.0f));
shader_glow->SetUniform(shader_glow_time, fx_angle);
shader_glow->SetUniform(shader_glow_step, glow_smoothstep);
shader_glow->SetUniform(shader_glow_value1, glow_mix_ratio1);
shader_glow->SetUniform(shader_glow_value2, glow_mix_ratio2);
shader_glow->SetUniform(shader_glow_value1, glow_large.x);
shader_glow->SetUniform(shader_glow_value2, glow_small.x);
fs_quad();
shader_glow->Unbind();
}
@@ -604,19 +598,18 @@ void Render::Draw3D()
shader_postfx->SetUniform(shader_postfx_screen_size, (vec2)screen_size);
shader_postfx->SetUniform(shader_postfx_time, fx_angle);
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_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);
shader_postfx->SetUniform(shader_postfx_moire_v, postfx_moire_v);
shader_postfx->SetUniform(shader_postfx_scanline, postfx_scanline);
shader_postfx->SetUniform(shader_postfx_scanline_h_base, postfx_scanline_h_base);
shader_postfx->SetUniform(shader_postfx_scanline_h_var, postfx_scanline_h_var);
shader_postfx->SetUniform(shader_postfx_scanline_h_repeat_x, postfx_scanline_h_repeat_x);
shader_postfx->SetUniform(shader_postfx_scanline_h_repeat_y, postfx_scanline_h_repeat_y);
shader_postfx->SetUniform(shader_postfx_scanline_v_base, postfx_scanline_v_base);
shader_postfx->SetUniform(shader_postfx_scanline_v_var, postfx_scanline_v_var);
shader_postfx->SetUniform(shader_postfx_scanline_v_repeat_x, postfx_scanline_v_repeat_x);
shader_postfx->SetUniform(shader_postfx_scanline_v_repeat_y, postfx_scanline_v_repeat_y);
shader_postfx->SetUniform(shader_postfx_scanline_h, postfx_scanline_h);
shader_postfx->SetUniform(shader_postfx_scanline_v, postfx_scanline_v);
shader_postfx->SetUniform(shader_postfx_flash, flash_value);
shader_postfx->SetUniform(shader_postfx_sync, (float)fabs(beat_value*cosf((main_angle-beat_angle)*8.0f)));
fs_quad();


Laddar…
Avbryt
Spara