Changeset 1986


Ignore:
Timestamp:
Oct 8, 2012, 12:48:14 AM (5 years ago)
Author:
rez
Message:

neercs - adding mirror sides (left ok, right no yet)

Location:
trunk/tools/neercs/video
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/tools/neercs/video/mirror.lolfx

    r1978 r1986  
    2222    vec3 source = texture2D(texture, p).xyz;
    2323
    24     vec3 color = vec3(0.0,0.1,0.0);
     24    vec3 color = vec3(0.0);
     25    if(p.x < mirror.x) color = (texture2D(texture, vec2(mirror.x - (1.0 - mirror.x * mirror.w + p.x * mirror.w), p.y)).xyz) * (mirror.z / mirror.x * p.x);
     26    if(p.x > 1.0 - mirror.x) color = (texture2D(texture, vec2(mirror.x - (1.0 - mirror.x * mirror.w + p.x * mirror.w), p.y)).xyz) * (mirror.z / mirror.x * (1.0 - p.x));
    2527
    26     gl_FragColor = vec4(source+color, 1.0);
     28    gl_FragColor = vec4(source + color, 1.0);
    2729}
  • trunk/tools/neercs/video/render.cpp

    r1978 r1986  
    116116vec4 postfx_scanline_v(0.75f,-0.25f,2.0f,0.0f); // horizontal scanline [base,variable,repeat,shift]
    117117vec3 postfx_corner(0.0f,0.75f,0.95f);           // corner [width,radius,blur]
    118 vec4 mirror(0.0f,0.0f,0.0f,0.0f);               //
     118vec4 mirror(0.7f,0.7f,0.5f,4.0f);               // mirror [width,height,strength,ratio]
    119119/* text variable */
    120120ivec2 ratio_2d(2,3);            // 2d ratio
     
    124124ivec2 canvas_size(0,0);         // caca size
    125125/* window variable */
    126 ivec2 border = vec2(3,2) * ratio_2d * font_size; // border width
     126ivec2 border = vec2(2,1) * ratio_2d * font_size; // border width
    127127/* setup variable */
    128128bool setup_switch = false;      // switch [option/item]
     
    242242    "mirror",
    243243        "enable",
    244         "param 1",
    245         "param 2",
    246         "param 3",
    247         "param 4",
     244        "width",
     245        "height",
     246        "strength",
     247        "ratio",
    248248        "",
    249249        "",
     
    298298        vec4(0),
    299299    vec4(0), /* copper */
    300         vec4( 0, 1, 1, 1),
     300        vec4(0, 1, 1, 1),
    301301        vec4(0.0f, 1.0f, 0.05f, copper_copper.x),
    302302        vec4(0.0f, 1.0f, 0.05f, copper_copper.y),
     
    316316        vec4( 0.0f, 8.0f, 0.50f, postfx_aberration),
    317317    vec4(0), /* noise */
    318         vec4( 0, 1, 1, 1),
     318        vec4(0, 1, 1, 1),
    319319        vec4(0.0f, 4.0f, 0.50f, noise_offset.x),
    320320        vec4(0.0f, 4.0f, 0.50f, noise_offset.y),
     
    352352        vec4( 0.0f, 4.0f, 0.50f, postfx_scanline_v.w),
    353353    vec4(0), /* mirror */
    354         vec4( 0, 1, 1, 1),
    355         vec4( 0.0f, 1.0f, 0.1f, mirror.x),
    356         vec4( 0.0f, 1.0f, 0.1f, mirror.y),
    357         vec4( 0.0f, 1.0f, 0.1f, mirror.z),
    358         vec4( 0.0f, 1.0f, 0.1f, mirror.w),
     354        vec4(0, 1, 1, 1),
     355        vec4(0.0f, 2.0f, 0.05f, mirror.x),
     356        vec4(0.0f, 2.0f, 0.05f, mirror.y),
     357        vec4(0.0f, 1.0f, 0.05f, mirror.z),
     358        vec4(1.0f, 4.0f, 0.25f, mirror.w),
    359359        vec4(0),
    360360        vec4(0),
     
    489489              shader_mirror_mirror;
    490490
    491 FrameBuffer *fbo_back, *fbo_front, *fbo_buffer;
    492 FrameBuffer *fbo_blur_h, *fbo_blur_v, *fbo_tmp;
     491FrameBuffer *fbo_back, *fbo_front, *fbo_screen;
     492FrameBuffer *fbo_blur_h, *fbo_blur_v;
     493FrameBuffer *fbo_tmp, *fbo_buffer;
    493494
    494495void Render::TraceQuad()
     
    514515    /* initialise framebuffer objects */
    515516    fbo_back = new FrameBuffer(screen_size);
     517    fbo_screen = new FrameBuffer(screen_size);
    516518    fbo_front = new FrameBuffer(screen_size);
    517519    fbo_buffer = new FrameBuffer(screen_size);
     
    11471149        fbo_tmp->Bind();
    11481150        shader_remanence->Bind();
    1149         shader_remanence->SetUniform(shader_remanence_source, fbo_front->GetTexture(), 0);
     1151        shader_remanence->SetUniform(shader_remanence_source, fbo_screen->GetTexture(), 0);
    11501152        shader_remanence->SetUniform(shader_remanence_buffer, fbo_buffer->GetTexture(), 1);
    11511153        shader_remanence->SetUniform(shader_remanence_mix, buffer);
     
    11951197        fbo_blur_v->Unbind();
    11961198        // shader glow
    1197         fbo_front->Bind();
     1199        fbo_screen->Bind();
    11981200        shader_glow->Bind();
    11991201        shader_glow->SetUniform(shader_glow_glow, fbo_blur_v->GetTexture(), 0);
     
    12021204        TraceQuad();
    12031205        shader_glow->Unbind();
    1204         fbo_front->Unbind();
     1206        fbo_screen->Unbind();
    12051207    }
    12061208    else
    12071209    {
    12081210        // shader simple
    1209         fbo_front->Bind();
     1211        fbo_screen->Bind();
    12101212        ShaderSimple(fbo_back, 0);
    1211         fbo_front->Unbind();
     1213        fbo_screen->Unbind();
    12121214    }
    12131215
     
    12171219        fbo_tmp->Bind();
    12181220        shader_color->Bind();
    1219         shader_color->SetUniform(shader_color_texture, fbo_front->GetTexture(), 0);
     1221        shader_color->SetUniform(shader_color_texture, fbo_screen->GetTexture(), 0);
    12201222        shader_color->SetUniform(shader_color_screen_size, (vec2)screen_size);
    12211223        shader_color->SetUniform(shader_color_filter, color_filter);
     
    12261228        fbo_tmp->Unbind();
    12271229        // shader simple
    1228         fbo_front->Bind();
     1230        fbo_screen->Bind();
    12291231        ShaderSimple(fbo_tmp, 0);
    1230         fbo_front->Unbind();
     1232        fbo_screen->Unbind();
    12311233    }
    12321234
     
    12361238        fbo_tmp->Bind();
    12371239        shader_noise->Bind();
    1238         shader_noise->SetUniform(shader_noise_texture, fbo_front->GetTexture(), 0);
     1240        shader_noise->SetUniform(shader_noise_texture, fbo_screen->GetTexture(), 0);
    12391241        shader_noise->SetUniform(shader_noise_screen_size, (vec2)screen_size);
    12401242        shader_noise->SetUniform(shader_noise_time, fx_angle);
     
    12461248        fbo_tmp->Unbind();
    12471249        // shader simple
    1248         fbo_front->Bind();
     1250        fbo_screen->Bind();
    12491251        ShaderSimple(fbo_tmp, 0);
    1250         fbo_front->Unbind();
     1252        fbo_screen->Unbind();
    12511253    }
    12521254
     
    12561258        fbo_tmp->Bind();
    12571259        shader_blur_h->Bind();
    1258         shader_blur_h->SetUniform(shader_blur_h_texture, fbo_front->GetTexture(), 0);
     1260        shader_blur_h->SetUniform(shader_blur_h_texture, fbo_screen->GetTexture(), 0);
    12591261        shader_blur_h->SetUniform(shader_blur_h_radius, blur / screen_size.x);
    12601262        TraceQuad();
     
    12621264        fbo_tmp->Unbind();
    12631265        // shader blur vertical
    1264         fbo_front->Bind();
     1266        fbo_screen->Bind();
    12651267        shader_blur_v->Bind();
    12661268        shader_blur_v->SetUniform(shader_blur_v_texture, fbo_tmp->GetTexture(), 0);
     
    12681270        TraceQuad();
    12691271        shader_blur_v->Unbind();
    1270         fbo_front->Unbind();
     1272        fbo_screen->Unbind();
    12711273    }
    12721274
     
    12741276    {
    12751277        // shader postfx
    1276         fbo_tmp->Bind();
     1278        fbo_front->Bind();
    12771279        shader_postfx->Bind();
    1278         shader_postfx->SetUniform(shader_postfx_texture, fbo_front->GetTexture(), 0);
     1280        shader_postfx->SetUniform(shader_postfx_texture, fbo_screen->GetTexture(), 0);
    12791281        shader_postfx->SetUniform(shader_postfx_screen_size, (vec2)screen_size);
    12801282        shader_postfx->SetUniform(shader_postfx_time, fx_angle);
     
    12891291        shader_postfx->SetUniform(shader_postfx_scanline_v, postfx_scanline_v);
    12901292        shader_postfx->SetUniform(shader_postfx_corner, postfx_corner);
    1291         shader_postfx->SetUniform(shader_postfx_sync, (float)fabs(sync_value*cosf((main_angle-sync_angle)*6.0f)));
    1292         shader_postfx->SetUniform(shader_postfx_beat, (float)fabs(beat_value*cosf((main_angle-beat_angle)*6.0f)));
     1293        shader_postfx->SetUniform(shader_postfx_sync, (float)fabs(sync_value * cosf((main_angle - sync_angle) * 6.0f)));
     1294        shader_postfx->SetUniform(shader_postfx_beat, (float)fabs(beat_value * cosf((main_angle - beat_angle) * 6.0f)));
    12931295        TraceQuad();
    12941296        shader_postfx->Unbind();
     1297        fbo_front->Unbind();
     1298    }
     1299    else
     1300    {
     1301        // shader simple
     1302        fbo_front->Bind();
     1303        ShaderSimple(fbo_screen, 0);
     1304        fbo_front->Unbind();
     1305    }
     1306
     1307    if (m_shader_mirror)
     1308    {
     1309        // shader mirror
     1310        fbo_tmp->Bind();
     1311        shader_mirror->Bind();
     1312        shader_mirror->SetUniform(shader_mirror_texture, fbo_front->GetTexture(), 0);
     1313        shader_mirror->SetUniform(shader_mirror_screen_size, (vec2)screen_size);
     1314        shader_mirror->SetUniform(shader_mirror_mirror, vec4(mirror.x * 0.1f, mirror.y * 0.1f, mirror.z, mirror.w));
     1315        TraceQuad();
     1316        shader_mirror->Unbind();
    12951317        fbo_tmp->Unbind();
    12961318        // shader simple
     
    13001322    }
    13011323
    1302     if (m_shader_mirror)
    1303     {
    1304         // shader mirror
    1305         fbo_tmp->Bind();
    1306         shader_mirror->Bind();
    1307         shader_mirror->SetUniform(shader_mirror_texture, fbo_front->GetTexture(), 0);
    1308         shader_mirror->SetUniform(shader_mirror_screen_size, (vec2)screen_size);
    1309         shader_mirror->SetUniform(shader_mirror_mirror, mirror);
    1310         TraceQuad();
    1311         shader_mirror->Unbind();
    1312         fbo_tmp->Unbind();
    1313     }
    1314 
    13151324    // shader simple
    1316     ShaderSimple(fbo_tmp, 0);
     1325    ShaderSimple(fbo_front, 0);
    13171326
    13181327    glDisableClientState(GL_VERTEX_ARRAY);
Note: See TracChangeset for help on using the changeset viewer.