From 789ada7c2b4310906d893f4bb2522bc7e415d8a8 Mon Sep 17 00:00:00 2001 From: rez Date: Tue, 16 Oct 2012 00:25:47 +0000 Subject: [PATCH] neercs: added bending to mirror --- neercs/video/mirror.lolfx | 8 ++++---- neercs/video/postfx.lolfx | 23 ++++++++++++----------- neercs/video/render.cpp | 8 ++++---- 3 files changed, 20 insertions(+), 19 deletions(-) diff --git a/neercs/video/mirror.lolfx b/neercs/video/mirror.lolfx index 8972a8d..5c3093b 100644 --- a/neercs/video/mirror.lolfx +++ b/neercs/video/mirror.lolfx @@ -22,10 +22,10 @@ void main(void) vec3 s = texture2D(texture, p).xyz; vec3 c = vec3(0.0); - if(p.x < mirror.x) c = (texture2D(texture, vec2(mirror.x + (mirror.x - p.x) * mirror.w, p.y)).xyz) * (mirror.z / mirror.x * p.x); - if(p.x > 1.0 - mirror.x) c = (texture2D(texture, vec2(- mirror.x - (mirror.x + p.x) * mirror.w, p.y)).xyz) * (mirror.z / mirror.x * (1.0 - p.x)); - if(p.y < mirror.y) c = (texture2D(texture, vec2(p.x, mirror.y + (mirror.y - p.y) * mirror.w)).xyz) * (mirror.z / mirror.y * p.y); - if(p.y > 1.0 - mirror.y) c = (texture2D(texture, vec2(p.x, - mirror.y - (mirror.y + p.y) * mirror.w)).xyz) * (mirror.z / mirror.y * (1.0 - p.y)); + if(p.x < mirror.x) c += (texture2D(texture, vec2(mirror.x + (mirror.x - p.x) * mirror.w, p.y * (0.8 + 2.0 * p.x) + 0.1 - 1.0 * p.x)).xyz) * (mirror.z / mirror.x * p.x); + if(p.x > 1.0 - mirror.x) c += (texture2D(texture, vec2(- mirror.x - (mirror.x + p.x) * mirror.w, p.y * (0.8 + 2.0 * (1.0 - p.x)) + 0.1 - 1.0 * (1.0 - p.x))).xyz) * (mirror.z / mirror.x * (1.0 - p.x)); + if(p.y < mirror.y) c += (texture2D(texture, vec2(p.x * (0.8 + 2.0 * p.y) + 0.1 - 1.0 * p.y, mirror.y + (mirror.y - p.y) * mirror.w)).xyz) * (mirror.z / mirror.y * p.y); + if(p.y > 1.0 - mirror.y) c += (texture2D(texture, vec2(p.x * (0.8 + 2.0 * (1.0 - p.y)) + 0.1 - 1.0 * (1.0 - p.y), - mirror.y - (mirror.y + p.y) * mirror.w)).xyz) * (mirror.z / mirror.y * (1.0 - p.y)); gl_FragColor = vec4(s + c, 1.0); } \ No newline at end of file diff --git a/neercs/video/postfx.lolfx b/neercs/video/postfx.lolfx index 70a6168..d4d69f7 100644 --- a/neercs/video/postfx.lolfx +++ b/neercs/video/postfx.lolfx @@ -65,25 +65,26 @@ void main(void) vec3 ca2=get_color(texture,vec2(z.x+v,z.y)); c+=vec3(ca1.x,c.y,ca2.z); // chromatic aberration - vec3 c1=vec3(0.2,0.1,0.0); - vec3 c2=vec3(0.7,0.5,0.5); + vec3 c1=vec3(0.8,0.8,0.8); + vec3 c2=vec3(0.0,0.0,0.0); vec3 c3=vec3(1.0,1.0,1.0); - vec3 c4=vec3(0.0,0.5,0.7); - vec3 c5=vec3(0.0,0.1,0.2); + vec3 c4=vec3(0.8,0.8,0.8); + vec3 c5=vec3(0.0,0.0,0.0); vec3 r; - float k=z.y+1.0;//(p.y+1.0)/2.0; + float r_p=0.5; + float r_h=0.05; + float k=z.y+1.0; - if(k<=0.1) r=mix(c1,c2,k*(1/0.1)); - if(k>0.1&&k<0.2) r=mix(c2,c3,(k-0.1)*(1.0/0.1)); - if(k>0.2&&k<0.3) r=mix(c3,c4,(k-0.2)*(1/0.1)); - if(k>=0.3) r=mix(c4,c5,k*((k-0.3)/0.7)); - - c+=r*0.5; // reflection + if(k<=r_p-r_h) r=mix(c1,c2,k*(1/(r_p-r_h))); + if(k>r_p-r_h&&k<=r_p) r=mix(c2,c3,(k-(r_p-r_h))*(1/r_h)); + if(k>r_p&&k=r_p+r_h) r=mix(c4,c5,k*((k-(r_p+r_h))/(r_p-r_h))); 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+=r*0.05; // reflection 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); diff --git a/neercs/video/render.cpp b/neercs/video/render.cpp index 26a131a..0ef598a 100644 --- a/neercs/video/render.cpp +++ b/neercs/video/render.cpp @@ -94,7 +94,7 @@ float beat_speed = 2.0f; // speed /* common variable */ float value, angle, radius, scale, speed; /* shader variable */ -vec2 buffer(0.7f,0.3f); // [new frame mix,old frame mix] +vec2 buffer(0.2f,0.8f); // [new frame mix,old frame mix] vec2 remanence(0.6f,0.4f); // remanence [source mix,buffer mix] vec2 glow_mix(0.7f,0.3f); // glow mix [source mix,glow mix] vec2 glow_large(3.0f,0.0f); // large glow radius [center,corner] @@ -103,7 +103,7 @@ vec2 blur(0.5f,0.0f); // blur radius [center,corner] vec4 copper_copper(0.75f,0.25f,0.42f,4.0f); // copper [base,variable,repeat,color cycle] vec3 copper_mask_color(4.0f,4.0f,4.0f); // color [red,green,blue] vec3 color_filter(0.9f,0.95f,0.85f); // color filter [red,green,blue] -vec4 color_color(1.0f,1.25f,0.0f,0.35f); // color modifier [brightness,contrast,level,grayscale] +vec4 color_color(1.0f,1.25f,0.1f,0.4f); // color modifier [brightness,contrast,level,grayscale] vec2 noise_offset(1.0f,1.0f); // random line [horizontal,vertical] float noise_noise = 0.15f; // noise vec3 noise_retrace(1.0f,1.0f,0.5f); // retrace [strength,length,speed] @@ -117,8 +117,8 @@ vec4 postfx_moire_v(0.75f,-0.25f,1.0f,1.5f); // horizontal moire [base,variab vec4 postfx_scanline_h(1.0f,0.0f,0.0f,0.0f); // vertical scanline [base,variable,repeat,shift] vec4 postfx_scanline_v(0.75f,-0.25f,2.0f,0.0f); // horizontal scanline [base,variable,repeat,shift] vec3 postfx_corner(0.0f,0.8f,0.96f); // corner [width,radius,blur] -vec4 mirror(0.95f,0.9f,0.4f,3.0f); // mirror [width,height,strength,ratio] -vec4 radial(3.0f,0.9f,16,0.5f); // radial [distance,fade ratio,iteration,strength] +vec4 mirror(0.95f,0.9f,0.4f,4.0f); // mirror [width,height,strength,ratio] +vec4 radial(4.0f,0.9f,16,0.5f); // radial [distance,fade ratio,iteration,strength] /* text variable */ ivec2 ratio_2d(2,3); // 2d ratio ivec2 map_size(256,256); // texture map size