Changeset 1736
 Timestamp:
 Aug 14, 2012, 2:43:49 AM (10 years ago)
 Location:
 trunk/tools/neercs/video
 Files:

 3 edited
Legend:
 Unmodified
 Added
 Removed

trunk/tools/neercs/video/postfx.lolfx
r1694 r1736 16 16 uniform vec2 screen_size; 17 17 uniform float time; 18 uniform float deform; 18 uniform vec2 deform; 19 uniform vec4 ghost; 19 20 uniform vec3 filter; 20 21 uniform vec3 color; … … 23 24 uniform float noise; 24 25 uniform float aberration; 25 uniform bool moire;26 26 uniform vec4 moire_h; 27 27 uniform vec4 moire_v; 28 uniform bool scanline;29 28 uniform vec4 scanline_h; 30 29 uniform vec4 scanline_v; 30 uniform vec2 corner; 31 31 uniform float flash; 32 32 uniform float sync; … … 34 34 const float PI=3.14159265358979323846; 35 35 36 vec2 zoom(in vec2 p,in float radius)36 vec2 screen(in vec2 p,in float radius) 37 37 { 38 float d=deform+sync*0.0625; 39 float zoom=1.5(radius*cos(p.x*d)+radius*cos(p.y*d)); 40 return p*zoom0.5; 38 float d=deform.x+sync*0.0625; 39 return p*(1.5(radius*cos(p.x*d)+radius*cos(p.y*d)))0.5; 41 40 } 42 41 … … 53 52 float letterbox(in vec2 p,in float radius,in float smooth) 54 53 { 55 return 1.0smoothstep(smooth,1.0,length(max(abs(p*2.0+1.0) +vec2(radius),0.0))radius);54 return 1.0smoothstep(smooth,1.0,length(max(abs(p*2.0+1.0)vec2(radius),0.0))+radius); 56 55 } 57 56 … … 61 60 vec2 p=1.0+2.0*gl_FragCoord.xy/screen_size.xy; 62 61 p.y+=0.025*sync; 63 vec2 z = zoom(p,0.5250);64 vec2 z1= zoom(p,0.5225);65 vec2 z2= zoom(p,0.5275);62 vec2 z =screen(p,deform.y); 63 vec2 z1=screen(p,deform.yghost.x*0.1); 64 vec2 z2=screen(p,deform.y+ghost.z*0.1); 66 65 float mask=q.x*(6.0q.x*6.0)*q.y*(6.0q.y*6.0); 67 66 … … 80 79 ca.z=get_color(texture,vec2(z.x+o.x+v,z.y+o.y)).z; 81 80 82 vec3 c=source +glass1*glass1*0.25+glass2*glass2*0.25;81 vec3 c=sourceglass1*glass1*ghost.y+glass2*glass2*ghost.w; 83 82 84 83 float a=(c.x+c.y+c.z)/3.0; … … 93 92 c=retrace.x*mod(z.y*retrace.y+time*retrace.z,1.0); // retrace 94 93 c=(vec3(rnd.xrnd.y))*noise; // noise 95 if(moire) 96 { 97 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 98 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 99 } 100 else 101 { 102 c*=(moire_h.x+moire_v.x)*0.5; 103 } 104 if(scanline) 105 { 106 c*=scanline_h.x+scanline_h.y*cos(z.y*float(screen_size.y*scanline_h.z+scanline_h.w)); // scanline h 107 c*=scanline_v.x+scanline_v.y*cos(z.x*float(screen_size.x*scanline_v.z+scanline_v.w)); // scanline v 108 } 109 else 110 { 111 c*=(scanline_h.x+scanline_v.x)*0.5; 112 } 94 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 95 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 96 c*=scanline_h.x+scanline_h.y*cos(z.y*float(screen_size.y*scanline_h.z+scanline_h.w)); // scanline h 97 c*=scanline_v.x+scanline_v.y*cos(z.x*float(screen_size.x*scanline_v.z+scanline_v.w)); // scanline v 113 98 c*=mask; // vignetting 114 c*=letterbox(z, 0.75,0.95); // letnoiseterbox99 c*=letterbox(z,corner.x,corner.y); // letterbox 115 100 gl_FragColor=vec4(c,1.0); 116 101 } 
trunk/tools/neercs/video/render.cpp
r1711 r1736 96 96 bool setup_switch=false; // switch [option/item] 97 97 int setup_option=0; // selected option 98 int setup_option_n= 7; // option number98 int setup_option_n=9; // option number 99 99 int setup_item=0; // selected item 100 100 int setup_item_n=8; // item number … … 131 131 "", 132 132 "", 133 "screen", 134 "enable", 135 "deform ratio", 136 "zoom base", 137 "zoom variable", 138 "corner radius", 139 "corner blur", 140 "", 141 "", 133 142 "color", 134 "postfx enable",135 143 "filter red", 136 144 "filter green", … … 140 148 "grayscale", 141 149 "", 142 "modifier",143 "deform ratio",144 "retrace strength",145 "retrace length",146 "retrace speed",147 "",148 "",149 "",150 150 "", 151 151 "noise", … … 154 154 "noise", 155 155 "aberration", 156 "retrace strength", 157 "retrace length", 158 "retrace speed", 159 "", 160 "ghost", 161 "back distance", 162 "back strength", 163 "front distance", 164 "front strength", 156 165 "", 157 166 "", … … 182 191 vec2 buffer(0.7f,0.3f); // [new frame mix,old frame mix] 183 192 vec2 remanency(0.3f,0.7f); // remanency [source mix,buffer mix] 184 vec2 glow_mix(0. 5f,0.5f); // glow mix [source mix,glow mix]193 vec2 glow_mix(0.6f,0.4f); // glow mix [source mix,glow mix] 185 194 vec2 glow_large(2.0f,2.0f); // large glow radius [center,corner] 186 195 vec2 glow_small(1.0f,1.0f); // small glow radius [center,corner] … … 188 197 //vec3 radial(2.0f,0.8f,0); // radial [mix,strength,color mode] 189 198 //// [IDEAS] http://www.youtube.com/watch?v=d1qEP2vMeI 190 float postfx_deform = 0.7f; // deformation ratio 191 vec3 postfx_filter(0.8f,0.9f,0.4f);// color filter [red,green,blue] 192 vec3 postfx_color(1.8f,1.8f,0.5f); // color modifier [brightness,contrast,grayscale] 199 vec2 postfx_deform(0.7f,0.54f); // deformation [ratio,zoom] 200 vec3 postfx_filter(0.8f,0.9f,0.4f); // color filter [red,green,blue] 201 vec3 postfx_color(1.8f,1.5f,0.5f); // color modifier [brightness,contrast,grayscale] 202 vec2 postfx_corner(0.75f,0.95f); // corner [radius,blur] 193 203 vec3 postfx_retrace(0.05f,2.0f,4.0f); // retrace [strength,length,speed] 194 204 vec2 postfx_offset(3.0f,3.0f); // random line [horizontal,vertical] 195 205 float postfx_noise = 0.15f; // noise 196 206 float postfx_aberration = 3.0f; // chromatic aberration 197 bool postfx_moire = true; // moire 198 vec4 postfx_moire_h(0.75f,0.25f,0.0f,1.0f); 199 vec4 postfx_moire_v(0.75f,0.25f,1.0f,1.5f); 200 bool postfx_scanline = true; // scanline 201 vec4 postfx_scanline_h(0.75f, 0.25f,0.0f,2.0f);// vertical scanline [base,variable,repeat x,repeat y] 202 vec4 postfx_scanline_v(0.75f,0.25f,2.0f,0.0f);// horizontal scanline [base,variable,repeat x,repeat y] 207 vec4 postfx_ghost(0.1f,0.25f,0.1f,0.5f); // ghost picture [distance,strength,distance,strength] 208 vec4 postfx_moire_h(0.75f,0.25f,0.0f,1.0f); // vertical moire [base,variable,repeat x,repeat y] 209 vec4 postfx_moire_v(0.75f,0.25f,1.0f,1.5f); // horizontal moire [base,variable,repeat x,repeat y] 210 vec4 postfx_scanline_h(0.75f, 0.25f,0.0f,2.0f); // vertical scanline [base,variable,repeat x,repeat y] 211 vec4 postfx_scanline_v(0.75f,0.25f,2.0f,0.0f); // horizontal scanline [base,variable,repeat x,repeat y] 203 212 //// 204 213 vec4 setup_var[]={ … … 213 222 vec4(0), 214 223 vec4(0), /* glow */ 215 vec4(0, 1, 1, 0),224 vec4(0, 1, 1, 1), 216 225 vec4(0.0f, 1.0f, 0.1f, glow_mix.x), 217 226 vec4(0.0f, 1.0f, 0.1f, glow_mix.y), … … 222 231 vec4(0), 223 232 vec4(0), /* blur */ 224 vec4(0, 1, 1, 0),233 vec4(0, 1, 1, 1), 225 234 vec4(0.0f, 2.0f, 0.1f, blur.x), 226 235 vec4(0.0f, 2.0f, 0.1f, blur.y), … … 230 239 vec4(0), 231 240 vec4(0), 241 vec4(0), /* screen */ 242 vec4(0, 1, 1, 1), 243 vec4(0.0f, 1.0f, 0.05f, postfx_deform.x), 244 vec4(0.5f, 0.7f, 0.01f, postfx_deform.y), 245 vec4(0.0f, 1.0f, 0.05f, postfx_corner.x), 246 vec4(0.0f, 1.0f, 0.05f, postfx_corner.y), 247 vec4(0), 248 vec4(0), 249 vec4(0), 232 250 vec4(0), /* color */ 233 vec4(0, 1, 1, 0),234 251 vec4(0.0f, 1.0f, 0.1f, postfx_filter.x), 235 252 vec4(0.0f, 1.0f, 0.1f, postfx_filter.y), … … 239 256 vec4(0.0f, 1.5f, 0.1f, postfx_color.z), 240 257 vec4(0), 241 vec4(0), /* modifier */242 vec4(0.0f, 1.0f, 0.05f, postfx_deform),243 vec4(0.0f, 1.0f, 0.05f, postfx_retrace.x),244 vec4(0.0f, 8.0f, 1.0f, postfx_retrace.y),245 vec4(0.0f, 8.0f, 1.0f, postfx_retrace.z),246 vec4(0),247 vec4(0),248 vec4(0),249 258 vec4(0), 250 259 vec4(0), /* noise */ … … 253 262 vec4(0.0f, 1.0f, 0.05f, postfx_noise), 254 263 vec4(0.0f, 5.0f, 0.5f, postfx_aberration), 255 vec4(0), 256 vec4(0), 257 vec4(0), 258 vec4(0), 264 vec4(0.0f, 0.2f, 0.01f, postfx_retrace.x), 265 vec4(0.0f, 8.0f, 0.5f, postfx_retrace.y), 266 vec4(0.0f, 4.0f, 0.25f, postfx_retrace.z), 267 vec4(0), 268 vec4(0), /* ghost */ 269 vec4(0.0f, 0.2f, 0.01f, postfx_ghost.x), 270 vec4(0.0f, 1.0f, 0.05f, postfx_ghost.y), 271 vec4(0.0f, 0.2f, 0.01f, postfx_ghost.z), 272 vec4(0.0f, 1.0f, 0.05f, postfx_ghost.w), 273 vec4(0), 274 vec4(0), 275 vec4(0), 276 vec4(0), 277 vec4(0), /* moire */ 278 vec4(0.5f, 1.0f, 0.05f, postfx_moire_h.x), 279 vec4(0.5f, 0.5f, 0.05f, postfx_moire_h.y), 280 vec4(0.0f, 4.0f, 0.5f, postfx_moire_h.z), 281 vec4(0.0f, 4.0f, 0.5f, postfx_moire_h.w), 282 vec4(0.5f, 1.0f, 0.1f, postfx_moire_v.x), 283 vec4(0.5f, 0.5f, 0.1f, postfx_moire_v.y), 284 vec4(0.0f, 4.0f, 0.5f, postfx_moire_v.z), 285 vec4(0.0f, 4.0f, 0.5f, postfx_moire_v.w), 286 vec4(0), /* scanline */ 287 vec4(0.5f, 1.0f, 0.05f, postfx_scanline_h.x), 288 vec4(0.5f, 0.5f, 0.05f, postfx_scanline_h.y), 289 vec4(0.0f, 4.0f, 0.5f, postfx_scanline_h.z), 290 vec4(0.0f, 4.0f, 0.5f, postfx_scanline_h.w), 291 vec4(0.5f, 1.0f, 0.1f, postfx_scanline_v.x), 292 vec4(0.5f, 0.5f, 0.1f, postfx_scanline_v.y), 293 vec4(0.0f, 4.0f, 0.5f, postfx_scanline_v.z), 294 vec4(0.0f, 4.0f, 0.5f, postfx_scanline_v.w), 259 295 vec4(0) 260 296 }; … … 276 312 k += 6; 277 313 m_shader_postfx = (setup_var[k].w == 1) ? true : false; k++; 314 postfx_deform = vec2(setup_var[k].w, setup_var[k + 1].w); k += 2; 315 postfx_corner = vec2(setup_var[k].w, setup_var[k + 1].w); k += 2; 316 k += 4; 278 317 postfx_filter = vec3(setup_var[k].w, setup_var[k + 1].w, setup_var[k + 2].w); k += 3; 279 318 postfx_color = vec3(setup_var[k].w, setup_var[k + 1].w, setup_var[k + 2].w); k += 3; 280 k += 2; 281 postfx_deform = setup_var[k].w; k++; 282 postfx_retrace = vec3(setup_var[k].w, setup_var[k + 1].w, setup_var[k + 2].w); k += 3; 283 k += 5; 319 k += 3; 284 320 postfx_offset = vec2(setup_var[k].w, setup_var[k + 1].w); k += 2; 285 321 postfx_noise = setup_var[k].w; k++; 286 322 postfx_aberration = setup_var[k].w; k++; 323 postfx_retrace = vec3(setup_var[k].w, setup_var[k + 1].w, setup_var[k + 2].w); k += 3; 324 k += 2; 325 postfx_ghost = vec4(setup_var[k].w, setup_var[k + 1].w, setup_var[k + 2].w, setup_var[k + 3].w); k += 4; 287 326 k += 5; 327 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; 328 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; 329 k++; 330 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; 331 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; 288 332 } 289 333 … … 314 358 shader_postfx_time, 315 359 shader_postfx_deform, 360 shader_postfx_ghost, 316 361 shader_postfx_filter, 317 362 shader_postfx_color, 363 shader_postfx_corner, 318 364 shader_postfx_retrace, 319 365 shader_postfx_offset, 320 366 shader_postfx_noise, 321 367 shader_postfx_aberration, 322 shader_postfx_moire,323 368 shader_postfx_moire_h, 324 369 shader_postfx_moire_v, 325 shader_postfx_scanline,326 370 shader_postfx_scanline_h, 327 371 shader_postfx_scanline_v, … … 409 453 shader_postfx_time = shader_postfx>GetUniformLocation("time"); 410 454 shader_postfx_deform = shader_postfx>GetUniformLocation("deform"); 455 shader_postfx_ghost = shader_postfx>GetUniformLocation("ghost"); 411 456 shader_postfx_filter = shader_postfx>GetUniformLocation("filter"); 412 457 shader_postfx_color = shader_postfx>GetUniformLocation("color"); 458 shader_postfx_corner = shader_postfx>GetUniformLocation("corner"); 413 459 shader_postfx_retrace = shader_postfx>GetUniformLocation("retrace"); 414 460 shader_postfx_offset = shader_postfx>GetUniformLocation("offset"); 415 461 shader_postfx_noise = shader_postfx>GetUniformLocation("noise"); 416 462 shader_postfx_aberration = shader_postfx>GetUniformLocation("aberration"); 417 shader_postfx_moire = shader_postfx>GetUniformLocation("moire");418 463 shader_postfx_moire_h = shader_postfx>GetUniformLocation("moire_h"); 419 464 shader_postfx_moire_v = shader_postfx>GetUniformLocation("moire_v"); 420 shader_postfx_scanline = shader_postfx>GetUniformLocation("scanline");421 465 shader_postfx_scanline_h = shader_postfx>GetUniformLocation("scanline_h"); 422 466 shader_postfx_scanline_v = shader_postfx>GetUniformLocation("scanline_v"); … … 454 498 m_shader(true), 455 499 m_shader_remanency(true), 456 m_shader_glow(false), 457 m_shader_blur(false), 458 m_shader_postfx(false), 459 m_border(false) 500 m_shader_glow(true), 501 m_shader_blur(true), 502 m_shader_postfx(true) 460 503 { 461 504 text_render = new TextRender(m_caca, font_size); … … 675 718 /* display variable */ 676 719 int y = setup_p.y + setup_size.y; 720 setup_item_key = setup_option * (setup_item_n + 1) + 1 + setup_item; 677 721 caca_set_color_argb(m_caca, setup_color.y, setup_color.x); 678 722 caca_draw_line(m_caca, setup_p.x, y, setup_p.x + setup_size.x, y,' '); 679 if (setup_switch) 680 { 681 setup_item_key = setup_option * (setup_item_n + 1) + 1 + setup_item; 723 if (setup_switch && setup_text[setup_item_key] != "") 724 { 682 725 int w = setup_size.x  3  4; 683 caca_printf(m_caca, setup_p.x + setup_size.x  4, y, "%4.2f", setup_var[setup_item_key].w); 684 caca_draw_line(m_caca, setup_p.x + 1, y, setup_p.x + 1 + w, y,'.'); 685 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'); 726 int bar_w = (w / (setup_var[setup_item_key].y  setup_var[setup_item_key].x) * setup_var[setup_item_key].w); 727 if ((setup_var[setup_item_key].y  setup_var[setup_item_key].x) / setup_var[setup_item_key].z > 2) 728 { 729 caca_printf(m_caca, setup_p.x + setup_size.x  4, y, "%4.2f", setup_var[setup_item_key].w); 730 caca_draw_line(m_caca, setup_p.x + 1, y, setup_p.x + 1 + w, y,'.'); 731 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'); 732 } 733 else 734 { 735 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"); 736 } 686 737 } 687 738 } … … 698 749 699 750 if (m_shader) 700 {701 751 fbo_back>Bind(); 702 }703 752 704 753 glViewport(0, 0, screen_size.x, screen_size.y); … … 723 772 glLoadMatrixf(&m[0][0]); 724 773 glMatrixMode(GL_MODELVIEW); 725 // draw border726 if (m_border)727 {728 glDisable(GL_TEXTURE_2D);729 glDisable(GL_BLEND);730 glColor3f(1.0f, 1.0f, 1.0f);731 rectangle(border.x  ratio_2d.x, border.y  ratio_2d.y, canvas_size.x + ratio_2d.x * 2, ratio_2d.y);732 rectangle(border.x  ratio_2d.x, border.y, ratio_2d.x, canvas_size.y);733 rectangle(border.x + canvas_size.x, border.y, ratio_2d.x, canvas_size.y);734 rectangle(border.x  ratio_2d.x, border.y + canvas_size.y, canvas_size.x + ratio_2d.x * 2, ratio_2d.y);735 glEnable(GL_BLEND);736 }737 774 } 738 775 … … 862 899 shader_postfx>SetUniform(shader_postfx_time, fx_angle); 863 900 shader_postfx>SetUniform(shader_postfx_deform, postfx_deform); 901 shader_postfx>SetUniform(shader_postfx_ghost, postfx_ghost); 864 902 shader_postfx>SetUniform(shader_postfx_filter, postfx_filter); 865 903 shader_postfx>SetUniform(shader_postfx_color, postfx_color); 904 shader_postfx>SetUniform(shader_postfx_corner, postfx_corner); 866 905 shader_postfx>SetUniform(shader_postfx_retrace, postfx_retrace); 867 906 shader_postfx>SetUniform(shader_postfx_offset, postfx_offset); 868 907 shader_postfx>SetUniform(shader_postfx_noise, postfx_noise); 869 908 shader_postfx>SetUniform(shader_postfx_aberration, postfx_aberration); 870 shader_postfx>SetUniform(shader_postfx_moire, postfx_moire);871 909 shader_postfx>SetUniform(shader_postfx_moire_h, postfx_moire_h); 872 910 shader_postfx>SetUniform(shader_postfx_moire_v, postfx_moire_v); 873 shader_postfx>SetUniform(shader_postfx_scanline, postfx_scanline);874 911 shader_postfx>SetUniform(shader_postfx_scanline_h, postfx_scanline_h); 875 912 shader_postfx>SetUniform(shader_postfx_scanline_v, postfx_scanline_v); 
trunk/tools/neercs/video/render.h
r1707 r1736 38 38 bool m_shader_glow; 39 39 bool m_shader_postfx; 40 bool m_border;41 40 }; 42 41
Note: See TracChangeset
for help on using the changeset viewer.