Переглянути джерело

moved blur after glow, tweaked a lot of parameters

master
rez Sam Hocevar <sam@hocevar.net> 12 роки тому
джерело
коміт
753f28f88d
4 змінених файлів з 59 додано та 56 видалено
  1. +7
    -2
      neercs/neercs.cpp
  2. +3
    -3
      neercs/video/glow.lolfx
  3. +4
    -3
      neercs/video/postfx.lolfx
  4. +45
    -48
      neercs/video/render.cpp

+ 7
- 2
neercs/neercs.cpp Переглянути файл

@@ -91,8 +91,8 @@ void Neercs::TickGame(float seconds)
{
float a = M_PI / 180 * i * 16 + m_time * 4;
float b = M_PI / 180 * i * 12;
int x = w / 2 - 15 + h / 3 * lol::cos(a) + h / 4 * lol::sin(b);
caca_put_str(m_caca, x, i, "LOL WUT! NEERCS SI TEH RULEZ!");
int x = w / 2 - 14 + w / 4 * lol::cos(a) + w / 4 * lol::sin(b);
caca_put_str(m_caca, x, i, "LOL WUT! NEERCS SI TEH RULEZ");
}

caca_set_color_argb(m_caca, 0x444, bg_color);
@@ -130,6 +130,11 @@ void Neercs::TickGame(float seconds)

caca_set_color_argb(m_caca, hex_color(0.6f + 0.4f * lol::cos(m_time * 2), 0.2f, 0.2f), bg_color);
caca_put_str(m_caca, w - 12, h - 2, "CACA RULEZ");

caca_set_color_argb(m_caca, 0xdef, bg_color);
caca_put_str(m_caca, 0, 0, "mdr@lol:~/ cd code/lolengine/");
caca_put_str(m_caca, 0, 1, "mdr@lol:~/code/lolengine/ cd /var/log/");
caca_put_str(m_caca, 0, 2, "mdr@lol:/var/log/");
}




+ 3
- 3
neercs/video/glow.lolfx Переглянути файл

@@ -14,9 +14,9 @@ void main()

uniform sampler2D glow;
uniform sampler2D source;
uniform vec3 mix;
uniform vec2 mix;

void main(void)
{
gl_FragColor=smoothstep(mix.z,1.0,texture2D(source,gl_TexCoord[0].xy))*mix.x+texture2D(glow,gl_TexCoord[0].xy)*mix.y;
}
gl_FragColor=texture2D(source,gl_TexCoord[0].xy)*mix.x+texture2D(glow,gl_TexCoord[0].xy)*mix.y;
}

+ 4
- 3
neercs/video/postfx.lolfx Переглянути файл

@@ -19,7 +19,7 @@ uniform float deform;
uniform vec3 filter;
uniform vec3 retrace;
uniform vec2 offset;
uniform vec2 noise;
uniform float noise;
uniform float aberration;
uniform bool moire;
uniform vec4 moire_h;
@@ -80,10 +80,11 @@ void main(void)

vec3 color=source+glass1*glass1*0.25+glass2*glass2*0.25;

color=smoothstep(0.05,1.0,color);
color+=flash; // flash
color+=ca; // chromatic aberration
color-=retrace.x*mod(z.y*retrace.y+time*retrace.z,1.0); // retrace
color-=(vec3(rnd.x,rnd.x,rnd.x)-vec3(rnd.y,rnd.y,rnd.y))*noise.y;// noise
color-=(vec3(rnd.x-rnd.y))*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
@@ -102,7 +103,7 @@ void main(void)
{
color*=(scanline_h.x+scanline_v.x)*0.5;
}
color*=filter; // hue
color*=filter; // filter
color*=mask; // vignetting
color*=letterbox(z,-0.75,0.95); // letnoiseterbox
gl_FragColor=vec4(color,1.0);

+ 45
- 48
neercs/video/render.cpp Переглянути файл

@@ -72,7 +72,7 @@ float fade_angle = 0; // angle
float fade_value = 0; // value
float fade_speed = 0.2f; // speed
/* sync variable */
bool sync_flag = false; // flag
bool sync_flag = false; // flagsh
float sync_angle = 0; // angle
float sync_value = 1.0f; // value
float sync_speed = 1.0f; // speed
@@ -94,24 +94,24 @@ float value, angle, radius, scale, speed;
/* shader variable */
vec2 buffer(0.75f,0.25f); // [new frame mix,old frame mix]
vec2 remanency(0.25f,0.75f); // remanency [source mix,buffer mix]
vec2 blur(0.5f,1.0f); // glow radius [normal,deform]
vec3 glow_mix(1.0f,0.0f,0.025f);// glow mix [glow mix,source mix,source smoothstep]
vec2 glow_large(4.0f,6.0f); // large glow radius [normal,deform]
vec2 glow_small(2.0f,4.0f); // small glow radius [normal,deform]
vec2 blur(0.25f,0.5f); // glow radius [normal,deform]
vec2 glow_mix(0.5f,0.5f); // glow mix [glow mix,source mix]
vec2 glow_large(2.0f,2.0f); // large glow radius [normal,deform]
vec2 glow_small(1.0f,1.0f); // small glow radius [normal,deform]
//vec3 radial(2.0f,0.8f,0); // radial [mix,strength,color mode]
//---------------------------------[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 [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_noise = 0.125f; // noise
float postfx_aberration = 3.0f; // chromatic aberration
bool postfx_moire = true; // moire
vec4 postfx_moire_h(0.75f,-0.25f,1.0f,2.0f);
vec4 postfx_moire_v(0.875f,-0.125f,0.5f,2.0f);
vec4 postfx_moire_v(0.75f,-0.25f,0.0f,1.0f);
bool postfx_scanline = true; // scanline
vec4 postfx_scanline_h(0.75f,-0.5f,2.0f,0.0f);// vertical scanline [base,variable,repeat]
vec4 postfx_scanline_v(1.0f,0.0f,0.0f,0.0f); // horizontal scanline [base,variable,repeat]
vec4 postfx_scanline_h(0.75f,-0.25f,2.0f,0.0f);// vertical scanline [base,variable,repeat]
vec4 postfx_scanline_v(0.75f, 0.25f,0.0f,2.0f);// horizontal scanline [base,variable,repeat]

Shader *shader_simple;
Shader *shader_blur_h, *shader_blur_v;
@@ -119,8 +119,8 @@ Shader *shader_remanency, *shader_glow, *shader_radial, *shader_postfx;
// shader variables
ShaderUniform shader_simple_texture;
ShaderUniform shader_blur_h_texture,
shader_blur_h_radius;
ShaderUniform shader_blur_v_texture,
shader_blur_h_radius,
shader_blur_v_texture,
shader_blur_v_radius;
ShaderUniform shader_remanency_source,
shader_remanency_buffer,
@@ -193,8 +193,8 @@ int Render::InitDraw(void)
fbo_back = new FrameBuffer(screen_size);
fbo_front = new FrameBuffer(screen_size);
fbo_buffer = new FrameBuffer(screen_size);
fbo_blur_h = new FrameBuffer(screen_size / 2);
fbo_blur_v = new FrameBuffer(screen_size / 2);
fbo_blur_h = new FrameBuffer(screen_size);
fbo_blur_v = new FrameBuffer(screen_size);
fbo_ping = new FrameBuffer(screen_size);
fbo_pong = new FrameBuffer(screen_size);
// shader simple
@@ -273,8 +273,8 @@ Render::Render(caca_canvas_t *caca)
m_polygon(true),
m_shader(true),
m_shader_remanency(true),
m_shader_blur(true),
m_shader_glow(true),
m_shader_blur(true),
m_shader_fx(true),
m_shader_postfx(true),
m_border(false)
@@ -461,38 +461,13 @@ void Render::Draw3D()
fbo_buffer->Unbind();
}

if (m_shader_fx && m_shader_blur)
{
// shader blur horizontal
fbo_ping->Bind();
shader_blur_h->Bind();
shader_blur_h->SetTexture(shader_blur_h_texture, fbo_back->GetTexture(), 0);
shader_blur_h->SetUniform(shader_blur_h_radius, blur / screen_size.x);
fs_quad();
shader_blur_h->Unbind();
fbo_ping->Unbind();
// shader blur vertical
fbo_front->Bind();
shader_blur_v->Bind();
shader_blur_v->SetTexture(shader_blur_v_texture, fbo_ping->GetTexture(), 0);
shader_blur_v->SetUniform(shader_blur_v_radius, blur / screen_size.y);
fs_quad();
shader_blur_v->Unbind();
}
else
{
// shader simple
fbo_front->Bind();
draw_shader_simple(fbo_back, 0);
}
fbo_front->Unbind();
// shader glow
if (m_shader_fx && m_shader_glow)
{
// shader blur horizontal
fbo_blur_h->Bind();
shader_blur_h->Bind();
shader_blur_h->SetTexture(shader_blur_h_texture, fbo_ping->GetTexture(), 0);
shader_blur_h->SetTexture(shader_blur_h_texture, fbo_back->GetTexture(), 0);
shader_blur_h->SetUniform(shader_blur_h_radius, glow_large / screen_size.x);
fs_quad();
shader_blur_h->Unbind();
@@ -522,26 +497,48 @@ void Render::Draw3D()
shader_blur_v->Unbind();
fbo_blur_v->Unbind();
// shader glow
fbo_pong->Bind();
fbo_front->Bind();
shader_glow->Bind();
shader_glow->SetTexture(shader_glow_glow, fbo_blur_v->GetTexture(), 0);
shader_glow->SetTexture(shader_glow_source, fbo_front->GetTexture(), 1);
shader_glow->SetTexture(shader_glow_source, fbo_back->GetTexture(), 1);
shader_glow->SetUniform(shader_glow_mix, glow_mix);
fs_quad();
shader_glow->Unbind();
fbo_front->Unbind();
}
if (!m_shader_fx)
else
{
// shader simple
fbo_pong->Bind();
draw_shader_simple(fbo_front, 0);
fbo_front->Bind();
draw_shader_simple(fbo_back, 0);
fbo_front->Unbind();
}

if (m_shader_fx && m_shader_blur)
{
// shader blur horizontal
fbo_ping->Bind();
shader_blur_h->Bind();
shader_blur_h->SetTexture(shader_blur_h_texture, fbo_front->GetTexture(), 0);
shader_blur_h->SetUniform(shader_blur_h_radius, blur / screen_size.x);
fs_quad();
shader_blur_h->Unbind();
fbo_ping->Unbind();
// shader blur vertical
fbo_front->Bind();
shader_blur_v->Bind();
shader_blur_v->SetTexture(shader_blur_v_texture, fbo_ping->GetTexture(), 0);
shader_blur_v->SetUniform(shader_blur_v_radius, blur / screen_size.y);
fs_quad();
shader_blur_v->Unbind();
fbo_front->Unbind();
}
fbo_pong->Unbind();
if (m_shader_postfx)
{
// shader postfx
shader_postfx->Bind();
shader_postfx->SetTexture(shader_postfx_texture, fbo_pong->GetTexture(), 0);
shader_postfx->SetTexture(shader_postfx_texture, fbo_front->GetTexture(), 0);
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);
@@ -564,7 +561,7 @@ void Render::Draw3D()
else
{
// shader simple
draw_shader_simple(fbo_pong, 0);
draw_shader_simple(fbo_front, 0);
}

glDisableClientState(GL_VERTEX_ARRAY);


Завантаження…
Відмінити
Зберегти