From d4e07923e9e17fbb47b365f18df405dd9970b91a Mon Sep 17 00:00:00 2001 From: Sam Hocevar Date: Wed, 19 Sep 2012 22:23:59 +0000 Subject: [PATCH] lolfx: use square brackets to indicate shader sections. --- neercs/video/blurh.lolfx | 44 ++++++++++----------- neercs/video/blurv.lolfx | 45 +++++++++++----------- neercs/video/color.lolfx | 40 +++++++++---------- neercs/video/copper.lolfx | 37 +++++++++--------- neercs/video/glow.lolfx | 18 ++++----- neercs/video/noise.lolfx | 41 ++++++++++---------- neercs/video/postfx.lolfx | 75 ++++++++++++++++++------------------ neercs/video/remanency.lolfx | 19 ++++----- neercs/video/simple.lolfx | 13 ++++--- neercs/video/text.lolfx | 4 +- 10 files changed, 171 insertions(+), 165 deletions(-) diff --git a/neercs/video/blurh.lolfx b/neercs/video/blurh.lolfx index 221207f..6208419 100644 --- a/neercs/video/blurh.lolfx +++ b/neercs/video/blurh.lolfx @@ -1,14 +1,14 @@ --- GLSL.Vert -- +[vert.glsl] #version 120 void main() - { - gl_Position=gl_Vertex; - gl_TexCoord[0]=gl_MultiTexCoord0; - } +{ + gl_Position = gl_Vertex; + gl_TexCoord[0] = gl_MultiTexCoord0; +} --- GLSL.Frag -- +[frag.glsl] #version 120 @@ -16,19 +16,19 @@ uniform sampler2D texture; uniform vec2 radius; void main(void) - { - vec4 total=vec4(0.0); - vec2 p=gl_TexCoord[0].xy; - float mask=2.0-p.x*(6.0-p.x*6.0)*p.y*(6.0-p.y*6.0); - float b=radius.x+radius.y*mask; - total+=texture2D(texture,vec2(p.x-b*4.0,p.y))*0.04; - total+=texture2D(texture,vec2(p.x-b*3.0,p.y))*0.08; - total+=texture2D(texture,vec2(p.x-b*2.0,p.y))*0.12; - total+=texture2D(texture,vec2(p.x-b ,p.y))*0.16; - total+=texture2D(texture,vec2(p.x ,p.y))*0.20; - total+=texture2D(texture,vec2(p.x+b ,p.y))*0.16; - total+=texture2D(texture,vec2(p.x+b*2.0,p.y))*0.12; - total+=texture2D(texture,vec2(p.x+b*3.0,p.y))*0.08; - total+=texture2D(texture,vec2(p.x+b*4.0,p.y))*0.04; - gl_FragColor=total; - } \ No newline at end of file +{ + vec4 total = vec4(0.0); + vec2 p = gl_TexCoord[0].xy; + float mask = 2.0-p.x*(6.0-p.x*6.0)*p.y*(6.0-p.y*6.0); + float b = radius.x+radius.y*mask; + total += texture2D(texture,vec2(p.x-b*4.0,p.y))*0.04; + total += texture2D(texture,vec2(p.x-b*3.0,p.y))*0.08; + total += texture2D(texture,vec2(p.x-b*2.0,p.y))*0.12; + total += texture2D(texture,vec2(p.x-b ,p.y))*0.16; + total += texture2D(texture,vec2(p.x ,p.y))*0.20; + total += texture2D(texture,vec2(p.x+b ,p.y))*0.16; + total += texture2D(texture,vec2(p.x+b*2.0,p.y))*0.12; + total += texture2D(texture,vec2(p.x+b*3.0,p.y))*0.08; + total += texture2D(texture,vec2(p.x+b*4.0,p.y))*0.04; + gl_FragColor = total; +} diff --git a/neercs/video/blurv.lolfx b/neercs/video/blurv.lolfx index 6605e2c..f07338a 100644 --- a/neercs/video/blurv.lolfx +++ b/neercs/video/blurv.lolfx @@ -1,14 +1,14 @@ --- GLSL.Vert -- +[vert.glsl] #version 120 void main() - { - gl_Position=gl_Vertex; - gl_TexCoord[0]=gl_MultiTexCoord0; - } +{ + gl_Position = gl_Vertex; + gl_TexCoord[0] = gl_MultiTexCoord0; +} --- GLSL.Frag -- +[frag.glsl] #version 120 @@ -16,19 +16,20 @@ uniform sampler2D texture; uniform vec2 radius; void main(void) - { - vec4 total=vec4(0.0); - vec2 p=gl_TexCoord[0].xy; - float mask=2.0-p.x*(6.0-p.x*6.0)*p.y*(6.0-p.y*6.0); - float b=radius.x+radius.y*mask; - total+=texture2D(texture,vec2(p.x,p.y-b*4.0))*0.04; - total+=texture2D(texture,vec2(p.x,p.y-b*3.0))*0.08; - total+=texture2D(texture,vec2(p.x,p.y-b*2.0))*0.12; - total+=texture2D(texture,vec2(p.x,p.y-b ))*0.16; - total+=texture2D(texture,vec2(p.x,p.y ))*0.20; - total+=texture2D(texture,vec2(p.x,p.y+b ))*0.16; - total+=texture2D(texture,vec2(p.x,p.y+b*2.0))*0.12; - total+=texture2D(texture,vec2(p.x,p.y+b*3.0))*0.08; - total+=texture2D(texture,vec2(p.x,p.y+b*4.0))*0.04; - gl_FragColor=total; - } \ No newline at end of file +{ + vec4 total = vec4(0.0); + vec2 p = gl_TexCoord[0].xy; + float mask = 2.0-p.x*(6.0-p.x*6.0)*p.y*(6.0-p.y*6.0); + float b = radius.x+radius.y*mask; + total += texture2D(texture,vec2(p.x,p.y-b*4.0))*0.04; + total += texture2D(texture,vec2(p.x,p.y-b*3.0))*0.08; + total += texture2D(texture,vec2(p.x,p.y-b*2.0))*0.12; + total += texture2D(texture,vec2(p.x,p.y-b ))*0.16; + total += texture2D(texture,vec2(p.x,p.y ))*0.20; + total += texture2D(texture,vec2(p.x,p.y+b ))*0.16; + total += texture2D(texture,vec2(p.x,p.y+b*2.0))*0.12; + total += texture2D(texture,vec2(p.x,p.y+b*3.0))*0.08; + total += texture2D(texture,vec2(p.x,p.y+b*4.0))*0.04; + gl_FragColor = total; +} + diff --git a/neercs/video/color.lolfx b/neercs/video/color.lolfx index 441c9a9..737b794 100644 --- a/neercs/video/color.lolfx +++ b/neercs/video/color.lolfx @@ -1,14 +1,14 @@ --- GLSL.Vert -- +[vert.glsl] #version 120 void main() - { - gl_Position=gl_Vertex; - gl_TexCoord[0]=gl_MultiTexCoord0; - } +{ + gl_Position = gl_Vertex; + gl_TexCoord[0] = gl_MultiTexCoord0; +} --- GLSL.Frag -- +[frag.glsl] #version 120 @@ -19,17 +19,17 @@ uniform vec4 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.w); // grayscale - c*=filter; // filter - c+=color.z*0.1; // level - c*=color.x; // brightness - c=0.5+(c-0.5)*color.y; // contrast - c+=flash; // flash - - gl_FragColor=vec4(c,1.0); - } \ No newline at end of file +{ + 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.w); // grayscale + c *= filter; // filter + c += color.z*0.1; // level + c *= color.x; // brightness + c = 0.5+(c-0.5)*color.y; // contrast + c += flash; // flash + + gl_FragColor = vec4(c,1.0); +} diff --git a/neercs/video/copper.lolfx b/neercs/video/copper.lolfx index 9a7ac76..2021666 100644 --- a/neercs/video/copper.lolfx +++ b/neercs/video/copper.lolfx @@ -1,14 +1,14 @@ --- GLSL.Vert -- +[vert.glsl] #version 120 void main() - { - gl_Position=gl_Vertex; - gl_TexCoord[0]=gl_MultiTexCoord0; - } +{ + gl_Position = gl_Vertex; + gl_TexCoord[0] = gl_MultiTexCoord0; +} --- GLSL.Frag -- +[frag.glsl] #version 120 @@ -18,20 +18,21 @@ uniform float time; uniform vec4 copper; void main(void) - { - vec2 p=gl_TexCoord[0].xy; - vec3 source=texture2D(texture,p).xyz; +{ + vec2 p = gl_TexCoord[0].xy; + vec3 source = texture2D(texture,p).xyz; - vec3 color=vec3(0.5); + vec3 color = vec3(0.5); - color.x+=0.5*cos(p.y*float(screen_size.y/copper.z)+time*2.0); - color.z+=0.5*sin(p.y*float(screen_size.y/copper.z)+time*2.0); + color.x += 0.5*cos(p.y*float(screen_size.y/copper.z)+time*2.0); + color.z += 0.5*sin(p.y*float(screen_size.y/copper.z)+time*2.0); - color*=copper.x+copper.y*cos(p.y*float(screen_size.x/copper.w)-time*2.0); + color *= copper.x+copper.y*cos(p.y*float(screen_size.x/copper.w)-time*2.0); - color.x=float(int(color.x*8.0)*32)/256.0; - color.y=float(int(color.y*8.0)*32)/256.0; - color.z=float(int(color.z*8.0)*32)/256.0; + color.x = float(int(color.x*8.0)*32)/256.0; + color.y = float(int(color.y*8.0)*32)/256.0; + color.z = float(int(color.z*8.0)*32)/256.0; + + gl_FragColor = vec4((color==1.0)?color:source,1.0); +} - gl_FragColor=vec4((color==1.0)?color:source,1.0); - } diff --git a/neercs/video/glow.lolfx b/neercs/video/glow.lolfx index 6bcd1b3..8540b91 100644 --- a/neercs/video/glow.lolfx +++ b/neercs/video/glow.lolfx @@ -1,14 +1,14 @@ --- GLSL.Vert -- +[vert.glsl] #version 120 void main() - { - gl_Position=gl_Vertex; - gl_TexCoord[0]=gl_MultiTexCoord0; - } +{ + gl_Position = gl_Vertex; + gl_TexCoord[0] = gl_MultiTexCoord0; +} --- GLSL.Frag -- +[frag.glsl] #version 120 @@ -17,6 +17,6 @@ uniform sampler2D source; uniform vec2 mix; void main(void) - { - gl_FragColor=texture2D(source,gl_TexCoord[0].xy)*mix.x+texture2D(glow,gl_TexCoord[0].xy)*mix.y; - } \ No newline at end of file +{ + gl_FragColor = texture2D(source,gl_TexCoord[0].xy)*mix.x+texture2D(glow,gl_TexCoord[0].xy)*mix.y; +} diff --git a/neercs/video/noise.lolfx b/neercs/video/noise.lolfx index 5d8d1b3..e3ec7db 100644 --- a/neercs/video/noise.lolfx +++ b/neercs/video/noise.lolfx @@ -1,14 +1,14 @@ --- GLSL.Vert -- +[vert.glsl] #version 120 void main() - { - gl_Position=gl_Vertex; - gl_TexCoord[0]=gl_MultiTexCoord0; - } +{ + gl_Position = gl_Vertex; + gl_TexCoord[0] = gl_MultiTexCoord0; +} --- GLSL.Frag -- +[frag.glsl] #version 120 @@ -20,20 +20,21 @@ uniform float noise; uniform vec3 retrace; float rand(in vec2 p,in float t,in float v) - { +{ return fract(sin(dot(p+mod(t,2.0),vec2(12.9898,78.2333)))*v); - } +} void main(void) - { - vec2 p=gl_FragCoord.xy/screen_size.xy; - - float r1=rand(p,time,43758.5453); - 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*0.01*mod(p.y*retrace.y+time*retrace.z,1.0); // retrace - gl_FragColor=vec4(c,1.0); - } \ No newline at end of file +{ + vec2 p = gl_FragCoord.xy/screen_size.xy; + + float r1 = rand(p,time,43758.5453); + 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*0.01*mod(p.y*retrace.y+time*retrace.z,1.0); // retrace + gl_FragColor = vec4(c,1.0); +} + diff --git a/neercs/video/postfx.lolfx b/neercs/video/postfx.lolfx index 623707b..de31fc2 100644 --- a/neercs/video/postfx.lolfx +++ b/neercs/video/postfx.lolfx @@ -1,14 +1,14 @@ --- GLSL.Vert -- +[vert.glsl] #version 120 void main() - { - gl_Position=gl_Vertex; - gl_TexCoord[0]=gl_MultiTexCoord0; - } +{ + gl_Position = gl_Vertex; + gl_TexCoord[0] = gl_MultiTexCoord0; +} --- GLSL.Frag -- +[frag.glsl] #version 120 @@ -29,47 +29,48 @@ uniform float sync; uniform float beat; vec2 screen(in vec2 p,in float radius) - { - float d=deform.x+sync*0.0625+beat*0.0375; +{ + float d = deform.x+sync*0.0625+beat*0.0375; 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) - { +{ return texture2D(tex,clamp(p,-1.0,0.0)).xyz; - } +} float letterbox(in vec2 p,in float w,in float radius,in float smooth) - { +{ return 1.0-smoothstep(smooth,1.0,length(max(abs(p*w+w/2.0)-vec2(radius),0.0))+radius); - } +} 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 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); +{ + 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 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); - vec3 source=get_color(texture,z); - vec3 g1=get_color(texture,z1-ghost1.xy*0.01); - vec3 g2=get_color(texture,z2-ghost2.xy*0.01); + vec3 source = get_color(texture,z); + vec3 g1 = get_color(texture,z1-ghost1.xy*0.01); + vec3 g2 = get_color(texture,z2-ghost2.xy*0.01); - vec3 c=source+g1*ghost1.w+g2*ghost2.w; // mix + vec3 c = source+g1*ghost1.w+g2*ghost2.w; // mix - 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 + 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 *= 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 *= mix(1.0,mask,vignetting); // vignetting + c *= letterbox(z,corner.x+2.0,corner.y,corner.z); // corner + gl_FragColor = vec4(c,1.0); +} - 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*=mix(1.0,mask,vignetting); // vignetting - c*=letterbox(z,corner.x+2.0,corner.y,corner.z); // corner - gl_FragColor=vec4(c,1.0); - } \ No newline at end of file diff --git a/neercs/video/remanency.lolfx b/neercs/video/remanency.lolfx index 53c170a..38e6d37 100644 --- a/neercs/video/remanency.lolfx +++ b/neercs/video/remanency.lolfx @@ -1,14 +1,14 @@ --- GLSL.Vert -- +[vert.glsl] #version 120 void main() - { - gl_Position=gl_Vertex; - gl_TexCoord[0]=gl_MultiTexCoord0; - } +{ + gl_Position = gl_Vertex; + gl_TexCoord[0] = gl_MultiTexCoord0; +} --- GLSL.Frag -- +[frag.glsl] #version 120 @@ -17,6 +17,7 @@ uniform sampler2D buffer; uniform vec2 mix; void main(void) - { - gl_FragColor=texture2D(source,gl_TexCoord[0].xy)*mix.x+texture2D(buffer,gl_TexCoord[0].xy)*mix.y; - } \ No newline at end of file +{ + gl_FragColor = texture2D(source,gl_TexCoord[0].xy)*mix.x+texture2D(buffer,gl_TexCoord[0].xy)*mix.y; +} + diff --git a/neercs/video/simple.lolfx b/neercs/video/simple.lolfx index d1561e3..5a78403 100644 --- a/neercs/video/simple.lolfx +++ b/neercs/video/simple.lolfx @@ -1,20 +1,21 @@ --- GLSL.Vert -- +[vert.glsl] #version 120 void main() - { +{ gl_Position = gl_Vertex; gl_TexCoord[0] = gl_MultiTexCoord0; - } +} --- GLSL.Frag -- +[frag.glsl] #version 120 uniform sampler2D texture; void main(void) - { +{ gl_FragColor = texture2D(texture, gl_TexCoord[0].xy); - } \ No newline at end of file +} + diff --git a/neercs/video/text.lolfx b/neercs/video/text.lolfx index 62b354a..077d82a 100644 --- a/neercs/video/text.lolfx +++ b/neercs/video/text.lolfx @@ -1,4 +1,4 @@ --- GLSL.Vert -- +[vert.glsl] #version 130 @@ -61,7 +61,7 @@ void main() gl_Position = in_Transform * vec4(in_Position, 0.0, 1.0); } --- GLSL.Frag -- +[frag.glsl] #version 130