diff --git a/neercs/video/postfx.lolfx b/neercs/video/postfx.lolfx index ee17cf5..da4d076 100644 --- a/neercs/video/postfx.lolfx +++ b/neercs/video/postfx.lolfx @@ -16,7 +16,8 @@ uniform sampler2D texture; uniform vec2 screen_size; uniform float time; uniform vec2 deform; -uniform vec4 ghost; +uniform vec4 ghost1; +uniform vec4 ghost2; uniform vec3 filter; uniform vec3 color; uniform vec3 retrace; @@ -28,6 +29,7 @@ uniform vec4 moire_v; uniform vec4 scanline_h; uniform vec4 scanline_v; uniform vec2 corner; +uniform float vignetting; uniform float flash; uniform float sync; @@ -60,16 +62,16 @@ void main(void) vec2 p=-1.0+2.0*gl_FragCoord.xy/screen_size.xy; p.y+=0.025*sync; vec2 z =screen(p,deform.y); - vec2 z1=screen(p,deform.y+ghost.x*0.01); - vec2 z2=screen(p,deform.y+ghost.z*0.01); + vec2 z1=screen(p,deform.y+ghost1.z*0.01); + vec2 z2=screen(p,deform.y+ghost2.z*0.01); float mask=q.x*(6.0-q.x*6.0)*q.y*(6.0-q.y*6.0); 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-vec2(0.25,0.0)); - vec3 glass2=get_color(texture,z2-vec2(0.25,0.0)); + vec3 g1=get_color(texture,z1-ghost1.xy); + vec3 g2=get_color(texture,z2-ghost2.xy); float v=aberration/float(screen_size.x)+aberration/float(screen_size.x)*(2.0-mask); @@ -78,7 +80,7 @@ void main(void) 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 c=source-glass1*glass1*ghost.y+glass2*glass2*ghost.w; + vec3 c=source+g1*g1*ghost1.w+g2*g2*ghost2.w; // mix float a=(c.x+c.y+c.z)/3.0; vec3 g=vec3(a,a,a); @@ -95,7 +97,7 @@ void main(void) 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 c*=scanline_h.x+scanline_h.y*cos(z.y*float(screen_size.y*scanline_h.z+scanline_h.w)); // scanline h c*=scanline_v.x+scanline_v.y*cos(z.x*float(screen_size.x*scanline_v.z+scanline_v.w)); // scanline v - c*=mask; // vignetting + c*=(mask-vignetting); // vignetting c*=letterbox(z,corner.x,corner.y); // letterbox gl_FragColor=vec4(c,1.0); } \ No newline at end of file diff --git a/neercs/video/render.cpp b/neercs/video/render.cpp index 8e31970..123849b 100644 --- a/neercs/video/render.cpp +++ b/neercs/video/render.cpp @@ -77,7 +77,7 @@ float fade_speed = 0.2f; // speed /* sync variable */ bool sync_flag = false; // flagsh float sync_angle = 0; // angle -float sync_value = 1.0f; // value +float sync_value = 0; // value float sync_speed = 1.0f; // speed /* beat variable */ bool beat_flag = false; // flag @@ -97,11 +97,13 @@ vec2 postfx_deform(0.7f,0.54f); // deformation [ratio,zoom] vec3 postfx_filter(0.8f,0.9f,0.4f); // color filter [red,green,blue] vec3 postfx_color(1.8f,1.5f,0.5f); // color modifier [brightness,contrast,grayscale] vec2 postfx_corner(0.75f,0.95f); // corner [radius,blur] +float postfx_vignetting = -0.5f; // vignetting strength vec3 postfx_retrace(0.05f,2.0f,4.0f); // retrace [strength,length,speed] vec2 postfx_offset(3.0f,3.0f); // random line [horizontal,vertical] float postfx_noise = 0.15f; // noise -float postfx_aberration = 3.0f; // chromatic aberration -vec4 postfx_ghost(0.1f,-0.25f,0.1f,0.5f); // ghost picture [distance,strength,distance,strength] +float postfx_aberration = 4.0f; // chromatic aberration +vec4 postfx_ghost1(0.01f,0.0f,0.1f,-0.4f); // ghost picture 1 [position x,position y,position z,strength] +vec4 postfx_ghost2(0.02f,0.0f,0.1f,0.4f); // ghost picture 2 [position x,position y,position z,strength] vec4 postfx_moire_h(0.75f,-0.25f,0.0f,1.0f); // vertical moire [base,variable,repeat x,repeat y] vec4 postfx_moire_v(0.75f,-0.25f,1.0f,1.5f); // horizontal moire [base,variable,repeat x,repeat y] vec4 postfx_scanline_h(0.75f, 0.25f,0.0f,2.0f); // vertical scanline [base,variable,repeat x,repeat y] @@ -169,7 +171,7 @@ char const *setup_text[] = { "zoom base", "corner radius", "corner blur", - "", + "vignetting", "", "", "color", @@ -191,14 +193,14 @@ char const *setup_text[] = { "retrace speed", "", "ghost", - "back distance", + "back x", + "back y", + "back z", "back strength", - "front distance", + "front x", + "front y", + "front z", "front strength", - "", - "", - "", - "", "moire", "h base", "h variable", @@ -256,12 +258,12 @@ vec4 setup_var[]={ // setup variable [start,end,step,value] vec4(0), vec4(0), vec4(0), /* screen */ - vec4(0, 1, 1, 1), - vec4(0.0f, 1.0f, 0.05f, postfx_deform.x), - vec4(0.5f, 0.7f, 0.01f, postfx_deform.y), - vec4(0.0f, 1.0f, 0.05f, postfx_corner.x), - vec4(0.0f, 1.0f, 0.05f, postfx_corner.y), - vec4(0), + vec4( 0, 1, 1, 1), + vec4( 0.0f, 1.0f, 0.05f, postfx_deform.x), + vec4( 0.5f, 0.7f, 0.01f, postfx_deform.y), + vec4( 0.0f, 1.0f, 0.05f, postfx_corner.x), + vec4( 0.0f, 1.0f, 0.05f, postfx_corner.y), + vec4(-1.0f, 1.0f, 0.10f, postfx_vignetting), vec4(0), vec4(0), vec4(0), /* color */ @@ -274,41 +276,41 @@ vec4 setup_var[]={ // setup variable [start,end,step,value] vec4(0), vec4(0), vec4(0), /* noise */ - vec4(0.0f, 4.0f, 0.5f, postfx_offset.x), - vec4(0.0f, 4.0f, 0.5f, postfx_offset.y), + vec4(0.0f, 4.0f, 0.50f, postfx_offset.x), + vec4(0.0f, 4.0f, 0.50f, postfx_offset.y), vec4(0.0f, 1.0f, 0.05f, postfx_noise), - vec4(0.0f, 5.0f, 0.5f, postfx_aberration), + vec4(0.0f, 8.0f, 0.50f, postfx_aberration), vec4(0.0f, 0.2f, 0.01f, postfx_retrace.x), - vec4(0.0f, 8.0f, 0.5f, postfx_retrace.y), + vec4(0.0f, 8.0f, 0.50f, postfx_retrace.y), vec4(0.0f, 4.0f, 0.25f, postfx_retrace.z), vec4(0), vec4(0), /* ghost */ - vec4(0.0f, 2.0f, 0.1f, postfx_ghost.x), - vec4(-1.0f, 1.0f, 0.1f, postfx_ghost.y), - vec4(0.0f, 2.0f, 0.1f, postfx_ghost.z), - vec4(-1.0f, 1.0f, 0.1f, postfx_ghost.w), - vec4(0), - vec4(0), - vec4(0), - vec4(0), + vec4(-0.5f, 0.5f, 0.01f, postfx_ghost1.x), + vec4(-0.5f, 0.5f, 0.01f, postfx_ghost1.y), + vec4(-2.0f, 2.0f, 0.10f, postfx_ghost1.z), + vec4(-1.0f, 1.0f, 0.05f, postfx_ghost1.w), + vec4(-0.5f, 0.5f, 0.01f, postfx_ghost2.x), + vec4(-0.5f, 0.5f, 0.01f, postfx_ghost2.y), + vec4(-2.0f, 2.0f, 0.10f, postfx_ghost2.z), + vec4(-1.0f, 1.0f, 0.05f, postfx_ghost2.w), vec4(0), /* moire */ - vec4(0.5f, 1.0f, 0.05f, postfx_moire_h.x), + vec4( 0.5f, 1.0f, 0.05f, postfx_moire_h.x), vec4(-0.5f, 0.5f, 0.05f, postfx_moire_h.y), - vec4(0.0f, 4.0f, 0.5f, postfx_moire_h.z), - vec4(0.0f, 4.0f, 0.5f, postfx_moire_h.w), - vec4(0.5f, 1.0f, 0.05f, postfx_moire_v.x), + vec4( 0.0f, 4.0f, 0.50f, postfx_moire_h.z), + vec4( 0.0f, 4.0f, 0.50f, postfx_moire_h.w), + vec4( 0.5f, 1.0f, 0.05f, postfx_moire_v.x), vec4(-0.5f, 0.5f, 0.05f, postfx_moire_v.y), - vec4(0.0f, 4.0f, 0.5f, postfx_moire_v.z), - vec4(0.0f, 4.0f, 0.5f, postfx_moire_v.w), + vec4( 0.0f, 4.0f, 0.50f, postfx_moire_v.z), + vec4( 0.0f, 4.0f, 0.50f, postfx_moire_v.w), vec4(0), /* scanline */ - vec4(0.5f, 1.0f, 0.05f, postfx_scanline_h.x), + vec4( 0.5f, 1.0f, 0.05f, postfx_scanline_h.x), vec4(-0.5f, 0.5f, 0.05f, postfx_scanline_h.y), - vec4(0.0f, 4.0f, 0.5f, postfx_scanline_h.z), - vec4(0.0f, 4.0f, 0.5f, postfx_scanline_h.w), - vec4(0.5f, 1.0f, 0.05f, postfx_scanline_v.x), + vec4( 0.0f, 4.0f, 0.50f, postfx_scanline_h.z), + vec4( 0.0f, 4.0f, 0.50f, postfx_scanline_h.w), + vec4( 0.5f, 1.0f, 0.05f, postfx_scanline_v.x), vec4(-0.5f, 0.5f, 0.05f, postfx_scanline_v.y), - vec4(0.0f, 4.0f, 0.5f, postfx_scanline_v.z), - vec4(0.0f, 4.0f, 0.5f, postfx_scanline_v.w), + vec4( 0.0f, 4.0f, 0.50f, postfx_scanline_v.z), + vec4( 0.0f, 4.0f, 0.50f, postfx_scanline_v.w), vec4(0) }; @@ -331,7 +333,8 @@ void Render::UpdateVar() m_shader_postfx = (setup_var[k].w == 1) ? true : false; k++; postfx_deform = vec2(setup_var[k].w, setup_var[k + 1].w); k += 2; postfx_corner = vec2(setup_var[k].w, setup_var[k + 1].w); k += 2; - k += 4; /* color */ + postfx_vignetting = setup_var[k].w; k++; + k += 3; /* color */ postfx_filter = vec3(setup_var[k].w, setup_var[k + 1].w, setup_var[k + 2].w); k += 3; postfx_color = vec3(setup_var[k].w, setup_var[k + 1].w, setup_var[k + 2].w); k += 3; k += 3; /* noise */ @@ -340,8 +343,9 @@ void Render::UpdateVar() postfx_aberration = setup_var[k].w; k++; postfx_retrace = vec3(setup_var[k].w, setup_var[k + 1].w, setup_var[k + 2].w); k += 3; k += 2; /* ghost */ - postfx_ghost = vec4(setup_var[k].w, setup_var[k + 1].w, setup_var[k + 2].w, setup_var[k + 3].w); k += 4; - k += 5; /* moire */ + postfx_ghost1 = vec4(setup_var[k].w, setup_var[k + 1].w, setup_var[k + 2].w, setup_var[k + 3].w); k += 4; + postfx_ghost2 = vec4(setup_var[k].w, setup_var[k + 1].w, setup_var[k + 2].w, setup_var[k + 3].w); k += 4; + k += 1; /* moire */ postfx_moire_h = vec4(setup_var[k].w, setup_var[k + 1].w, setup_var[k + 2].w, setup_var[k + 3].w); k += 4; postfx_moire_v = vec4(setup_var[k].w, setup_var[k + 1].w, setup_var[k + 2].w, setup_var[k + 3].w); k += 4; k++; /* scanline */ @@ -387,10 +391,12 @@ ShaderUniform shader_postfx_texture, shader_postfx_screen_size, shader_postfx_time, shader_postfx_deform, - shader_postfx_ghost, + shader_postfx_ghost1, + shader_postfx_ghost2, shader_postfx_filter, shader_postfx_color, shader_postfx_corner, + shader_postfx_vignetting, shader_postfx_retrace, shader_postfx_offset, shader_postfx_noise, @@ -482,10 +488,12 @@ 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_ghost = shader_postfx->GetUniformLocation("ghost"); + shader_postfx_ghost1 = shader_postfx->GetUniformLocation("ghost1"); + shader_postfx_ghost2 = shader_postfx->GetUniformLocation("ghost2"); shader_postfx_filter = shader_postfx->GetUniformLocation("filter"); shader_postfx_color = shader_postfx->GetUniformLocation("color"); shader_postfx_corner = shader_postfx->GetUniformLocation("corner"); + shader_postfx_vignetting = shader_postfx->GetUniformLocation("vignetting"); shader_postfx_retrace = shader_postfx->GetUniformLocation("retrace"); shader_postfx_offset = shader_postfx->GetUniformLocation("offset"); shader_postfx_noise = shader_postfx->GetUniformLocation("noise"); @@ -554,6 +562,8 @@ void Render::TickDraw(float seconds) if (Input::GetButtonState(282/*SDLK_F1*/) && (timer - timer_key > timer_key_repeat)) { m_setup = !m_setup; + sync_flag = true; + sync_angle = main_angle; timer_key = timer; } if (Input::GetButtonState(283/*SDLK_F2*/) && (timer - timer_key > timer_key_repeat)) @@ -676,6 +686,8 @@ void Render::TickDraw(float seconds) } if (Input::GetButtonState(13/*SDLK_RETURN*/)&&(timer-timer_key>timer_key_repeat)) { + sync_flag = true; + sync_angle = main_angle; timer_key = timer; } @@ -965,10 +977,12 @@ 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_ghost, postfx_ghost); + shader_postfx->SetUniform(shader_postfx_ghost1, postfx_ghost1); + shader_postfx->SetUniform(shader_postfx_ghost2, postfx_ghost2); shader_postfx->SetUniform(shader_postfx_filter, postfx_filter); shader_postfx->SetUniform(shader_postfx_color, postfx_color); shader_postfx->SetUniform(shader_postfx_corner, postfx_corner); + shader_postfx->SetUniform(shader_postfx_vignetting, postfx_vignetting); shader_postfx->SetUniform(shader_postfx_retrace, postfx_retrace); shader_postfx->SetUniform(shader_postfx_offset, postfx_offset); shader_postfx->SetUniform(shader_postfx_noise, postfx_noise); @@ -978,7 +992,7 @@ void Render::Draw3D() 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))); + shader_postfx->SetUniform(shader_postfx_sync, (float)fabs(sync_value*cosf((main_angle-sync_angle)*6.0f))); fs_quad(); shader_postfx->Unbind(); }