\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
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
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
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
" \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
"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