]> git.sesse.net Git - casparcg/blobdiff - accelerator/ogl/image/image_shader.cpp
[mixer] Merged fixed from 2.0 where contrast adjustment incorrectly worked on premult...
[casparcg] / accelerator / ogl / image / image_shader.cpp
index dfc47a0b2ef6675e79eb1e68129210ebc5032c9c..96753a5a4497ab7ccb6f70f46247fe823bd9a93f 100644 (file)
@@ -103,7 +103,7 @@ std::string get_blend_color_func()
                                }
                )shader";
 }
-               
+
 std::string get_simple_blend_color_func()
 {
        return
@@ -125,20 +125,13 @@ std::string get_chroma_func()
        return
 
                get_chroma_glsl()
-               
+
                +
-               
+
                R"shader(
                                vec4 chroma_key(vec4 c)
                                {
-                                       switch (chroma_mode)
-                                       {
-                                       case 0: return c;
-                                       case 1: return ChromaOnGreen(c.bgra).bgra;
-                                       case 2: return ChromaOnBlue(c.bgra).bgra;
-                                       }
-
-                                       return c;
+                                       return ChromaOnCustomColor(c.bgra).bgra;
                                }
                )shader";
 }
@@ -211,9 +204,14 @@ std::string get_fragment(bool blend_modes, bool post_processing)
                        uniform bool            straighten_alpha;
 
                        uniform bool            chroma;
-                       uniform int                     chroma_mode;
-                       uniform vec2            chroma_blend;
-                       uniform float           chroma_spill;
+                       uniform bool            chroma_show_mask;
+                       uniform float           chroma_target_hue;
+                       uniform float           chroma_hue_width;
+                       uniform float           chroma_min_saturation;
+                       uniform float           chroma_min_brightness;
+                       uniform float           chroma_softness;
+                       uniform float           chroma_spill_suppress;
+                       uniform float           chroma_spill_suppress_saturation;
        )shader"
 
        +
@@ -319,7 +317,7 @@ std::string get_fragment(bool blend_modes, bool post_processing)
                                        color.rgb /= color.a + 0.0000001;
 
                                return color;
-                       }       
+                       }
 
                        void main()
                        {
@@ -339,7 +337,7 @@ std::string get_fragment(bool blend_modes, bool post_processing)
                                        if(levels)
                                                color.rgb = LevelsControl(color.rgb, min_input, gamma, max_input, min_output, max_output);
                                        if(csb)
-                                               color.rgb = ContrastSaturationBrightness(color.rgb, brt, sat, con);
+                                               color.rgb = ContrastSaturationBrightness(color, brt, sat, con);
                                        if(has_local_key)
                                                color *= texture2D(local_key, gl_TexCoord[1].st).r;
                                        if(has_layer_key)
@@ -383,9 +381,9 @@ std::shared_ptr<shader> get_image_shader(
                                delete p;
                        });
        };
-               
+
        try
-       {                               
+       {
                g_blend_modes  = glTextureBarrierNV ? blend_modes_wanted : false;
                g_post_processing = straight_alpha_wanted;
                existing_shader.reset(new shader(get_vertex(), get_fragment(g_blend_modes, g_post_processing)), deleter);
@@ -394,7 +392,7 @@ std::shared_ptr<shader> get_image_shader(
        {
                CASPAR_LOG_CURRENT_EXCEPTION();
                CASPAR_LOG(warning) << "Failed to compile shader. Trying to compile without blend-modes.";
-                               
+
                g_blend_modes = false;
                existing_shader.reset(new shader(get_vertex(), get_fragment(g_blend_modes, g_post_processing)), deleter);
        }