Browse Source

moved some code from postfx to a new shader -> color.lolfx

master
parent
commit
9501ce12fc
9 changed files with 120 additions and 145 deletions
  1. +1
    -1
      neercs/Makefile.am
  2. +1
    -1
      neercs/neercs.vcxproj
  3. +1
    -1
      neercs/neercs.vcxproj.filters
  4. +34
    -0
      neercs/video/color.lolfx
  5. +3
    -3
      neercs/video/noise.lolfx
  6. +6
    -20
      neercs/video/postfx.lolfx
  7. +0
    -52
      neercs/video/radial.lolfx
  8. +72
    -65
      neercs/video/render.cpp
  9. +2
    -2
      neercs/video/render.h

+ 1
- 1
neercs/Makefile.am View File

@@ -11,7 +11,7 @@ neercs_SOURCES = \
video/render.cpp video/render.h \
video/text-render.cpp video/text-render.h \
video/simple.lolfx \
video/blurh.lolfx video/blurv.lolfx video/glow.lolfx video/radial.lolfx \
video/blurh.lolfx video/blurv.lolfx video/glow.lolfx video/color.lolfx \
video/remanency.lolfx video/noise.lolfx video/postfx.lolfx\
video/text.lolfx
neercs_CPPFLAGS = @LOL_CFLAGS@ @PIPI_CFLAGS@ @CACA_CFLAGS@ -Iold


+ 1
- 1
neercs/neercs.vcxproj View File

@@ -83,7 +83,7 @@
<LolFxCompile Include="video\blurh.lolfx" />
<LolFxCompile Include="video\blurv.lolfx" />
<LolFxCompile Include="video\glow.lolfx" />
<LolFxCompile Include="video\radial.lolfx" />
<LolFxCompile Include="video\color.lolfx" />
<LolFxCompile Include="video\remanency.lolfx" />
<LolFxCompile Include="video\noise.lolfx" />
<LolFxCompile Include="video\postfx.lolfx" />


+ 1
- 1
neercs/neercs.vcxproj.filters View File

@@ -129,7 +129,7 @@
<LolFxCompile Include="video\glow.lolfx">
<Filter>video</Filter>
</LolFxCompile>
<LolFxCompile Include="video\radial.lolfx">
<LolFxCompile Include="video\color.lolfx">
<Filter>video</Filter>
</LolFxCompile>
<LolFxCompile Include="video\remanency.lolfx">


+ 34
- 0
neercs/video/color.lolfx View File

@@ -0,0 +1,34 @@
-- GLSL.Vert --

#version 120

void main()
{
gl_Position=gl_Vertex;
gl_TexCoord[0]=gl_MultiTexCoord0;
}

-- GLSL.Frag --

#version 120

uniform sampler2D texture;
uniform vec2 screen_size;
uniform vec3 filter;
uniform vec3 color;
uniform float flash;

void main(void)
{
vec2 p=gl_FragCoord.xy/screen_size.xy;
vec3 c=texture2D(texture,p).xyz;

float a=(c.x+c.y+c.z)/3.0;
c=mix(c,vec3(a),color.z); // grayscale
c*=filter; // filter
c*=color.x; // brightness
c=0.5+(c-0.5)*color.y; // contrast
c+=flash; // flash

gl_FragColor=vec4(c,1.0);
}

+ 3
- 3
neercs/video/noise.lolfx View File

@@ -32,8 +32,8 @@ void main(void)
float r2=rand(p,time,70425.2854);
vec2 o=(offset-offset*2.0*r1)/screen_size;

vec3 c=texture2D(texture,p+o).xyz; // offset
c*=1.0+(noise-noise*2.0*r1); // noise
c-=retrace.x*mod(p.y*retrace.y+time*retrace.z,1.0); // retrace
vec3 c=texture2D(texture,p+o).xyz; // offset
c*=1.0+(noise-noise*2.0*r1); // noise
c-=retrace.x*0.01*mod(p.y*retrace.y+time*retrace.z,1.0); // retrace
gl_FragColor=vec4(c,1.0);
}

+ 6
- 20
neercs/video/postfx.lolfx View File

@@ -18,16 +18,13 @@ uniform float time;
uniform vec2 deform;
uniform vec4 ghost1;
uniform vec4 ghost2;
uniform vec3 filter;
uniform vec3 color;
uniform float vignetting;
uniform float aberration;
uniform vec4 moire_h;
uniform vec4 moire_v;
uniform vec4 scanline_h;
uniform vec4 scanline_v;
uniform vec2 corner;
uniform float vignetting;
uniform float flash;
uniform float sync;

vec2 screen(in vec2 p,in float radius)
@@ -51,7 +48,7 @@ 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 =screen(p,deform.y);
vec2 z=screen(p,deform.y);
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);
@@ -60,24 +57,13 @@ void main(void)
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);

vec3 ca;
ca.x=get_color(texture,vec2(z.x-v,z.y)).x;
ca.y=get_color(texture,vec2(z.x ,z.y)).y;
ca.z=get_color(texture,vec2(z.x+v,z.y)).z;

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);
c=mix(c,g,color.z); // gray
c*=filter; // filter
c*=color.x; // brightness
c=0.5+(c-0.5)*color.y; // contrast
float v=aberration/float(screen_size.x)+aberration/float(screen_size.x)*(2.0-mask);
vec3 ca1=get_color(texture,vec2(z.x-v,z.y));
vec3 ca2=get_color(texture,vec2(z.x+v,z.y));
c+=vec3(ca1.x,c.y,ca2.z); // chromatic aberration

c+=flash; // flash
c+=ca; // chromatic aberration
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


+ 0
- 52
neercs/video/radial.lolfx View File

@@ -1,54 +0,0 @@

#version 120

void main()
{
gl_Position=gl_Vertex;
gl_TexCoord[0]=gl_MultiTexCoord0;
}


#version 120

uniform sampler2D texture;
uniform vec2 screen_size;
uniform float time;
uniform float value1;
uniform float value2;
uniform float color;

float PI=3.14159265358979323846;

vec3 deform(in vec2 p)
{
vec2 uv;
float zoom=0.5;
uv.x=p.x*zoom-0.5;
uv.y=p.y*zoom-0.5;
return texture2D(texture,uv).xyz;
}

void main(void)
{
int n=32;

vec2 p=-1.0+4.0*gl_TexCoord[0].xy;
vec2 s=p;
vec3 source=deform(s);

vec3 total=vec3(0,1.0,1.0);

vec2 d=-p/float(n*2);
float w=value1;
for(int i=0;i<n;i++)
{
vec3 c=deform(s);
vec3 data=c+vec3(c.x*color-p.x*color,c.z*color+p.y*color,c.y*color+p.x*color);
total+=data*w;
w*=value2;
s+=d;
}
gl_FragColor=vec4(source*0.625+total*0.025,1.0);
}

+ 72
- 65
neercs/video/render.cpp View File

@@ -36,7 +36,7 @@ extern char const *lolfx_remanency;
extern char const *lolfx_blurh;
extern char const *lolfx_blurv;
extern char const *lolfx_glow;
extern char const *lolfx_radial;
extern char const *lolfx_color;
extern char const *lolfx_noise;
extern char const *lolfx_postfx;

@@ -87,26 +87,26 @@ float beat_speed = 2.0f; // speed
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 remanency(0.5f,0.5f); // remanency [source mix,buffer 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]
vec2 noise_offset(1.5f,1.5f); // random line [horizontal,vertical]
float noise_noise = 0.15f; // noise
vec3 noise_retrace(0.02f,1.0f,0.5f); // retrace [strength,length,speed]
vec2 blur(0.5f,0.5f); // blur radius [center,corner]
vec3 color_filter(0.9f,1.0f,0.7f); // color filter [red,green,blue]
vec3 color_color(1.1f,1.1f,0.25f); // color modifier [brightness,contrast,grayscale]
vec2 noise_offset(2.0f,2.0f); // random line [horizontal,vertical]
float noise_noise = 0.25f; // noise
vec3 noise_retrace(1.0f,1.0f,0.5f); // retrace [strength,length,speed]
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
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]
float postfx_aberration = 4.0f; // chromatic aberration
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]
vec2 postfx_corner(0.75f,0.95f); // corner [radius,blur]
/* window variable */
ivec2 border; // border width
/* text variable */
@@ -126,7 +126,6 @@ int setup_n = 0; // contextual option/item number
ivec2 setup_p(1,1); // position [x,y]
ivec3 setup_size(30,0,12); // size [w,h,split]
ivec2 setup_color(0x678,0x234); // color [foreground,background]
//vec3 radial(2.0f,0.8f,0); // radial [mix,strength,color mode]
char const *setup_text[] = {
"theme",
"default",
@@ -266,20 +265,20 @@ vec4 setup_var[]={ // setup variable [start,end,step,value]
vec4(0),
vec4(0),
vec4(0), /* color */
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),
vec4(0.0f, 4.0f, 0.1f, postfx_color.x),
vec4(0.0f, 4.0f, 0.1f, postfx_color.y),
vec4(0.0f, 1.5f, 0.1f, postfx_color.z),
vec4(0.0f, 8.0f, 0.5f, postfx_aberration),
vec4(0.0f, 1.0f, 0.05f, color_filter.x),
vec4(0.0f, 1.0f, 0.05f, color_filter.y),
vec4(0.0f, 1.0f, 0.05f, color_filter.z),
vec4(0.0f, 2.0f, 0.05f, color_color.x),
vec4(0.0f, 2.0f, 0.05f, color_color.y),
vec4(0.0f, 1.0f, 0.05f, color_color.z),
vec4(0.0f, 8.0f, 0.50f, postfx_aberration),
vec4(0),
vec4(0), /* noise */
vec4( 0, 1, 1, 1),
vec4(0.0f, 4.0f, 0.50f, noise_offset.x),
vec4(0.0f, 4.0f, 0.50f, noise_offset.y),
vec4(0.0f, 0.5f, 0.25f, noise_noise),
vec4(0.0f, 0.2f, 0.01f, noise_retrace.x),
vec4(0.0f, 0.5f, 0.05f, noise_noise),
vec4(0.0f, 4.0f, 0.25f, noise_retrace.x),
vec4(0.0f, 8.0f, 0.50f, noise_retrace.y),
vec4(0.0f, 4.0f, 0.25f, noise_retrace.z),
vec4(0),
@@ -334,8 +333,8 @@ void Render::UpdateVar()
postfx_corner = vec2(setup_var[k].w, setup_var[k + 1].w); k += 2;
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;
color_filter = vec3(setup_var[k].w, setup_var[k + 1].w, setup_var[k + 2].w); k += 3;
color_color = vec3(setup_var[k].w, setup_var[k + 1].w, setup_var[k + 2].w); k += 3;
postfx_aberration = setup_var[k].w; k++;
k += 2; /* noise */
m_shader_noise = (setup_var[k].w == 1) ? true : false; k++;
@@ -356,7 +355,6 @@ void Render::UpdateVar()
int calc_item_length()
{
int n = !setup_switch ? setup_option_n : setup_item_n;
int v = 0;
for (int i = 0; i < n; i++)
{
int k = !setup_switch ? (i * (setup_item_n + 1)) : (setup_option * (setup_item_n + 1) + 1 + i);
@@ -367,7 +365,7 @@ int calc_item_length()

Shader *shader_simple;
Shader *shader_remanency;
Shader *shader_blur_h, *shader_blur_v, *shader_glow, *shader_radial;
Shader *shader_blur_h, *shader_blur_v, *shader_glow, *shader_color;
Shader *shader_noise, *shader_postfx;
// shader variables
ShaderUniform shader_simple_texture;
@@ -381,12 +379,11 @@ ShaderUniform shader_blur_h_texture,
ShaderUniform shader_glow_glow,
shader_glow_source,
shader_glow_mix;
ShaderUniform shader_radial_texture,
shader_radial_screen_size,
shader_radial_time,
shader_radial_value1,
shader_radial_value2,
shader_radial_color;
ShaderUniform shader_color_texture,
shader_color_screen_size,
shader_color_filter,
shader_color_color,
shader_color_flash;
ShaderUniform shader_noise_texture,
shader_noise_screen_size,
shader_noise_time,
@@ -400,16 +397,13 @@ ShaderUniform shader_postfx_texture,
shader_postfx_deform,
shader_postfx_ghost1,
shader_postfx_ghost2,
shader_postfx_filter,
shader_postfx_color,
shader_postfx_corner,
shader_postfx_vignetting,
shader_postfx_aberration,
shader_postfx_moire_h,
shader_postfx_moire_v,
shader_postfx_scanline_h,
shader_postfx_scanline_v,
shader_postfx_flash,
shader_postfx_corner,
shader_postfx_sync;

FrameBuffer *fbo_back, *fbo_front, *fbo_buffer;
@@ -477,14 +471,13 @@ int Render::InitDraw(void)
shader_blur_v = Shader::Create(lolfx_blurv);
shader_blur_v_texture = shader_blur_v->GetUniformLocation("texture");
shader_blur_v_radius = shader_blur_v->GetUniformLocation("radius");
// shader radial
shader_radial = Shader::Create(lolfx_radial);
shader_radial_texture = shader_radial->GetUniformLocation("texture");
shader_radial_screen_size = shader_radial->GetUniformLocation("screen_size");
shader_radial_time = shader_radial->GetUniformLocation("time");
shader_radial_value1 = shader_radial->GetUniformLocation("value1");
shader_radial_value2 = shader_radial->GetUniformLocation("value2");
shader_radial_color = shader_radial->GetUniformLocation("color");
// shader color
shader_color = Shader::Create(lolfx_color);
shader_color_texture = shader_color->GetUniformLocation("texture");
shader_color_screen_size = shader_color->GetUniformLocation("screen_size");
shader_color_filter = shader_color->GetUniformLocation("filter");
shader_color_color = shader_color->GetUniformLocation("color");
shader_color_flash = shader_color->GetUniformLocation("flash");
// shader noise
shader_noise = Shader::Create(lolfx_noise);
shader_noise_texture = shader_noise->GetUniformLocation("texture");
@@ -502,16 +495,13 @@ int Render::InitDraw(void)
shader_postfx_deform = shader_postfx->GetUniformLocation("deform");
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_aberration = shader_noise->GetUniformLocation("aberration");
shader_postfx_aberration = shader_postfx->GetUniformLocation("aberration");
shader_postfx_moire_h = shader_postfx->GetUniformLocation("moire_h");
shader_postfx_moire_v = shader_postfx->GetUniformLocation("moire_v");
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");
shader_postfx_corner = shader_postfx->GetUniformLocation("corner");
shader_postfx_sync = shader_postfx->GetUniformLocation("sync");

return true;
@@ -548,6 +538,7 @@ Render::Render(caca_canvas_t *caca)
m_shader_remanency(true),
m_shader_glow(true),
m_shader_blur(true),
m_shader_color(true),
m_shader_noise(true),
m_shader_postfx(true)
{
@@ -805,7 +796,7 @@ void Render::TickDraw(float seconds)
int w = setup_size.x - 3 - 4;
int bar_w = w / (setup_var[setup_item_key].y - setup_var[setup_item_key].x);
int bar_x = bar_w * setup_var[setup_item_key].x;
if ((setup_var[setup_item_key].y - setup_var[setup_item_key].x) / setup_var[setup_item_key].z > 2)
if ((setup_var[setup_item_key].y - setup_var[setup_item_key].x) / setup_var[setup_item_key].z > 1)
{
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, x, y, x - bar_x + bar_w * setup_var[setup_item_key].y, y,'.');
@@ -952,23 +943,22 @@ void Render::Draw3D()
fbo_front->Unbind();
}

if (m_shader_blur)
if (m_shader_color)
{
// shader blur horizontal
// shader color
fbo_ping->Bind();
shader_blur_h->Bind();
shader_blur_h->SetUniform(shader_blur_h_texture, fbo_front->GetTexture(), 0);
shader_blur_h->SetUniform(shader_blur_h_radius, blur / screen_size.x);
shader_color->Bind();
shader_color->SetUniform(shader_color_texture, fbo_front->GetTexture(), 0);
shader_color->SetUniform(shader_color_screen_size, (vec2)screen_size);
shader_color->SetUniform(shader_color_filter, color_filter);
shader_color->SetUniform(shader_color_color, color_color);
shader_color->SetUniform(shader_color_flash, flash_value);
fs_quad();
shader_blur_h->Unbind();
shader_color->Unbind();
fbo_ping->Unbind();
// shader blur vertical
// shader simple
fbo_front->Bind();
shader_blur_v->Bind();
shader_blur_v->SetUniform(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();
draw_shader_simple(fbo_ping, 0);
fbo_front->Unbind();
}

@@ -992,6 +982,26 @@ void Render::Draw3D()
fbo_front->Unbind();
}

if (m_shader_blur)
{
// shader blur horizontal
fbo_ping->Bind();
shader_blur_h->Bind();
shader_blur_h->SetUniform(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->SetUniform(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();
}

if (m_shader_postfx)
{
// shader postfx
@@ -1002,16 +1012,13 @@ void Render::Draw3D()
shader_postfx->SetUniform(shader_postfx_deform, postfx_deform);
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_aberration, postfx_aberration);
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_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_corner, postfx_corner);
shader_postfx->SetUniform(shader_postfx_sync, (float)fabs(sync_value*cosf((main_angle-sync_angle)*6.0f)));
fs_quad();
shader_postfx->Unbind();
@@ -1028,4 +1035,4 @@ void Render::Draw3D()

Render::~Render()
{
}
}

+ 2
- 2
neercs/video/render.h View File

@@ -34,9 +34,9 @@ private:
bool m_setup;
bool m_shader;
bool m_shader_remanency;
bool m_shader_blur;
bool m_shader_glow;
bool m_shader_radial;
bool m_shader_blur;
bool m_shader_color;
bool m_shader_noise;
bool m_shader_postfx;
};


Loading…
Cancel
Save