]> git.sesse.net Git - casparcg/commitdiff
2.0. image_mixer: Re-enabled image adjustements.
authorRonag <Ronag@362d55ac-95cf-4e76-9f9a-cbaa9c17b72d>
Sun, 14 Aug 2011 09:58:47 +0000 (09:58 +0000)
committerRonag <Ronag@362d55ac-95cf-4e76-9f9a-cbaa9c17b72d>
Sun, 14 Aug 2011 09:58:47 +0000 (09:58 +0000)
git-svn-id: https://casparcg.svn.sourceforge.net/svnroot/casparcg/server/branches/2.0.0.2@1167 362d55ac-95cf-4e76-9f9a-cbaa9c17b72d

core/mixer/image/image_kernel.cpp

index 0ca341aa8e2bd70148474b947736f48c784d09eb..bc23ad20f6ab9e3bc0270fca4c7ae1d77a425713 100644 (file)
@@ -108,10 +108,6 @@ struct image_kernel::implementation : boost::noncopyable
        //      "vec4 blend_color(vec4 fore)                                                                                                            \n"\r
        //      "{                                                                                                                                                                      \n"\r
        //      "   vec4 back = texture2D(background, gl_TexCoord[1].st);                                                       \n"\r
-       //      "   if(levels)                                                                                                                                          \n"\r
-       //      "               fore.rgb = LevelsControl(fore.rgb, min_input, max_input, gamma, min_output, max_output); \n"\r
-       //      "       if(csb)                                                                                                                                                 \n"\r
-       //      "               fore.rgb = ContrastSaturationBrightness(fore.rgb, brt, sat, con);                       \n"\r
        //      "   fore.rgb = get_blend_color(back.bgr, fore.rgb);                                                                     \n"\r
        //      "                                                                                                                                                                       \n"\r
        //      "       return vec4(mix(back.rgb, fore.rgb, fore.a), back.a + fore.a);                                  \n"\r
@@ -147,7 +143,7 @@ struct image_kernel::implementation : boost::noncopyable
                return\r
 \r
                "#version 120                                                                                                                                           \n"\r
-               "uniform sampler2D      background;                                                                                                             \n"\r
+               //"uniform sampler2D    background;                                                                                                     \n"\r
                "uniform sampler2D      plane[4];                                                                                                               \n"\r
                "uniform sampler2D      local_key;                                                                                                              \n"\r
                "uniform sampler2D      layer_key;                                                                                                              \n"\r
@@ -155,8 +151,8 @@ struct image_kernel::implementation : boost::noncopyable
                "uniform bool           is_hd;                                                                                                                  \n"\r
                "uniform bool           has_local_key;                                                                                                  \n"\r
                "uniform bool           has_layer_key;                                                                                                  \n"\r
-               "uniform int            blend_mode;                                                                                                             \n"\r
-               "uniform int            alpha_mode;                                                                                                             \n"\r
+               //"uniform int          blend_mode;                                                                                                             \n"\r
+               //"uniform int          alpha_mode;                                                                                                             \n"\r
                "uniform int            pixel_format;                                                                                                   \n"\r
                "                                                                                                                                                                       \n"\r
                "uniform bool           levels;                                                                                                                 \n"\r
@@ -170,7 +166,14 @@ struct image_kernel::implementation : boost::noncopyable
                "uniform float          brt;                                                                                                                    \n"\r
                "uniform float          sat;                                                                                                                    \n"\r
                "uniform float          con;                                                                                                                    \n"\r
-               "                                                                                                                                                                       \n"                             \r
+               "                                                                                                                                                                       \n"     \r
+\r
+               +\r
+               \r
+               get_blend_glsl()\r
+\r
+               +\r
+\r
                "//http://slouken.blogspot.com/2011/02/mpeg-acceleration-with-glsl.html                         \n"\r
                "vec4 ycbcra_to_rgba_sd(float y, float cb, float cr, float a)                                           \n"\r
                "{                                                                                                                                                                      \n"\r
@@ -265,6 +268,10 @@ struct image_kernel::implementation : boost::noncopyable
                "void main()                                                                                                                                            \n"\r
                "{                                                                                                                                                                      \n"\r
                "       vec4 color = get_rgba_color();                                                                                                  \n"\r
+               "   if(levels)                                                                                                                                          \n"\r
+               "               color.rgb = LevelsControl(color.rgb, min_input, max_input, gamma, min_output, max_output); \n"\r
+               "       if(csb)                                                                                                                                                 \n"\r
+               "               color.rgb = ContrastSaturationBrightness(color.rgb, brt, sat, con);                     \n"\r
                "       if(has_local_key)                                                                                                                               \n"\r
                "               color.a *= texture2D(local_key, gl_TexCoord[1].st).r;                                           \n"\r
                "       if(has_layer_key)                                                                                                                               \n"\r
@@ -310,10 +317,9 @@ struct image_kernel::implementation : boost::noncopyable
                                shader_.reset(new shader(get_vertex(), get_fragment(true)));\r
                        }\r
                        \r
+                       GL(glEnable(GL_TEXTURE_2D));\r
                        GL(glEnable(GL_BLEND));\r
                        GL(glBlendFuncSeparate(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA, GL_ONE, GL_ONE));\r
-\r
-                       GL(glEnable(GL_TEXTURE_2D));\r
                }\r
 \r
                if(last_mode_ != item.mode)\r
@@ -351,7 +357,7 @@ struct image_kernel::implementation : boost::noncopyable
                if(layer_key)\r
                        layer_key->bind(5);\r
 \r
-               background->bind(6);\r
+               //background->bind(6);\r
 \r
                // Setup shader\r
 \r
@@ -363,12 +369,12 @@ struct image_kernel::implementation : boost::noncopyable
                shader_->set("plane[3]",                3);\r
                shader_->set("local_key",               4);\r
                shader_->set("layer_key",               5);\r
-               shader_->set("background",              6);\r
+               //shader_->set("background",            6);\r
                shader_->set("is_hd",                   item.pix_desc.planes.at(0).height > 700 ? 1 : 0);\r
                shader_->set("has_local_key",   local_key ? 1 : 0);\r
                shader_->set("has_layer_key",   layer_key ? 1 : 0);\r
-               shader_->set("blend_mode",              item.transform.get_is_key() ? core::image_transform::blend_mode::normal : item.transform.get_blend_mode());\r
-               shader_->set("alpha_mode",              item.transform.get_alpha_mode());\r
+               //shader_->set("blend_mode",            item.transform.get_is_key() ? core::image_transform::blend_mode::normal : item.transform.get_blend_mode());\r
+               //shader_->set("alpha_mode",            item.transform.get_alpha_mode());\r
                shader_->set("pixel_format",    item.pix_desc.pix_fmt); \r
 \r
                auto levels = item.transform.get_levels();\r
@@ -408,12 +414,19 @@ struct image_kernel::implementation : boost::noncopyable
                                                \r
                auto m_p = item.transform.get_clip_translation();\r
                auto m_s = item.transform.get_clip_scale();\r
-               double w = static_cast<double>(background->width());\r
-               double h = static_cast<double>(background->height());\r
 \r
-               GL(glEnable(GL_SCISSOR_TEST));\r
-               GL(glScissor(static_cast<size_t>(m_p[0]*w), static_cast<size_t>(m_p[1]*h), static_cast<size_t>(m_s[0]*w), static_cast<size_t>(m_s[1]*h)));\r
-                       \r
+               bool scissor = m_p[0] > std::numeric_limits<double>::epsilon()           || m_p[1] > std::numeric_limits<double>::epsilon() &&\r
+                                          m_s[0] < 1.0 - std::numeric_limits<double>::epsilon() || m_s[1] < 1.0 - std::numeric_limits<double>::epsilon();\r
+\r
+               if(scissor)\r
+               {\r
+                       double w = static_cast<double>(background->width());\r
+                       double h = static_cast<double>(background->height());\r
+               \r
+                       GL(glEnable(GL_SCISSOR_TEST));\r
+                       GL(glScissor(static_cast<size_t>(m_p[0]*w), static_cast<size_t>(m_p[1]*h), static_cast<size_t>(m_s[0]*w), static_cast<size_t>(m_s[1]*h)));\r
+               }\r
+\r
                auto f_p = item.transform.get_fill_translation();\r
                auto f_s = item.transform.get_fill_scale();\r
                \r
@@ -426,7 +439,8 @@ struct image_kernel::implementation : boost::noncopyable
                        glMultiTexCoord2d(GL_TEXTURE0, 0.0, 1.0); glMultiTexCoord2d(GL_TEXTURE1,  f_p[0]        , (f_p[1]+f_s[1]));             glVertex2d( f_p[0]        *2.0-1.0, (f_p[1]+f_s[1])*2.0-1.0);\r
                glEnd();\r
 \r
-               GL(glDisable(GL_SCISSOR_TEST)); \r
+               if(scissor)\r
+                       GL(glDisable(GL_SCISSOR_TEST)); \r
        }\r
 };\r
 \r