]> git.sesse.net Git - casparcg/commitdiff
2.0. image_mixer: Added "keyer" concept.
authorronag <ronag@362d55ac-95cf-4e76-9f9a-cbaa9c17b72d>
Thu, 25 Aug 2011 14:20:46 +0000 (14:20 +0000)
committerronag <ronag@362d55ac-95cf-4e76-9f9a-cbaa9c17b72d>
Thu, 25 Aug 2011 14:20:46 +0000 (14:20 +0000)
git-svn-id: https://casparcg.svn.sourceforge.net/svnroot/casparcg/server/branches/2.0.0.2@1285 362d55ac-95cf-4e76-9f9a-cbaa9c17b72d

core/mixer/image/image_kernel.cpp
core/mixer/image/image_kernel.h
core/mixer/image/image_mixer.cpp
core/mixer/image/image_shader.cpp

index 1fd83d91d5d8b0b0efd6a32cd21f8c4adaa70c80..9e5e4de0cb56cc6faf00240f6c680ba145f7bb65 100644 (file)
@@ -120,14 +120,16 @@ struct image_kernel::implementation : boost::noncopyable
 \r
                        shader_->set("background",      texture_id::background);\r
                        shader_->set("blend_mode",      params.blend_mode);\r
+                       shader_->set("keyer",           params.keyer);\r
                }\r
                else\r
                {\r
-                       switch(params.blend_mode)\r
+                       switch(params.keyer)\r
                        {\r
-                       case blend_mode::mix:\r
+                       case keyer::additive:\r
                                ogl.blend_func(GL_ONE, GL_ONE); \r
                                break;\r
+                       case keyer::linear:\r
                        default:                                \r
                                ogl.blend_func(GL_ONE, GL_ONE_MINUS_SRC_ALPHA); \r
                        }               \r
index 31e9098e404dae16b6cb71bf6cbe0e667b261c5b..9db54b321e1609ec704f83a6f492073087799952 100644 (file)
@@ -33,18 +33,29 @@ namespace caspar { namespace core {
 class device_buffer;\r
 class ogl_device;\r
 \r
+struct keyer\r
+{\r
+       enum type\r
+       {\r
+               linear = 0,\r
+               additive\r
+       };\r
+};\r
+\r
 struct draw_params\r
 {\r
        pixel_format_desc                                               pix_desc;\r
        std::vector<safe_ptr<device_buffer>>    textures;\r
        frame_transform                                                 transform;\r
        blend_mode::type                                                blend_mode;\r
+       keyer::type                                                             keyer;\r
        std::shared_ptr<device_buffer>                  background;\r
        std::shared_ptr<device_buffer>                  local_key;\r
        std::shared_ptr<device_buffer>                  layer_key;\r
 \r
        draw_params() \r
                : blend_mode(blend_mode::normal)\r
+               , keyer(keyer::linear)\r
        {\r
        }\r
 };\r
index 393c8a7140f6383df22c486dadb3951f72bc459d..35e95f0a34e1e75ad42b7a44709fab40b92e84e1 100644 (file)
@@ -178,7 +178,6 @@ private:
                draw_params.pix_desc                            = std::move(item.pix_desc);\r
                draw_params.textures                            = std::move(item.textures);\r
                draw_params.transform                           = std::move(item.transform);\r
-               draw_params.blend_mode                          = blend_mode::normal;\r
 \r
                if(item.transform.is_key)\r
                {\r
@@ -198,7 +197,7 @@ private:
                        draw_params.local_key                   = std::move(local_key_buffer);\r
                        draw_params.layer_key                   = layer_key_buffer;\r
 \r
-                       draw_params.blend_mode                  = blend_mode::mix;\r
+                       draw_params.keyer                               = keyer::additive;\r
 \r
                        kernel_.draw(channel_.ogl(), std::move(draw_params));\r
                }\r
index 85ceb4cca1ccdd2e7bd1529a7155a6ea74f75dfe..6d89630c2c2da0a54a550ac7b2537109d1c1d3ca 100644 (file)
@@ -69,12 +69,15 @@ std::string get_blend_color_func()
        "                                                                                                                                                                       \n"                                                                                                                                                       \r
        "vec4 blend(vec4 fore)                                                                                                                          \n"\r
        "{                                                                                                                                                                      \n"\r
-       "   vec4 back = texture2D(background, gl_TexCoord[1].st).bgra;                                          \n"     \r
-       "                                                                                                                                                                       \n"             \r
-       "       if(blend_mode == 29) // mix                                                                                                             \n"\r
-       "               return fore + back;                                                                                                                     \n"\r
-       "                                                                                                                                                                       \n"             \r
+       "   vec4 back = texture2D(background, gl_TexCoord[1].st).bgra;                                          \n"             \r
        "       fore.rgb = get_blend_color(back.rgb, fore.rgb);                                                                 \n"\r
+       "                                                                                                                                                                       \n"             \r
+       "       switch(keyer)                                                                                                                                   \n"\r
+       "       {                                                                                                                                                               \n"\r
+       "               case 0: return fore + (1.0-fore.a)*back; // linear                                                      \n"\r
+       "               case 1: return fore + back; // additive                                                                         \n"\r
+       "       }                                                                                                                                                               \n"\r
+       "                                                                                                                                                                       \n"                                     \r
        "       return fore + (1.0-fore.a)*back;                                                                                                \n"\r
        "}                                                                                                                                                                      \n";                    \r
 }\r
@@ -119,7 +122,7 @@ std::string get_fragment(bool blend_modes)
        "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            keyer;                                                                                                                  \n"\r
        "uniform int            pixel_format;                                                                                                   \n"\r
        "                                                                                                                                                                       \n"\r
        "uniform float          opacity;                                                                                                                \n"\r