Преглед изворни кода

remanency expanded to 6 buffers, 3 ared used and blended (2,4 and 6)

master
rez Sam Hocevar <sam@hocevar.net> пре 12 година
родитељ
комит
d1b93d2501
6 измењених фајлова са 62 додато и 27 уклоњено
  1. +2
    -2
      neercs/neercs.cpp
  2. +1
    -1
      neercs/video/postfx.lolfx
  3. +10
    -5
      neercs/video/remanency.lolfx
  4. +47
    -17
      neercs/video/render.cpp
  5. +1
    -0
      neercs/video/render.h
  6. +1
    -2
      neercs/video/text.lolfx

+ 2
- 2
neercs/neercs.cpp Прегледај датотеку

@@ -76,7 +76,7 @@ void Neercs::TickGame(float seconds)
caca_set_color_argb(m_caca, 0xfff, bg_color);
caca_clear_canvas(m_caca);

caca_set_color_argb(m_caca, 0xc48, bg_color);
caca_set_color_argb(m_caca, 0xa46, bg_color);
for(int i = 0; i < h; i++)
{
float a = M_PI / 180 * i * 16 + m_time * 4;
@@ -120,7 +120,7 @@ void Neercs::TickGame(float seconds)
caca_printf(m_caca, 2, h - 3, "W=%i", w);
caca_printf(m_caca, 2, h - 2, "H=%i", h);

caca_set_color_argb(m_caca, hex_color(0.6f + 0.4f * lol::cos(m_time * 2), 0.125f, 0.125f), bg_color);
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");
}



+ 1
- 1
neercs/video/postfx.lolfx Прегледај датотеку

@@ -94,4 +94,4 @@ void main(void)
//color*=2.0*letterbox(z,-0.75,0.125)*2.0; // vignetting
color*=letterbox(z,-0.75,0.95); // letterbox
gl_FragColor=vec4(color,1.0);
}
}

+ 10
- 5
neercs/video/remanency.lolfx Прегледај датотеку

@@ -13,16 +13,21 @@ void main()
#version 120

uniform sampler2D texture;
uniform sampler2D texture_prv;
uniform sampler2D texture_buffer1;
uniform sampler2D texture_buffer2;
uniform sampler2D texture_buffer3;
uniform vec2 screen_size;
uniform float time;
uniform float value;
uniform float value1;
uniform float value2;

void main(void)
{
vec2 p=gl_TexCoord[0].xy;
vec4 source=texture2D(texture,p);
vec4 remanency=texture2D(texture_prv,p);
vec4 color=source*(1.0-value)+remanency*value;
vec4 buffer1=texture2D(texture_buffer1,p);
vec4 buffer2=texture2D(texture_buffer2,p);
vec4 buffer3=texture2D(texture_buffer3,p);
vec4 color=source*value1+buffer1*value2+buffer2*value2+buffer3*value2;
gl_FragColor=color;
}
}

+ 47
- 17
neercs/video/render.cpp Прегледај датотеку

@@ -50,7 +50,7 @@ int active = true; // window active flag
float nearplane = 0.1f; // nearplane
float farplane = 1000.0f; // farplane
int polygon_fillmode = GL_FILL; // fill mode
bool key_state = 0; // key state
bool key_state = 0; // key state
/* window variable */
ivec2 screen_size; // screen size
vec3 screen_color = CR * vec3(32, 32, 32); // screen color
@@ -84,7 +84,7 @@ float beat_speed = 2.0f; // speed
/* window variable */
ivec2 border; // border width
/* text variable */
ivec2 ratio_2d(1,3); // 2d ratio
ivec2 ratio_2d(2,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
@@ -116,10 +116,13 @@ ShaderUniform shader_blur_v_texture,
shader_blur_v_time,
shader_blur_v_value;
ShaderUniform shader_remanency_texture,
shader_remanency_texture_prv,
shader_remanency_texture_buffer1,
shader_remanency_texture_buffer2,
shader_remanency_texture_buffer3,
shader_remanency_screen_size,
shader_remanency_time,
shader_remanency_value;
shader_remanency_value1,
shader_remanency_value2;
ShaderUniform shader_glow_texture,
shader_glow_texture_prv,
shader_glow_screen_size,
@@ -143,7 +146,8 @@ ShaderUniform shader_postfx_texture,
shader_postfx_scanline,
shader_postfx_sync;

FrameBuffer *fbo_back, *fbo_front, *fbo_buffer;
FrameBuffer *fbo_back, *fbo_front;
FrameBuffer *fbo_buffer1, *fbo_buffer2, *fbo_buffer3, *fbo_buffer4, *fbo_buffer5, *fbo_buffer6;
FrameBuffer *fbo_blur_h, *fbo_blur_v, *fbo_ping, *fbo_pong;

TextRender *text_render;
@@ -182,7 +186,12 @@ int Render::InitDraw(void)
/* Initialise framebuffer objects */
fbo_back = new FrameBuffer(screen_size);
fbo_front = new FrameBuffer(screen_size);
fbo_buffer = new FrameBuffer(screen_size);
fbo_buffer1 = new FrameBuffer(screen_size);
fbo_buffer2 = new FrameBuffer(screen_size);
fbo_buffer3 = new FrameBuffer(screen_size);
fbo_buffer4 = new FrameBuffer(screen_size);
fbo_buffer5 = new FrameBuffer(screen_size);
fbo_buffer6 = new FrameBuffer(screen_size);
fbo_blur_h = new FrameBuffer(screen_size / glow_fbo_size);
fbo_blur_v = new FrameBuffer(screen_size / glow_fbo_size);
fbo_ping = new FrameBuffer(screen_size);
@@ -205,10 +214,13 @@ int Render::InitDraw(void)
// shader remanency
shader_remanency = Shader::Create(lolfx_remanency);
shader_remanency_texture = shader_remanency->GetUniformLocation("texture");
shader_remanency_texture_prv = shader_remanency->GetUniformLocation("texture_prv");
shader_remanency_texture_buffer1 = shader_remanency->GetUniformLocation("texture_buffer1");
shader_remanency_texture_buffer2 = shader_remanency->GetUniformLocation("texture_buffer2");
shader_remanency_texture_buffer3 = shader_remanency->GetUniformLocation("texture_buffer3");
shader_remanency_screen_size = shader_remanency->GetUniformLocation("screen_size");
shader_remanency_time = shader_remanency->GetUniformLocation("time");
shader_remanency_value = shader_remanency->GetUniformLocation("value");
shader_remanency_value1 = shader_remanency->GetUniformLocation("value1");
shader_remanency_value2 = shader_remanency->GetUniformLocation("value2");
// shader glow
shader_glow = Shader::Create(lolfx_glow);
shader_glow_texture = shader_glow->GetUniformLocation("texture");
@@ -244,7 +256,7 @@ int Render::InitDraw(void)
int Render::CreateGLWindow()
{
screen_size = Video::GetSize();
border = 24 * ratio_2d;
border = 18 * ratio_2d;
border.y = border.x; // enabled to get same border everywhere
canvas_char = (screen_size - border * 2) / (font_size * ratio_2d);
canvas_size = canvas_char * font_size * ratio_2d;
@@ -428,10 +440,13 @@ void Render::Draw3D()
fbo_ping->Bind();
shader_remanency->Bind();
shader_remanency->SetTexture(shader_remanency_texture, fbo_back->GetTexture(), 0);
shader_remanency->SetTexture(shader_remanency_texture_prv, fbo_buffer->GetTexture(), 1);
shader_remanency->SetTexture(shader_remanency_texture_buffer1, fbo_buffer2->GetTexture(), 1);
shader_remanency->SetTexture(shader_remanency_texture_buffer2, fbo_buffer4->GetTexture(), 2);
shader_remanency->SetTexture(shader_remanency_texture_buffer3, fbo_buffer6->GetTexture(), 3);
shader_remanency->SetUniform(shader_remanency_screen_size, vec2(1.0f));
shader_remanency->SetUniform(shader_remanency_time, fx_angle);
shader_remanency->SetUniform(shader_remanency_value, 0.8f);
shader_remanency->SetUniform(shader_remanency_value1, 0.25f);
shader_remanency->SetUniform(shader_remanency_value2, 0.25f);
fs_quad();
shader_remanency->Unbind();
fbo_ping->Unbind();
@@ -440,9 +455,24 @@ void Render::Draw3D()
draw_shader_simple(fbo_ping, 0);
fbo_back->Unbind();
// save previous fbo
fbo_buffer->Bind();
fbo_buffer6->Bind();
draw_shader_simple(fbo_buffer5, 0);
fbo_buffer6->Unbind();
fbo_buffer5->Bind();
draw_shader_simple(fbo_buffer4, 0);
fbo_buffer5->Unbind();
fbo_buffer4->Bind();
draw_shader_simple(fbo_buffer3, 0);
fbo_buffer4->Unbind();
fbo_buffer3->Bind();
draw_shader_simple(fbo_buffer2, 0);
fbo_buffer3->Unbind();
fbo_buffer2->Bind();
draw_shader_simple(fbo_buffer1, 0);
fbo_buffer2->Unbind();
fbo_buffer1->Bind();
draw_shader_simple(fbo_front, 0);
fbo_buffer->Unbind();
fbo_buffer1->Unbind();
}

if (m_shader_fx && m_shader_blur)
@@ -453,7 +483,7 @@ void Render::Draw3D()
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_time, fx_angle);
shader_blur_h->SetUniform(shader_blur_h_value, 0.5f/screen_size.x);
shader_blur_h->SetUniform(shader_blur_h_value, 0.375f/screen_size.x);
fs_quad();
shader_blur_h->Unbind();
fbo_ping->Unbind();
@@ -463,7 +493,7 @@ void Render::Draw3D()
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_time, fx_angle);
shader_blur_v->SetUniform(shader_blur_v_value, 0.5f/screen_size.y);
shader_blur_v->SetUniform(shader_blur_v_value, 0.375f/screen_size.y);
fs_quad();
shader_blur_v->Unbind();
}
@@ -483,7 +513,7 @@ void Render::Draw3D()
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_time, fx_angle);
shader_blur_h->SetUniform(shader_blur_h_value, 2.25f / screen_size.x);
shader_blur_h->SetUniform(shader_blur_h_value, 2.5f / screen_size.x);
fs_quad();
shader_blur_h->Unbind();
fbo_blur_h->Unbind();
@@ -493,7 +523,7 @@ void Render::Draw3D()
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_time, fx_angle);
shader_blur_v->SetUniform(shader_blur_h_value, 2.25f / screen_size.y);
shader_blur_v->SetUniform(shader_blur_h_value, 2.5f / screen_size.y);
fs_quad();
shader_blur_v->Unbind();
fbo_blur_v->Unbind();


+ 1
- 0
neercs/video/render.h Прегледај датотеку

@@ -1,4 +1,5 @@
//
// Neercs
//

#if !defined __VIDEO_RENDER_H__


+ 1
- 2
neercs/video/text.lolfx Прегледај датотеку

@@ -53,5 +53,4 @@ void main(void)
vec2 c = gl_PointCoord * (1.0 / 32.0) + pass_UV;
float t = texture2D(in_Texture, c).x;
gl_FragColor = mix(pass_Background, pass_Foreground, t);
}

}

Loading…
Откажи
Сачувај