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

Last change on this file since 1665 was 1665, checked in by rez, 8 years ago

modified A LOT postfx, added MOAR controls to all effects, especially for moire/scanline

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