Explorar el Código

added TONS of new parameters into the setup menu

master
rez Sam Hocevar <sam@hocevar.net> hace 12 años
padre
commit
0463ff8732
Se han modificado 3 ficheros con 117 adiciones y 96 borrados
  1. +16
    -31
      neercs/video/postfx.lolfx
  2. +101
    -64
      neercs/video/render.cpp
  3. +0
    -1
      neercs/video/render.h

+ 16
- 31
neercs/video/postfx.lolfx Ver fichero

@@ -15,29 +15,28 @@ void main()
uniform sampler2D texture;
uniform vec2 screen_size;
uniform float time;
uniform float deform;
uniform vec2 deform;
uniform vec4 ghost;
uniform vec3 filter;
uniform vec3 color;
uniform vec3 retrace;
uniform vec2 offset;
uniform float noise;
uniform float aberration;
uniform bool moire;
uniform vec4 moire_h;
uniform vec4 moire_v;
uniform bool scanline;
uniform vec4 scanline_h;
uniform vec4 scanline_v;
uniform vec2 corner;
uniform float flash;
uniform float sync;

const float PI=3.14159265358979323846;

vec2 zoom(in vec2 p,in float radius)
vec2 screen(in vec2 p,in float radius)
{
float d=deform+sync*0.0625;
float zoom=1.5-(radius*cos(p.x*d)+radius*cos(p.y*d));
return p*zoom-0.5;
float d=deform.x+sync*0.0625;
return p*(1.5-(radius*cos(p.x*d)+radius*cos(p.y*d)))-0.5;
}

vec3 get_color(in sampler2D tex,in vec2 p)
@@ -52,7 +51,7 @@ float rand(in vec2 p)

float letterbox(in vec2 p,in float radius,in float smooth)
{
return 1.0-smoothstep(smooth,1.0,length(max(abs(p*2.0+1.0)+vec2(radius),0.0))-radius);
return 1.0-smoothstep(smooth,1.0,length(max(abs(p*2.0+1.0)-vec2(radius),0.0))+radius);
}

void main(void)
@@ -60,9 +59,9 @@ void main(void)
vec2 q=gl_FragCoord.xy/screen_size.xy;
vec2 p=-1.0+2.0*gl_FragCoord.xy/screen_size.xy;
p.y+=0.025*sync;
vec2 z =zoom(p,0.5250);
vec2 z1=zoom(p,0.5225);
vec2 z2=zoom(p,0.5275);
vec2 z =screen(p,deform.y);
vec2 z1=screen(p,deform.y-ghost.x*0.1);
vec2 z2=screen(p,deform.y+ghost.z*0.1);
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)));
@@ -79,7 +78,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*0.25+glass2*glass2*0.25;
vec3 c=source-glass1*glass1*ghost.y+glass2*glass2*ghost.w;

float a=(c.x+c.y+c.z)/3.0;
vec3 g=vec3(a,a,a);
@@ -92,25 +91,11 @@ void main(void)
c+=ca; // chromatic aberration
c-=retrace.x*mod(z.y*retrace.y+time*retrace.z,1.0); // retrace
c-=(vec3(rnd.x-rnd.y))*noise; // noise
if(moire)
{
c*=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
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
}
else
{
c*=(moire_h.x+moire_v.x)*0.5;
}
if(scanline)
{
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
}
else
{
c*=(scanline_h.x+scanline_v.x)*0.5;
}
c*=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
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*=letterbox(z,-0.75,0.95); // letnoiseterbox
c*=letterbox(z,corner.x,corner.y); // letterbox
gl_FragColor=vec4(c,1.0);
}

+ 101
- 64
neercs/video/render.cpp Ver fichero

@@ -95,7 +95,7 @@ ivec2 canvas_size(0,0); // caca size
/* setup variable */
bool setup_switch=false; // switch [option/item]
int setup_option=0; // selected option
int setup_option_n=7; // option number
int setup_option_n=9; // option number
int setup_item=0; // selected item
int setup_item_n=8; // item number
int setup_item_key=0; // item array key
@@ -130,8 +130,16 @@ char const *setup_text[] = {
"",
"",
"",
"screen",
"enable",
"deform ratio",
"zoom base",
"zoom variable",
"corner radius",
"corner blur",
"",
"",
"color",
"postfx enable",
"filter red",
"filter green",
"filter blue",
@@ -139,20 +147,21 @@ char const *setup_text[] = {
"contrast",
"grayscale",
"",
"modifier",
"deform ratio",
"retrace strength",
"retrace length",
"retrace speed",
"",
"",
"",
"",
"noise",
"offset h",
"offset v",
"noise",
"aberration",
"retrace strength",
"retrace length",
"retrace speed",
"",
"ghost",
"back distance",
"back strength",
"front distance",
"front strength",
"",
"",
"",
@@ -181,25 +190,25 @@ float value, angle, radius, scale, speed;
/* shader variable */
vec2 buffer(0.7f,0.3f); // [new frame mix,old frame mix]
vec2 remanency(0.3f,0.7f); // remanency [source mix,buffer mix]
vec2 glow_mix(0.5f,0.5f); // glow mix [source mix,glow mix]
vec2 glow_mix(0.6f,0.4f); // glow mix [source mix,glow mix]
vec2 glow_large(2.0f,2.0f); // large glow radius [center,corner]
vec2 glow_small(1.0f,1.0f); // small glow radius [center,corner]
vec2 blur(0.25f,0.5f); // glow radius [center,corner]
//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.7f; // deformation ratio
vec3 postfx_filter(0.8f,0.9f,0.4f);// color filter [red,green,blue]
vec3 postfx_color(1.8f,1.8f,0.5f); // color modifier [brightness,contrast,grayscale]
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]
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
bool postfx_moire = true; // moire
vec4 postfx_moire_h(0.75f,-0.25f,0.0f,1.0f);
vec4 postfx_moire_v(0.75f,-0.25f,1.0f,1.5f);
bool postfx_scanline = true; // scanline
vec4 postfx_scanline_h(0.75f, 0.25f,0.0f,2.0f);// vertical scanline [base,variable,repeat x,repeat y]
vec4 postfx_scanline_v(0.75f,-0.25f,2.0f,0.0f);// horizontal scanline [base,variable,repeat x,repeat y]
vec4 postfx_ghost(0.1f,0.25f,0.1f,0.5f); // ghost picture [distance,strength,distance,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]
vec4 postfx_scanline_v(0.75f,-0.25f,2.0f,0.0f); // horizontal scanline [base,variable,repeat x,repeat y]
//------------------------------//
vec4 setup_var[]={
vec4(0), /* remanency */
@@ -212,7 +221,7 @@ vec4 setup_var[]={
vec4(0),
vec4(0),
vec4(0), /* glow */
vec4(0, 1, 1, 0),
vec4(0, 1, 1, 1),
vec4(0.0f, 1.0f, 0.1f, glow_mix.x),
vec4(0.0f, 1.0f, 0.1f, glow_mix.y),
vec4(0.0f, 4.0f, 0.1f, glow_large.x),
@@ -221,7 +230,7 @@ vec4 setup_var[]={
vec4(0.0f, 2.0f, 0.1f, glow_small.y),
vec4(0),
vec4(0), /* blur */
vec4(0, 1, 1, 0),
vec4(0, 1, 1, 1),
vec4(0.0f, 2.0f, 0.1f, blur.x),
vec4(0.0f, 2.0f, 0.1f, blur.y),
vec4(0),
@@ -229,8 +238,16 @@ vec4 setup_var[]={
vec4(0),
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),
vec4(0),
vec4(0), /* color */
vec4(0, 1, 1, 0),
vec4(0.0f, 1.0f, 0.1f, postfx_filter.x),
vec4(0.0f, 1.0f, 0.1f, postfx_filter.y),
vec4(0.0f, 1.0f, 0.1f, postfx_filter.z),
@@ -238,24 +255,43 @@ vec4 setup_var[]={
vec4(0.0f, 4.0f, 0.1f, postfx_color.y),
vec4(0.0f, 1.5f, 0.1f, postfx_color.z),
vec4(0),
vec4(0), /* modifier */
vec4(0.0f, 1.0f, 0.05f, postfx_deform),
vec4(0.0f, 1.0f, 0.05f, postfx_retrace.x),
vec4(0.0f, 8.0f, 1.0f, postfx_retrace.y),
vec4(0.0f, 8.0f, 1.0f, postfx_retrace.z),
vec4(0),
vec4(0),
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, 1.0f, 0.05f, postfx_noise),
vec4(0.0f, 5.0f, 0.5f, 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, 4.0f, 0.25f, postfx_retrace.z),
vec4(0),
vec4(0), /* ghost */
vec4(0.0f, 0.2f, 0.01f, postfx_ghost.x),
vec4(0.0f, 1.0f, 0.05f, postfx_ghost.y),
vec4(0.0f, 0.2f, 0.01f, postfx_ghost.z),
vec4(0.0f, 1.0f, 0.05f, postfx_ghost.w),
vec4(0),
vec4(0),
vec4(0),
vec4(0),
vec4(0), /* moire */
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.1f, postfx_moire_v.x),
vec4(-0.5f, 0.5f, 0.1f, 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), /* scanline */
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.1f, postfx_scanline_v.x),
vec4(-0.5f, 0.5f, 0.1f, 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)
};

@@ -275,16 +311,24 @@ void Render::UpdateVar()
blur = vec2(setup_var[k].w, setup_var[k + 1].w); k += 2;
k += 6;
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;
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 += 2;
postfx_deform = 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 += 5;
k += 3;
postfx_offset = vec2(setup_var[k].w, setup_var[k + 1].w); k += 2;
postfx_noise = setup_var[k].w; k++;
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;
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;
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++;
postfx_scanline_h = vec4(setup_var[k].w, setup_var[k + 1].w, setup_var[k + 2].w, setup_var[k + 3].w); k += 4;
postfx_scanline_v = vec4(setup_var[k].w, setup_var[k + 1].w, setup_var[k + 2].w, setup_var[k + 3].w); k += 4;
}

Shader *shader_simple;
@@ -313,16 +357,16 @@ ShaderUniform shader_postfx_texture,
shader_postfx_screen_size,
shader_postfx_time,
shader_postfx_deform,
shader_postfx_ghost,
shader_postfx_filter,
shader_postfx_color,
shader_postfx_corner,
shader_postfx_retrace,
shader_postfx_offset,
shader_postfx_noise,
shader_postfx_aberration,
shader_postfx_moire,
shader_postfx_moire_h,
shader_postfx_moire_v,
shader_postfx_scanline,
shader_postfx_scanline_h,
shader_postfx_scanline_v,
shader_postfx_flash,
@@ -408,16 +452,16 @@ 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_filter = shader_postfx->GetUniformLocation("filter");
shader_postfx_color = shader_postfx->GetUniformLocation("color");
shader_postfx_corner = shader_postfx->GetUniformLocation("corner");
shader_postfx_retrace = shader_postfx->GetUniformLocation("retrace");
shader_postfx_offset = shader_postfx->GetUniformLocation("offset");
shader_postfx_noise = shader_postfx->GetUniformLocation("noise");
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 = shader_postfx->GetUniformLocation("scanline_h");
shader_postfx_scanline_v = shader_postfx->GetUniformLocation("scanline_v");
shader_postfx_flash = shader_postfx->GetUniformLocation("flash");
@@ -453,10 +497,9 @@ Render::Render(caca_canvas_t *caca)
m_setup(true),
m_shader(true),
m_shader_remanency(true),
m_shader_glow(false),
m_shader_blur(false),
m_shader_postfx(false),
m_border(false)
m_shader_glow(true),
m_shader_blur(true),
m_shader_postfx(true)
{
text_render = new TextRender(m_caca, font_size);
}
@@ -674,15 +717,23 @@ void Render::TickDraw(float seconds)
}
/* display variable */
int y = setup_p.y + setup_size.y;
setup_item_key = setup_option * (setup_item_n + 1) + 1 + setup_item;
caca_set_color_argb(m_caca, setup_color.y, setup_color.x);
caca_draw_line(m_caca, setup_p.x, y, setup_p.x + setup_size.x, y,' ');
if (setup_switch)
if (setup_switch && setup_text[setup_item_key] != "")
{
setup_item_key = setup_option * (setup_item_n + 1) + 1 + setup_item;
int w = setup_size.x - 3 - 4;
caca_printf(m_caca, setup_p.x + setup_size.x - 4, y, "%4.2f", setup_var[setup_item_key].w);
caca_draw_line(m_caca, setup_p.x + 1, y, setup_p.x + 1 + w, y,'.');
if(setup_var[setup_item_key].w > setup_var[setup_item_key].x) caca_draw_line(m_caca, setup_p.x + 1, y, setup_p.x + 1 + int(w / (setup_var[setup_item_key].y - setup_var[setup_item_key].x) * setup_var[setup_item_key].w), y,'x');
int bar_w = (w / (setup_var[setup_item_key].y - setup_var[setup_item_key].x) * setup_var[setup_item_key].w);
if ((setup_var[setup_item_key].y - setup_var[setup_item_key].x) / setup_var[setup_item_key].z > 2)
{
caca_printf(m_caca, setup_p.x + setup_size.x - 4, y, "%4.2f", setup_var[setup_item_key].w);
caca_draw_line(m_caca, setup_p.x + 1, y, setup_p.x + 1 + w, y,'.');
if(setup_var[setup_item_key].w > setup_var[setup_item_key].x) caca_draw_line(m_caca, setup_p.x + 1, y, setup_p.x + 1 + bar_w, y,'x');
}
else
{
caca_put_str(m_caca, setup_p.x + setup_size.x - 3, y, (setup_var[setup_item_key].w == setup_var[setup_item_key].y)?"YES":" NO");
}
}
}

@@ -697,9 +748,7 @@ void Render::Draw2D()
text_render->Render();

if (m_shader)
{
fbo_back->Bind();
}

glViewport(0, 0, screen_size.x, screen_size.y);

@@ -722,18 +771,6 @@ void Render::Draw2D()
mat4 m = mat4::ortho(0, screen_size.x, screen_size.y, 0, -1.f, 1.f);
glLoadMatrixf(&m[0][0]);
glMatrixMode(GL_MODELVIEW);
// draw border
if (m_border)
{
glDisable(GL_TEXTURE_2D);
glDisable(GL_BLEND);
glColor3f(1.0f, 1.0f, 1.0f);
rectangle(border.x - ratio_2d.x, border.y - ratio_2d.y, canvas_size.x + ratio_2d.x * 2, ratio_2d.y);
rectangle(border.x - ratio_2d.x, border.y, ratio_2d.x, canvas_size.y);
rectangle(border.x + canvas_size.x, border.y, ratio_2d.x, canvas_size.y);
rectangle(border.x - ratio_2d.x, border.y + canvas_size.y, canvas_size.x + ratio_2d.x * 2, ratio_2d.y);
glEnable(GL_BLEND);
}
}

void Render::Draw3D()
@@ -861,16 +898,16 @@ 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_filter, postfx_filter);
shader_postfx->SetUniform(shader_postfx_color, postfx_color);
shader_postfx->SetUniform(shader_postfx_corner, postfx_corner);
shader_postfx->SetUniform(shader_postfx_retrace, postfx_retrace);
shader_postfx->SetUniform(shader_postfx_offset, postfx_offset);
shader_postfx->SetUniform(shader_postfx_noise, postfx_noise);
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, postfx_scanline_h);
shader_postfx->SetUniform(shader_postfx_scanline_v, postfx_scanline_v);
shader_postfx->SetUniform(shader_postfx_flash, flash_value);


+ 0
- 1
neercs/video/render.h Ver fichero

@@ -37,7 +37,6 @@ private:
bool m_shader_blur;
bool m_shader_glow;
bool m_shader_postfx;
bool m_border;
};

#endif // __VIDEO_RENDER_H__


Cargando…
Cancelar
Guardar