Sfoglia il codice sorgente

fixed noise / added tons of control vars to postfx

master
parent
commit
4884c3165c
3 ha cambiato i file con 97 aggiunte e 37 eliminazioni
  1. +1
    -1
      neercs/neercs.cpp
  2. +19
    -9
      neercs/video/postfx.lolfx
  3. +77
    -27
      neercs/video/render.cpp

+ 1
- 1
neercs/neercs.cpp Vedi File

@@ -116,7 +116,7 @@ void Neercs::TickGame(float seconds)
caca_set_color_argb(m_caca, hex_color(0.5f + 0.5f * lol::cos(m_time * 3 ), 0.5f, 0.5f + 0.25f * lol::sin(m_time * 3 )), bg_color);
caca_put_str(m_caca, logo_x + 3, logo_y ,"__ _________ ______ ______ ______ ______");
caca_set_color_argb(m_caca, hex_color(0.5f + 0.5f * lol::cos(m_time * 3 + M_PI / 4 * 1), 0.5f, 0.5f + 0.25f * lol::sin(m_time * 3 + M_PI / 4 * 1)), bg_color);
caca_put_str(m_caca, logo_x + 2, logo_y + 1, "/ \\/ / __ > __ > __ > ___// ___/");
caca_put_str(m_caca, logo_x + 2, logo_y + 1, "/ \\/ / __ > __ > __ > ___// ___/ \x0a9");
caca_set_color_argb(m_caca, hex_color(0.5f + 0.5f * lol::cos(m_time * 3 + M_PI / 4 * 2), 0.5f, 0.5f + 0.25f * lol::sin(m_time * 3 + M_PI / 4 * 2)), bg_color);
caca_put_str(m_caca, logo_x + 1, logo_y + 2, "/ / ____/ ____/ __ < <____\\___ \\");
caca_set_color_argb(m_caca, hex_color(0.5f + 0.5f * lol::cos(m_time * 3 + M_PI / 4 * 3), 0.5f, 0.5f + 0.25f * lol::sin(m_time * 3 + M_PI / 4 * 3)), bg_color);


+ 19
- 9
neercs/video/postfx.lolfx Vedi File

@@ -15,11 +15,21 @@ void main()
uniform sampler2D texture;
uniform vec2 screen_size;
uniform float time;
uniform float flash;
uniform float noise;
uniform float noise_h;
uniform float noise_v;
uniform float aberration;
uniform float deform;
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 float flash;
uniform float sync;

const float PI=3.14159265358979323846;
@@ -58,8 +68,8 @@ void main(void)

float rnd1=rand(vec2(p.x+time,p.y-time));
float rnd2=rand(vec2(p.x-time,p.y+time));
float d1=rnd1*noise/float(screen_size.x);
float d2=rnd2*noise/float(screen_size.y);
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;
@@ -73,8 +83,8 @@ void main(void)

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;
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 color=source+glass1*glass1*0.25+glass2*glass2*0.25+(scanline?noise:source);

@@ -82,15 +92,15 @@ void main(void)
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))*0.1; // noise
color*=0.75+0.25*cos(z.x*float(screen_size.x*2))*sin(0.5+z.y*float(screen_size.y)); // scanline w
color*=0.75+0.50*sin(z.y*float(screen_size.y*2)); // scanline h
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
}
else
{
color*=0.675;
}
color=vec3(color.x*0.875,color.y*1.0,color.z*0.75);
color=vec3(color.x*0.875,color.y*1.0,color.z*0.75); // hue
color*=mask; // vignetting
color*=letterbox(z,-0.75,0.95); // letterbox
gl_FragColor=vec4(color,1.0);

+ 77
- 27
neercs/video/render.cpp Vedi File

@@ -84,7 +84,7 @@ float beat_speed = 2.0f; // speed
/* window variable */
ivec2 border; // border width
/* text variable */
ivec2 ratio_2d(2,3); // 2d ratio
ivec2 ratio_2d(1,4); // 2d ratio
ivec2 map_size(256,256); // texture map size
ivec2 font_size(8,8); // font size
ivec2 canvas_char(0,0); // canvas char number
@@ -92,17 +92,37 @@ ivec2 canvas_size(0,0); // caca size
/* common variable */
float value, angle, radius, scale, speed;
/* shader variable */
int glow_fbo_size = 2; // glow fbo size
float glow_smoothstep = 0.0f; // glow smoothstep value (try 0.025f)
float glow_mix_ratio1 = 0.5f; // glow mixing ratio
float glow_mix_ratio2 = 0.5f; // source mixing ratio
float radial_value1 = 2.0f;
float radial_value2 = 0.8f;
float radial_color = 0; // color
float postfx_deform = 0.625f; // deformation ratio
float postfx_noise = 4.0f; // noise
float remanency_source_mix = 0.25f;
float remanency_buffer_mix = 0.75f;
float remanency_new_frame_mix = 0.75f;
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 postfx_deform = 0.625f; // deformation ratio
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_scanline = true; // scanline
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;
//float radial_value1 = 2.0f;
//float radial_value2 = 0.8f;
//float radial_color = 0;

Shader *shader_simple;
Shader *shader_blur_h, *shader_blur_v;
@@ -142,8 +162,18 @@ ShaderUniform shader_postfx_texture,
shader_postfx_time,
shader_postfx_deform,
shader_postfx_noise,
shader_postfx_noise_h,
shader_postfx_noise_v,
shader_postfx_aberration,
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_flash,
shader_postfx_sync;

@@ -239,8 +269,18 @@ int Render::InitDraw(void)
shader_postfx_time = shader_postfx->GetUniformLocation("time");
shader_postfx_deform = shader_postfx->GetUniformLocation("deform");
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_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_flash = shader_postfx->GetUniformLocation("flash");
shader_postfx_sync = shader_postfx->GetUniformLocation("sync");

@@ -437,8 +477,8 @@ void Render::Draw3D()
shader_remanency->SetTexture(shader_remanency_texture_buffer, fbo_buffer->GetTexture(), 1);
shader_remanency->SetUniform(shader_remanency_screen_size, vec2(1.0f));
shader_remanency->SetUniform(shader_remanency_screen_color, screen_color);
shader_remanency->SetUniform(shader_remanency_value1, 0.25f);
shader_remanency->SetUniform(shader_remanency_value2, 0.75f);
shader_remanency->SetUniform(shader_remanency_value1, remanency_source_mix);
shader_remanency->SetUniform(shader_remanency_value2, remanency_buffer_mix);
fs_quad();
shader_remanency->Unbind();
fbo_ping->Unbind();
@@ -453,8 +493,8 @@ void Render::Draw3D()
shader_remanency->SetTexture(shader_remanency_texture_buffer, fbo_buffer->GetTexture(), 1);
shader_remanency->SetUniform(shader_remanency_screen_size, vec2(1.0f));
shader_remanency->SetUniform(shader_remanency_screen_color, screen_color);
shader_remanency->SetUniform(shader_remanency_value1, 0.75f);
shader_remanency->SetUniform(shader_remanency_value2, 0.25f);
shader_remanency->SetUniform(shader_remanency_value1, remanency_new_frame_mix);
shader_remanency->SetUniform(shader_remanency_value2, remanency_old_frame_mix);
fs_quad();
shader_remanency->Unbind();
fbo_ping->Unbind();
@@ -471,8 +511,8 @@ void Render::Draw3D()
shader_blur_h->Bind();
shader_blur_h->SetTexture(shader_blur_h_texture, fbo_back->GetTexture(), 0);
shader_blur_h->SetUniform(shader_blur_h_screen_size, vec2(1.0f));
shader_blur_h->SetUniform(shader_blur_h_blur, 0.25f / screen_size.x);
shader_blur_h->SetUniform(shader_blur_h_deform, 0.375f / screen_size.x);
shader_blur_h->SetUniform(shader_blur_h_blur, blur_radius / screen_size.x);
shader_blur_h->SetUniform(shader_blur_h_deform, blur_radius_deform / screen_size.x);
fs_quad();
shader_blur_h->Unbind();
fbo_ping->Unbind();
@@ -481,8 +521,8 @@ void Render::Draw3D()
shader_blur_v->Bind();
shader_blur_v->SetTexture(shader_blur_v_texture, fbo_ping->GetTexture(), 0);
shader_blur_v->SetUniform(shader_blur_v_screen_size, vec2(1.0f));
shader_blur_v->SetUniform(shader_blur_v_blur, 0.25f / screen_size.y);
shader_blur_v->SetUniform(shader_blur_v_deform, 0.375f / screen_size.y);
shader_blur_v->SetUniform(shader_blur_v_blur, blur_radius / screen_size.y);
shader_blur_v->SetUniform(shader_blur_v_deform, blur_radius_deform / screen_size.y);
fs_quad();
shader_blur_v->Unbind();
}
@@ -501,8 +541,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, 2.5f / screen_size.x);
shader_blur_h->SetUniform(shader_blur_h_deform, 0.5f / screen_size.x);
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);
fs_quad();
shader_blur_h->Unbind();
fbo_blur_h->Unbind();
@@ -511,8 +551,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, 2.5f / screen_size.y);
shader_blur_v->SetUniform(shader_blur_v_deform, 0.5f / screen_size.y);
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);
fs_quad();
shader_blur_v->Unbind();
fbo_blur_v->Unbind();
@@ -521,8 +561,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, 1.0f / screen_size.x);
shader_blur_h->SetUniform(shader_blur_h_deform, 0.5f / screen_size.x);
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);
fs_quad();
shader_blur_h->Unbind();
fbo_blur_h->Unbind();
@@ -531,8 +571,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, 1.0f / screen_size.y);
shader_blur_h->SetUniform(shader_blur_v_deform, 0.5f / screen_size.y);
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);
fs_quad();
shader_blur_v->Unbind();
fbo_blur_v->Unbind();
@@ -565,8 +605,18 @@ void Render::Draw3D()
shader_postfx->SetUniform(shader_postfx_time, fx_angle);
shader_postfx->SetUniform(shader_postfx_deform, postfx_deform);
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_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_flash, flash_value);
shader_postfx->SetUniform(shader_postfx_sync, (float)fabs(beat_value*cosf((main_angle-beat_angle)*8.0f)));
fs_quad();


Caricamento…
Annulla
Salva