5 #include "effect_util.h"
7 #include "vignette_effect.h"
13 VignetteEffect::VignetteEffect()
15 aspect_correction(1.0f, 1.0f),
19 register_vec2("center", (float *)¢er);
20 register_float("radius", (float *)&radius);
21 register_float("inner_radius", (float *)&inner_radius);
24 string VignetteEffect::output_fragment_shader()
26 return read_file("vignette_effect.frag");
29 void VignetteEffect::inform_input_size(unsigned input_num, unsigned width, unsigned height) {
30 assert(input_num == 0);
31 if (width >= height) {
32 aspect_correction = Point2D(float(width) / float(height), 1.0f);
34 aspect_correction = Point2D(1.0f, float(height) / float(width));
38 void VignetteEffect::set_gl_state(GLuint glsl_program_num, const string &prefix, unsigned *sampler_num)
40 Effect::set_gl_state(glsl_program_num, prefix, sampler_num);
42 set_uniform_float(glsl_program_num, prefix, "pihalf_div_radius", 0.5 * M_PI / radius);
43 set_uniform_vec2(glsl_program_num, prefix, "aspect_correction", (float *)&aspect_correction);
45 Point2D flipped_center(center.x, 1.0f - center.y);
46 set_uniform_vec2(glsl_program_num, prefix, "flipped_center", (float *)&flipped_center);