source: trunk/tools/neercs/video/render.cpp @ 1666

Last change on this file since 1666 was 1666, checked in by rez, 9 years ago

updated postfx.lol

File size: 22.5 KB
Line 
1//
2// Neercs
3//
4
5#if defined HAVE_CONFIG_H
6#   include "config.h"
7#endif
8
9#if defined _XBOX
10#   define _USE_MATH_DEFINES /* for M_PI */
11#   include <xtl.h>
12#elif defined _WIN32
13#   define _USE_MATH_DEFINES /* for M_PI */
14#   define WIN32_LEAN_AND_MEAN
15#   include <windows.h>
16#endif
17
18#include <cmath>
19#include <cstdio>
20#include <cstdlib>
21#include <ctime>
22#include <string>
23
24#include "core.h"
25#include "lolgl.h"
26
27using namespace std;
28using namespace lol;
29
30#include "../neercs.h"
31#include "render.h"
32#include "text-render.h"
33
34extern char const *lolfx_blurh;
35extern char const *lolfx_blurv;
36extern char const *lolfx_remanency;
37extern char const *lolfx_glow;
38extern char const *lolfx_postfx;
39extern char const *lolfx_radial;
40extern char const *lolfx_simple;
41
42#define PID M_PI/180.0f    // pi ratio
43#define CR 1.0f/256.0f     // color ratio
44
45/*
46 * Various variables
47 */
48
49int active = true;         // window active flag
50float nearplane = 0.1f;    // nearplane
51float farplane = 1000.0f;  // farplane
52int polygon_fillmode = GL_FILL; // fill mode
53bool key_state = 0;        // key state
54/* window variable */
55ivec2 screen_size;         // screen size
56vec3 screen_color = CR * vec3(32, 32, 32); // screen color
57/* object variable */
58float main_angle = 0.0f;   // main angle
59float part_angle = 0.0f;   // part angle
60float fx_angle;            // current angle
61/* fs_quad variable */
62float fs_quad_vtx[] = {-1.0f, 1.0f, 0, 1.0f, -1.0f, -1.0f, 0, 1.0f, 1.0f, -1.0f, 0, 1.0f, 1.0f, 1.0f, 0, 1.0f};
63float fs_quad_tex[] = {0, 1.0f, 0, 0, 1.0f, 0, 1.0f, 1.0f};
64/* flash variable */
65bool flash_flag = false;   // flag
66float flash_angle = 0;     // angle
67float flash_value = 0;     // value
68float flash_speed = 1.5f;  // speed
69/* fade variable */
70bool fade_flag = false;    // flag
71float fade_angle = 0;      // angle
72float fade_value = 0;      // value
73float fade_speed = 0.2f;   // speed
74/* sync variable */
75bool sync_flag = false;    // flag
76float sync_angle = 0;      // angle
77float sync_value = 1.0f;   // value
78float sync_speed = 1.0f;   // speed
79/* beat variable */
80bool beat_flag = false;    // flag
81float beat_angle = 0;      // angle
82float beat_value = 0;      // value
83float beat_speed = 2.0f;   // speed
84/* window variable */
85ivec2 border;              // border width
86/* text variable */
87ivec2 ratio_2d(1,4);       // 2d ratio
88ivec2 map_size(256,256);   // texture map size
89ivec2 font_size(8,8);      // font size
90ivec2 canvas_char(0,0);    // canvas char number
91ivec2 canvas_size(0,0);    // caca size
92/* common variable */
93float value, angle, radius, scale, speed;
94/* shader variable */
95float remanency_source_mix = 0.25f;
96float remanency_buffer_mix = 0.75f;
97float remanency_new_frame_mix = 0.75f;
98float remanency_old_frame_mix = 0.25f;
99float blur_radius = 0.25f;      // glow radius
100float blur_radius_deform = 0.625f;// glow radius deform
101int glow_fbo_size = 2;          // glow fbo size
102float glow_smoothstep = 0.1f;   // glow smoothstep value (try 0.025f)
103vec3 glow_large(0.75f,2.0f,3.0f);// large glow [mix,ratio normal,ratio deform]
104vec3 glow_small(0.50f,1.0f,1.5f);// small glow [mix,ratio normal,ratio deform]
105//---------------------------------[IDEAS] http://www.youtube.com/watch?v=d1qEP2vMe-I
106float postfx_deform = 0.625f;   // deformation ratio
107vec3 postfx_filter(0.875f,1.0f,0.75f);// color filter [red,green,blue]
108vec3 postfx_retrace(0.025f,2.0f,4.0f);// retrace [color,length,speed]
109vec2 postfx_offset(3.0f,3.0f);  // random line [horizontal,vertical]
110vec2 postfx_noise(0,0.125f);    // noise [0=grey/1=color,mix]
111float postfx_aberration = 3.0f; // chromatic aberration
112bool postfx_moire = true;       // moire
113vec4 postfx_moire_h(0.75f,0.25f,0.5f,1.5f);
114vec4 postfx_moire_v(0.75f,0.25f,0.5f,1.5f);
115bool postfx_scanline = true;    // scanline
116vec4 postfx_scanline_h(0.75f,0.25f,1.0f,0.0f);// vertical scanline [base,variable,repeat]
117vec4 postfx_scanline_v(1.0f,0.0f,0.0f,0.0f);
118//float radial_value1 = 2.0f;
119//float radial_value2 = 0.8f;
120//float radial_color = 0;
121
122Shader *shader_simple;
123Shader *shader_blur_h, *shader_blur_v;
124Shader *shader_remanency, *shader_glow, *shader_radial, *shader_postfx;
125// shader variables
126ShaderUniform shader_simple_texture;
127ShaderUniform shader_blur_h_texture,
128              shader_blur_h_screen_size,
129              shader_blur_h_blur,
130              shader_blur_h_deform;
131ShaderUniform shader_blur_v_texture,
132              shader_blur_v_screen_size,
133              shader_blur_v_blur,
134              shader_blur_v_deform;
135ShaderUniform shader_remanency_texture,
136              shader_remanency_texture_buffer,
137              shader_remanency_screen_size,
138              shader_remanency_screen_color,
139              shader_remanency_value1,
140              shader_remanency_value2;
141ShaderUniform shader_glow_texture,
142              shader_glow_texture_prv,
143              shader_glow_screen_size,
144              shader_glow_time,
145              shader_glow_step,
146              shader_glow_value1,
147              shader_glow_value2;
148ShaderUniform shader_radial_texture,
149              shader_radial_screen_size,
150              shader_radial_time,
151              shader_radial_value1,
152              shader_radial_value2,
153              shader_radial_color;
154ShaderUniform shader_postfx_texture,
155              shader_postfx_texture_2d,
156              shader_postfx_screen_size,
157              shader_postfx_time,
158              shader_postfx_deform,
159              shader_postfx_filter,
160              shader_postfx_retrace,
161              shader_postfx_offset,
162              shader_postfx_noise,
163              shader_postfx_aberration,
164              shader_postfx_moire,
165              shader_postfx_moire_h,
166              shader_postfx_moire_v,
167              shader_postfx_scanline,
168              shader_postfx_scanline_h,
169              shader_postfx_scanline_v,
170              shader_postfx_flash,
171              shader_postfx_sync;
172
173FrameBuffer *fbo_back, *fbo_front, *fbo_buffer;
174FrameBuffer *fbo_blur_h, *fbo_blur_v, *fbo_ping, *fbo_pong;
175
176TextRender *text_render;
177
178void fs_quad()
179{
180    glLoadIdentity();
181    glDrawArrays(GL_QUADS, 0, 4);
182}
183
184void draw_shader_simple(FrameBuffer *fbo_output, int n)
185{
186    shader_simple->Bind();
187    shader_simple->SetTexture(shader_simple_texture, fbo_output->GetTexture(), n);
188    fs_quad();
189    shader_simple->Unbind();
190}
191
192void rectangle(int x, int y, int w, int h)
193{
194    glLoadIdentity();
195    glBegin(GL_QUADS);
196        glVertex2i(x+w, y  );
197        glVertex2i(x  , y  );
198        glVertex2i(x  , y+h);
199        glVertex2i(x+w, y+h);
200    glEnd();
201}
202
203int Render::InitDraw(void)
204{
205    glDepthMask(GL_TRUE);     // do not write z-buffer
206    glEnable(GL_CULL_FACE);   // disable cull face
207    glCullFace(GL_BACK);      // don't draw front face
208
209    /* Initialise framebuffer objects */
210    fbo_back = new FrameBuffer(screen_size);
211    fbo_front = new FrameBuffer(screen_size);
212    fbo_buffer = new FrameBuffer(screen_size);
213    fbo_blur_h = new FrameBuffer(screen_size / glow_fbo_size);
214    fbo_blur_v = new FrameBuffer(screen_size / glow_fbo_size);
215    fbo_ping = new FrameBuffer(screen_size);
216    fbo_pong = new FrameBuffer(screen_size);
217    // shader simple
218    shader_simple = Shader::Create(lolfx_simple);
219    shader_simple_texture = shader_simple->GetUniformLocation("texture");
220    // shader blur horizontal
221    shader_blur_h = Shader::Create(lolfx_blurh);
222    shader_blur_h_texture = shader_blur_h->GetUniformLocation("texture");
223    shader_blur_h_screen_size = shader_blur_h->GetUniformLocation("screen_size");
224    shader_blur_h_blur = shader_blur_h->GetUniformLocation("blur");
225    shader_blur_h_deform = shader_blur_h->GetUniformLocation("deform");
226    // shader blur vertical
227    shader_blur_v = Shader::Create(lolfx_blurv);
228    shader_blur_v_texture = shader_blur_v->GetUniformLocation("texture");
229    shader_blur_v_screen_size = shader_blur_v->GetUniformLocation("screen_size");
230    shader_blur_v_blur = shader_blur_v->GetUniformLocation("blur");
231    shader_blur_v_deform = shader_blur_v->GetUniformLocation("deform");
232    // shader remanency
233    shader_remanency = Shader::Create(lolfx_remanency);
234    shader_remanency_texture = shader_remanency->GetUniformLocation("texture");
235    shader_remanency_texture_buffer = shader_remanency->GetUniformLocation("texture_buffer");
236    shader_remanency_screen_size = shader_remanency->GetUniformLocation("screen_size");
237    shader_remanency_screen_color = shader_remanency->GetUniformLocation("screen_color");
238    shader_remanency_value1 = shader_remanency->GetUniformLocation("value1");
239    shader_remanency_value2 = shader_remanency->GetUniformLocation("value2");
240    // shader glow
241    shader_glow = Shader::Create(lolfx_glow);
242    shader_glow_texture = shader_glow->GetUniformLocation("texture");
243    shader_glow_texture_prv = shader_glow->GetUniformLocation("texture_prv");
244    shader_glow_screen_size = shader_glow->GetUniformLocation("screen_size");
245    shader_glow_time = shader_glow->GetUniformLocation("time");
246    shader_glow_step = shader_glow->GetUniformLocation("step");
247    shader_glow_value1 = shader_glow->GetUniformLocation("value1");
248    shader_glow_value2 = shader_glow->GetUniformLocation("value2");
249    // shader radial
250    shader_radial = Shader::Create(lolfx_radial);
251    shader_radial_texture = shader_radial->GetUniformLocation("texture");
252    shader_radial_screen_size = shader_radial->GetUniformLocation("screen_size");
253    shader_radial_time = shader_radial->GetUniformLocation("time");
254    shader_radial_value1 = shader_radial->GetUniformLocation("value1");
255    shader_radial_value2 = shader_radial->GetUniformLocation("value2");
256    shader_radial_color = shader_radial->GetUniformLocation("color");
257    // shader postfx
258    shader_postfx = Shader::Create(lolfx_postfx);
259    shader_postfx_texture = shader_postfx->GetUniformLocation("texture");
260    shader_postfx_texture_2d = shader_postfx->GetUniformLocation("texture_2d");
261    shader_postfx_screen_size = shader_postfx->GetUniformLocation("screen_size");
262    shader_postfx_time = shader_postfx->GetUniformLocation("time");
263    shader_postfx_deform = shader_postfx->GetUniformLocation("deform");
264    shader_postfx_filter = shader_postfx->GetUniformLocation("filter");
265    shader_postfx_retrace = shader_postfx->GetUniformLocation("retrace");
266    shader_postfx_offset = shader_postfx->GetUniformLocation("offset");
267    shader_postfx_noise = shader_postfx->GetUniformLocation("noise");
268    shader_postfx_aberration = shader_postfx->GetUniformLocation("aberration");
269    shader_postfx_moire = shader_postfx->GetUniformLocation("moire");
270    shader_postfx_moire_h = shader_postfx->GetUniformLocation("moire_h");
271    shader_postfx_moire_v = shader_postfx->GetUniformLocation("moire_v");
272    shader_postfx_scanline = shader_postfx->GetUniformLocation("scanline");
273    shader_postfx_scanline_h = shader_postfx->GetUniformLocation("scanline_h");
274    shader_postfx_scanline_v = shader_postfx->GetUniformLocation("scanline_v");
275    shader_postfx_flash = shader_postfx->GetUniformLocation("flash");
276    shader_postfx_sync = shader_postfx->GetUniformLocation("sync");
277
278    return true;
279}
280
281int Render::CreateGLWindow()
282{
283    screen_size = Video::GetSize();
284    border = 18 * ratio_2d;
285    border.y = border.x; // enabled to get same border everywhere
286    canvas_char = (screen_size - border * 2) / (font_size * ratio_2d);
287    canvas_size = canvas_char * font_size * ratio_2d;
288
289    border = (screen_size - canvas_size) / 2;
290
291    caca_set_canvas_size(m_caca, canvas_char.x, canvas_char.y);
292
293    InitDraw();
294    return true;
295}
296
297Render::Render(caca_canvas_t *caca)
298  : m_caca(caca),
299    m_ready(false),
300    m_pause(false),
301    m_polygon(true),
302    m_shader(true),
303    m_shader_remanency(true),
304    m_shader_blur(true),
305    m_shader_glow(true),
306    m_shader_fx(true),
307    m_shader_postfx(true),
308    m_border(false)
309{
310    text_render = new TextRender(m_caca, font_size);
311}
312
313void Render::TickGame(float seconds)
314{
315    Entity::TickGame(seconds);
316}
317
318void Render::Pause()
319{
320    m_pause=!m_pause;
321}
322
323void Render::TickDraw(float seconds)
324{
325    /* keyboard manager */
326    if (Input::GetButtonState(27/*SDLK_ESCAPE*/))
327        Ticker::Shutdown();
328    //if (Input::GetButtonState(282/*SDLK_F1*/))
329    //    LEAULE();
330    if (Input::GetButtonState(283/*SDLK_F2*/))
331        {
332        m_polygon=!m_polygon;
333        polygon_fillmode=(m_polygon)?GL_FILL:GL_LINE;
334        glPolygonMode(GL_FRONT,polygon_fillmode);
335        }
336    if (Input::GetButtonState(284/*SDLK_F3*/)&&key_state!=284)
337        {
338        m_shader=!m_shader;
339        key_state=284;
340        }
341    if (Input::GetButtonState(285/*SDLK_F4*/))
342        m_shader_postfx=!m_shader_postfx;
343    if (Input::GetButtonState(286/*SDLK_F5*/))
344        Pause();
345
346    Entity::TickDraw(seconds);
347
348    if (!m_ready)
349    {
350        CreateGLWindow();
351        text_render->Init();
352        m_ready = true;
353    }
354
355    // timer
356    if (!m_pause)
357        main_angle += seconds * 100.0f * PID;
358    if (sync_flag)
359    {
360        angle=(main_angle-sync_angle)*sync_speed;
361        sync_value=1.0f-sinf(angle);
362        if (angle>90.0f*PID)
363        {
364            sync_value=0;
365            sync_flag=false;
366        }
367    }
368    if (beat_flag)
369    {
370        angle=(main_angle-beat_angle)*beat_speed;
371        beat_value=1.0f-sinf(angle);
372        if (angle>90.0f*PID)
373        {
374            beat_value=0;
375            beat_flag=false;
376        }
377    }
378    if (flash_flag)
379    {
380        angle=(main_angle-flash_angle)*flash_speed;
381        flash_value=1.0f-sinf(angle);
382        if (angle>90.0f*PID)
383        {
384            flash_value=0;
385            flash_flag=false;
386        }
387    }
388    if (fade_flag)
389    {
390        angle=(main_angle-fade_angle)*fade_speed;
391        fade_value=1.0f-sinf(angle);
392        if (angle>90.0f*PID)
393        {
394            fade_value=0;
395            fade_flag=false;
396        }
397    }
398
399    Draw2D();
400    Draw3D();
401}
402
403void Render::Draw2D()
404{
405    /* Draw text in an offline buffer */
406    text_render->Render();
407
408    if (m_shader)
409    {
410        fbo_back->Bind();
411    }
412
413    glViewport(0, 0, screen_size.x, screen_size.y);
414
415    /* Clear the back buffer */
416    glEnable(GL_BLEND);
417    glBlendFunc(GL_SRC_COLOR,GL_DST_ALPHA);
418    glClearColor(screen_color.r, screen_color.g, screen_color.b, 1.0f);
419    glClearDepth(1.0f); // set depth buffer
420    glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
421
422    text_render->Blit(border, canvas_size);
423
424    //if (m_polygon) glEnable(GL_LINE_SMOOTH); else glDisable(GL_LINE_SMOOTH);
425    glLineWidth((m_polygon)?2.0f:1.0f);
426    fx_angle=main_angle-part_angle;
427    if (m_polygon)
428        glEnable(GL_TEXTURE_2D);
429
430    glMatrixMode(GL_PROJECTION);
431    mat4 m = mat4::ortho(0, screen_size.x, screen_size.y, 0, -1.f, 1.f);
432    glLoadMatrixf(&m[0][0]);
433    glMatrixMode(GL_MODELVIEW);
434    // draw border
435    if (m_border)
436    {
437        glDisable(GL_TEXTURE_2D);
438        glDisable(GL_BLEND);
439        glColor3f(1.0f, 1.0f, 1.0f);
440        rectangle(border.x - ratio_2d.x, border.y - ratio_2d.y, canvas_size.x + ratio_2d.x * 2, ratio_2d.y);
441        rectangle(border.x - ratio_2d.x, border.y, ratio_2d.x, canvas_size.y);
442        rectangle(border.x + canvas_size.x, border.y, ratio_2d.x, canvas_size.y);
443        rectangle(border.x - ratio_2d.x, border.y + canvas_size.y, canvas_size.x + ratio_2d.x * 2, ratio_2d.y);
444        glEnable(GL_BLEND);
445    }
446}
447
448void Render::Draw3D()
449{
450    if (!m_shader)
451        return;
452
453    glDisable(GL_DEPTH_TEST);
454    glDisable(GL_BLEND);
455
456    glEnableClientState(GL_VERTEX_ARRAY);
457    glVertexPointer(4, GL_FLOAT, 0, fs_quad_vtx);
458
459    glEnableClientState(GL_TEXTURE_COORD_ARRAY);
460    glTexCoordPointer(2, GL_FLOAT, 0, fs_quad_tex);
461
462    if (m_shader_remanency)
463    {
464        // shader remanency
465        fbo_ping->Bind();
466        shader_remanency->Bind();
467        shader_remanency->SetTexture(shader_remanency_texture, fbo_back->GetTexture(), 0);
468        shader_remanency->SetTexture(shader_remanency_texture_buffer, fbo_buffer->GetTexture(), 1);
469        shader_remanency->SetUniform(shader_remanency_screen_size, vec2(1.0f));
470        shader_remanency->SetUniform(shader_remanency_screen_color, screen_color);
471        shader_remanency->SetUniform(shader_remanency_value1, remanency_source_mix);
472        shader_remanency->SetUniform(shader_remanency_value2, remanency_buffer_mix);
473        fs_quad();
474        shader_remanency->Unbind();
475        fbo_ping->Unbind();
476        // shader simple
477        fbo_back->Bind();
478        draw_shader_simple(fbo_ping, 0);
479        fbo_back->Unbind();
480        // save previous fbo
481        fbo_ping->Bind();
482        shader_remanency->Bind();
483        shader_remanency->SetTexture(shader_remanency_texture, fbo_front->GetTexture(), 0);
484        shader_remanency->SetTexture(shader_remanency_texture_buffer, fbo_buffer->GetTexture(), 1);
485        shader_remanency->SetUniform(shader_remanency_screen_size, vec2(1.0f));
486        shader_remanency->SetUniform(shader_remanency_screen_color, screen_color);
487        shader_remanency->SetUniform(shader_remanency_value1, remanency_new_frame_mix);
488        shader_remanency->SetUniform(shader_remanency_value2, remanency_old_frame_mix);
489        fs_quad();
490        shader_remanency->Unbind();
491        fbo_ping->Unbind();
492        // shader simple
493        fbo_buffer->Bind();
494        draw_shader_simple(fbo_ping, 0);
495        fbo_buffer->Unbind();
496    }
497
498    if (m_shader_fx && m_shader_blur)
499    {
500        // shader blur horizontal
501        fbo_ping->Bind();
502        shader_blur_h->Bind();
503        shader_blur_h->SetTexture(shader_blur_h_texture, fbo_back->GetTexture(), 0);
504        shader_blur_h->SetUniform(shader_blur_h_screen_size, vec2(1.0f));
505        shader_blur_h->SetUniform(shader_blur_h_blur, blur_radius / screen_size.x);
506        shader_blur_h->SetUniform(shader_blur_h_deform, blur_radius_deform / screen_size.x);
507        fs_quad();
508        shader_blur_h->Unbind();
509        fbo_ping->Unbind();
510        // shader blur vertical
511        fbo_front->Bind();
512        shader_blur_v->Bind();
513        shader_blur_v->SetTexture(shader_blur_v_texture, fbo_ping->GetTexture(), 0);
514        shader_blur_v->SetUniform(shader_blur_v_screen_size, vec2(1.0f));
515        shader_blur_v->SetUniform(shader_blur_v_blur, blur_radius / screen_size.y);
516        shader_blur_v->SetUniform(shader_blur_v_deform, blur_radius_deform / screen_size.y);
517        fs_quad();
518        shader_blur_v->Unbind();
519    }
520    else
521    {
522        // shader simple
523        fbo_front->Bind();
524        draw_shader_simple(fbo_back, 0);
525    }
526    fbo_front->Unbind();
527    // shader glow
528    if (m_shader_fx && m_shader_glow)
529    {
530        // shader blur horizontal
531        fbo_blur_h->Bind();
532        shader_blur_h->Bind();
533        shader_blur_h->SetTexture(shader_blur_h_texture, fbo_ping->GetTexture(), 0);
534        shader_blur_h->SetUniform(shader_blur_h_screen_size, vec2(1.0f / glow_fbo_size));
535        shader_blur_h->SetUniform(shader_blur_h_blur, glow_large.y / screen_size.x);
536        shader_blur_h->SetUniform(shader_blur_h_deform, glow_large.z / screen_size.x);
537        fs_quad();
538        shader_blur_h->Unbind();
539        fbo_blur_h->Unbind();
540        // shader blur vertical
541        fbo_blur_v->Bind();
542        shader_blur_v->Bind();
543        shader_blur_v->SetTexture(shader_blur_v_texture, fbo_blur_h->GetTexture(), 0);
544        shader_blur_v->SetUniform(shader_blur_v_screen_size, vec2(1.0f / glow_fbo_size));
545        shader_blur_v->SetUniform(shader_blur_v_blur, glow_large.y / screen_size.y);
546        shader_blur_v->SetUniform(shader_blur_v_deform, glow_large.z / screen_size.y);
547        fs_quad();
548        shader_blur_v->Unbind();
549        fbo_blur_v->Unbind();
550        // shader blur horizontal
551        fbo_blur_h->Bind();
552        shader_blur_h->Bind();
553        shader_blur_h->SetTexture(shader_blur_h_texture, fbo_blur_v->GetTexture(), 0);
554        shader_blur_h->SetUniform(shader_blur_h_screen_size, vec2(1.0f / glow_fbo_size));
555        shader_blur_h->SetUniform(shader_blur_h_blur, glow_small.y / screen_size.x);
556        shader_blur_h->SetUniform(shader_blur_h_deform, glow_small.z / screen_size.x);
557        fs_quad();
558        shader_blur_h->Unbind();
559        fbo_blur_h->Unbind();
560        // shader blur vertical
561        fbo_blur_v->Bind();
562        shader_blur_v->Bind();
563        shader_blur_v->SetTexture(shader_blur_v_texture, fbo_blur_h->GetTexture(), 0);
564        shader_blur_v->SetUniform(shader_blur_v_screen_size, vec2(1.0f / glow_fbo_size));
565        shader_blur_v->SetUniform(shader_blur_v_blur, glow_small.y / screen_size.y);
566        shader_blur_h->SetUniform(shader_blur_v_deform, glow_small.z / screen_size.y);
567        fs_quad();
568        shader_blur_v->Unbind();
569        fbo_blur_v->Unbind();
570        // shader glow
571        fbo_pong->Bind();
572        shader_glow->Bind();
573        shader_glow->SetTexture(shader_glow_texture, fbo_blur_v->GetTexture(), 0);
574        shader_glow->SetTexture(shader_glow_texture_prv, fbo_front->GetTexture(), 1);
575        shader_glow->SetUniform(shader_glow_screen_size, vec2(1.0f));
576        shader_glow->SetUniform(shader_glow_time, fx_angle);
577        shader_glow->SetUniform(shader_glow_step, glow_smoothstep);
578        shader_glow->SetUniform(shader_glow_value1, glow_large.x);
579        shader_glow->SetUniform(shader_glow_value2, glow_small.x);
580        fs_quad();
581        shader_glow->Unbind();
582    }
583    if (!m_shader_fx)
584    {
585        // shader simple
586        fbo_pong->Bind();
587        draw_shader_simple(fbo_front, 0);
588    }
589    fbo_pong->Unbind();
590    if (m_shader_postfx)
591    {
592        // shader postfx
593        shader_postfx->Bind();
594        shader_postfx->SetTexture(shader_postfx_texture, fbo_pong->GetTexture(), 0);
595        shader_postfx->SetUniform(shader_postfx_screen_size, (vec2)screen_size);
596        shader_postfx->SetUniform(shader_postfx_time, fx_angle);
597        shader_postfx->SetUniform(shader_postfx_deform, postfx_deform);
598        shader_postfx->SetUniform(shader_postfx_filter, postfx_filter);
599        shader_postfx->SetUniform(shader_postfx_retrace, postfx_retrace);
600        shader_postfx->SetUniform(shader_postfx_offset, postfx_offset);
601        shader_postfx->SetUniform(shader_postfx_noise, postfx_noise);
602        shader_postfx->SetUniform(shader_postfx_aberration, postfx_aberration);
603        shader_postfx->SetUniform(shader_postfx_moire, postfx_moire);
604        shader_postfx->SetUniform(shader_postfx_moire_h, postfx_moire_h);
605        shader_postfx->SetUniform(shader_postfx_moire_v, postfx_moire_v);
606        shader_postfx->SetUniform(shader_postfx_scanline, postfx_scanline);
607        shader_postfx->SetUniform(shader_postfx_scanline_h, postfx_scanline_h);
608        shader_postfx->SetUniform(shader_postfx_scanline_v, postfx_scanline_v);
609        shader_postfx->SetUniform(shader_postfx_flash, flash_value);
610        shader_postfx->SetUniform(shader_postfx_sync, (float)fabs(beat_value*cosf((main_angle-beat_angle)*8.0f)));
611        fs_quad();
612        shader_postfx->Unbind();
613    }
614    else
615    {
616        // shader simple
617        draw_shader_simple(fbo_pong, 0);
618    }
619
620    glDisableClientState(GL_VERTEX_ARRAY);
621    glDisableClientState(GL_TEXTURE_COORD_ARRAY);
622}
623
624Render::~Render()
625{
626}
Note: See TracBrowser for help on using the repository browser.