X-Git-Url: https://git.sesse.net/?p=movit;a=blobdiff_plain;f=dither_effect.cpp;h=3fa6aebc3fa8f674674ca37e37ac6932be78c6fe;hp=17c577d4cdacc3ae44a4c79015d46c6e888389d6;hb=29dbee6d7375145fda1346dbd2531017c9ce8e1e;hpb=c5b9c3df43caa7a88f2f729a5c52359ca8ca537f diff --git a/dither_effect.cpp b/dither_effect.cpp index 17c577d..3fa6aeb 100644 --- a/dither_effect.cpp +++ b/dither_effect.cpp @@ -35,6 +35,10 @@ DitherEffect::DitherEffect() register_int("output_width", &width); register_int("output_height", &height); register_int("num_bits", &num_bits); + register_uniform_float("round_fac", &uniform_round_fac); + register_uniform_float("inv_round_fac", &uniform_inv_round_fac); + register_uniform_vec2("tc_scale", uniform_tc_scale); + register_uniform_sampler2d("dither_tex", &uniform_dither_tex); glGenTextures(1, &texnum); } @@ -47,7 +51,7 @@ DitherEffect::~DitherEffect() string DitherEffect::output_fragment_shader() { char buf[256]; - sprintf(buf, "#define NEED_EXPLICIT_ROUND %d\n", (movit_num_wrongly_rounded > 0 && movit_shader_rounding_supported)); + sprintf(buf, "#define NEED_EXPLICIT_ROUND %d\n", (movit_num_wrongly_rounded > 0)); return buf + read_file("dither_effect.frag"); } @@ -110,19 +114,19 @@ void DitherEffect::set_gl_state(GLuint glsl_program_num, const string &prefix, u glBindTexture(GL_TEXTURE_2D, texnum); check_error(); - set_uniform_int(glsl_program_num, prefix, "dither_tex", *sampler_num); - ++sampler_num; + uniform_dither_tex = *sampler_num; + ++*sampler_num; // In theory, we should adjust for the texel centers that have moved here as well, // but since we use GL_NEAREST and we don't really care a lot what texel we sample, // we don't have to worry about it. - float tc_scale[] = { float(width) / float(texture_width), float(height) / float(texture_height) }; - set_uniform_vec2(glsl_program_num, prefix, "tc_scale", tc_scale); + uniform_tc_scale[0] = float(width) / float(texture_width); + uniform_tc_scale[1] = float(height) / float(texture_height); // Used if the shader needs to do explicit rounding. int round_fac = (1 << num_bits) - 1; - set_uniform_float(glsl_program_num, prefix, "round_fac", round_fac); - set_uniform_float(glsl_program_num, prefix, "inv_round_fac", 1.0f / round_fac); + uniform_round_fac = round_fac; + uniform_inv_round_fac = 1.0f / round_fac; } } // namespace movit