From: Steinar H. Gunderson Date: Tue, 2 Oct 2012 16:50:16 +0000 (+0200) Subject: Kill the vertex shader system; it is too complicated to get it right until we have... X-Git-Tag: 1.0~423 X-Git-Url: https://git.sesse.net/?p=movit;a=commitdiff_plain;h=91c70600f2d0a6a42420ee98949cf182859b798f Kill the vertex shader system; it is too complicated to get it right until we have a full DAG understanding. --- diff --git a/effect.cpp b/effect.cpp index 6f9d4c5..3a4f8c8 100644 --- a/effect.cpp +++ b/effect.cpp @@ -152,8 +152,3 @@ void Effect::set_uniforms(GLuint glsl_program_num, const std::string& prefix) set_uniform_vec3(glsl_program_num, prefix, it->first, it->second); } } - -std::string Effect::output_vertex_shader() -{ - return read_file("identity.vert"); -} diff --git a/effect.h b/effect.h index 79209b8..1478c6e 100644 --- a/effect.h +++ b/effect.h @@ -35,7 +35,6 @@ public: virtual bool needs_mipmaps() { return false; } virtual std::string output_convenience_uniforms(); - virtual std::string output_vertex_shader(); virtual std::string output_fragment_shader() = 0; virtual void set_uniforms(GLuint glsl_program_num, const std::string& prefix); diff --git a/effect_chain.cpp b/effect_chain.cpp index f860cad..d45c2fc 100644 --- a/effect_chain.cpp +++ b/effect_chain.cpp @@ -159,24 +159,6 @@ void EffectChain::finalize() current_gamma_curve = output_format.gamma_curve; } - std::string vert_shader = read_file("header.vert"); - for (unsigned i = 0; i < effects.size(); ++i) { - char effect_id[256]; - sprintf(effect_id, "eff%d", i); - - vert_shader += "\n"; - vert_shader += std::string("#define FUNCNAME ") + effect_id + "\n"; - vert_shader += replace_prefix(effects[i]->output_convenience_uniforms(), effect_id); - vert_shader += replace_prefix(effects[i]->output_vertex_shader(), effect_id); - vert_shader += "#undef PREFIX\n"; - vert_shader += "#undef FUNCNAME\n"; - vert_shader += "#undef LAST_INPUT\n"; - vert_shader += std::string("#define LAST_INPUT ") + effect_id + "\n"; - vert_shader += "\n"; - } - vert_shader.append(read_file("footer.vert")); - printf("%s\n", vert_shader.c_str()); - std::string frag_shader = read_file("header.frag"); for (unsigned i = 0; i < effects.size(); ++i) { char effect_id[256]; @@ -196,7 +178,7 @@ void EffectChain::finalize() printf("%s\n", frag_shader.c_str()); glsl_program_num = glCreateProgram(); - GLuint vs_obj = compile_shader(vert_shader, GL_VERTEX_SHADER); + GLuint vs_obj = compile_shader(read_file("vs.vert"), GL_VERTEX_SHADER); GLuint fs_obj = compile_shader(frag_shader, GL_FRAGMENT_SHADER); glAttachShader(glsl_program_num, vs_obj); check_error(); diff --git a/identity.vert b/identity.vert deleted file mode 100644 index 77b6ff8..0000000 --- a/identity.vert +++ /dev/null @@ -1,5 +0,0 @@ -// Identity transformation (sometimes useful to do nothing). -vec2 FUNCNAME() -{ - return LAST_INPUT(); -} diff --git a/mirror_effect.cpp b/mirror_effect.cpp index f772821..7c9875a 100644 --- a/mirror_effect.cpp +++ b/mirror_effect.cpp @@ -5,12 +5,7 @@ MirrorEffect::MirrorEffect() { } -std::string MirrorEffect::output_vertex_shader() -{ - return read_file("mirror_effect.vert"); -} - std::string MirrorEffect::output_fragment_shader() { - return read_file("identity.frag"); + return read_file("mirror_effect.frag"); } diff --git a/mirror_effect.frag b/mirror_effect.frag new file mode 100644 index 0000000..2f52d2b --- /dev/null +++ b/mirror_effect.frag @@ -0,0 +1,6 @@ +// Mirrors the image horizontally. +vec4 FUNCNAME(vec2 tc) +{ + tc = vec2(1.0, 0.0) + tc * vec2(-1.0, 1.0); + return LAST_INPUT(tc); +} diff --git a/mirror_effect.h b/mirror_effect.h index 6e75b26..6b07ea9 100644 --- a/mirror_effect.h +++ b/mirror_effect.h @@ -6,7 +6,6 @@ class MirrorEffect : public Effect { public: MirrorEffect(); - std::string output_vertex_shader(); std::string output_fragment_shader(); }; diff --git a/mirror_effect.vert b/mirror_effect.vert deleted file mode 100644 index 8c29945..0000000 --- a/mirror_effect.vert +++ /dev/null @@ -1,4 +0,0 @@ -vec2 FUNCNAME() -{ - return vec2(1.0, 0.0) + LAST_INPUT() * vec2(-1.0, 1.0); -} diff --git a/vs.vert b/vs.vert new file mode 100644 index 0000000..1f48069 --- /dev/null +++ b/vs.vert @@ -0,0 +1,7 @@ +varying vec2 tc; + +void main() +{ + tc = gl_MultiTexCoord0.st; + gl_Position = ftransform(); +}