diff --git a/effects/blending.frag b/effects/blending.frag new file mode 100644 index 000000000..132135c06 --- /dev/null +++ b/effects/blending.frag @@ -0,0 +1,29 @@ +const int BLEND_MODE_ADD = 0; +const int BLEND_MODE_AVERAGE = 1; +const int BLEND_MODE_COLORBURN = 2; +const int BLEND_MODE_COLORDODGE = 3; +const int BLEND_MODE_DARKEN = 4; +const int BLEND_MODE_DIFFERENCE = 5; +const int BLEND_MODE_EXCLUSION = 6; +const int BLEND_MODE_GLOW = 7; +const int BLEND_MODE_HARDLIGHT = 8; +const int BLEND_MODE_HARDMIX = 9; +const int BLEND_MODE_LIGHTEN = 10; +const int BLEND_MODE_LINEARBURN = 11; +const int BLEND_MODE_LINEARDODGE = 12; +const int BLEND_MODE_LINEARLIGHT = 13; +const int BLEND_MODE_MULTIPLY = 14; +const int BLEND_MODE_NEGATION = 15; +const int BLEND_MODE_NORMAL = 16; +const int BLEND_MODE_OVERLAY = 17; +const int BLEND_MODE_PHOENIX = 18; +const int BLEND_MODE_PINLIGHT = 19; +const int BLEND_MODE_REFLECT = 20; +const int BLEND_MODE_SCREEN = 21; +const int BLEND_MODE_SOFTLIGHT = 22; +const int BLEND_MODE_SUBSTRACT = 23; +const int BLEND_MODE_SUBTRACT = 24; +const int BLEND_MODE_VIVIDLIGHT = 25; + +void main(void) { +} \ No newline at end of file diff --git a/effects/internal/transformeffect.cpp b/effects/internal/transformeffect.cpp index b313e9298..8f22d0970 100644 --- a/effects/internal/transformeffect.cpp +++ b/effects/internal/transformeffect.cpp @@ -23,19 +23,14 @@ #include "panels/viewer.h" #include "ui/viewerwidget.h" -#define BLEND_MODE_NORMAL 0 -#define BLEND_MODE_SCREEN 1 -#define BLEND_MODE_MULTIPLY 2 -#define BLEND_MODE_OVERLAY 3 - TransformEffect::TransformEffect(Clip* c, const EffectMeta* em) : Effect(c, em) { enable_coords = true; - EffectRow* position_row = add_row(tr("Position")); + EffectRow* position_row = add_row(tr("Position")); position_x = position_row->add_field(EFFECT_FIELD_DOUBLE, "posx"); // position X position_y = position_row->add_field(EFFECT_FIELD_DOUBLE, "posy"); // position Y - EffectRow* scale_row = add_row(tr("Scale")); + EffectRow* scale_row = add_row(tr("Scale")); scale_x = scale_row->add_field(EFFECT_FIELD_DOUBLE, "scalex"); // scale X (and Y is uniform scale is selected) scale_x->set_double_minimum_value(0); scale_x->set_double_maximum_value(3000); @@ -43,27 +38,49 @@ TransformEffect::TransformEffect(Clip* c, const EffectMeta* em) : Effect(c, em) scale_y->set_double_minimum_value(0); scale_y->set_double_maximum_value(3000); - EffectRow* uniform_scale_row = add_row(tr("Uniform Scale")); + EffectRow* uniform_scale_row = add_row(tr("Uniform Scale")); uniform_scale_field = uniform_scale_row->add_field(EFFECT_FIELD_BOOL, "uniformscale"); // uniform scale option - EffectRow* rotation_row = add_row(tr("Rotation")); + EffectRow* rotation_row = add_row(tr("Rotation")); rotation = rotation_row->add_field(EFFECT_FIELD_DOUBLE, "rotation"); - EffectRow* anchor_point_row = add_row(tr("Anchor Point")); + EffectRow* anchor_point_row = add_row(tr("Anchor Point")); anchor_x_box = anchor_point_row->add_field(EFFECT_FIELD_DOUBLE, "anchorx"); // anchor point X anchor_y_box = anchor_point_row->add_field(EFFECT_FIELD_DOUBLE, "anchory"); // anchor point Y - EffectRow* opacity_row = add_row(tr("Opacity")); + EffectRow* opacity_row = add_row(tr("Opacity")); opacity = opacity_row->add_field(EFFECT_FIELD_DOUBLE, "opacity"); // opacity opacity->set_double_minimum_value(0); opacity->set_double_maximum_value(100); - EffectRow* blend_mode_row = add_row(tr("Blend Mode")); + EffectRow* blend_mode_row = add_row(tr("Blend Mode")); blend_mode_box = blend_mode_row->add_field(EFFECT_FIELD_COMBO, "blendmode"); // blend mode - blend_mode_box->add_combo_item(tr("Normal"), BLEND_MODE_NORMAL); - blend_mode_box->add_combo_item(tr("Overlay"), BLEND_MODE_OVERLAY); - blend_mode_box->add_combo_item(tr("Screen"), BLEND_MODE_SCREEN); - blend_mode_box->add_combo_item(tr("Multiply"), BLEND_MODE_MULTIPLY); + blend_mode_box->add_combo_item(tr("Normal"), BLEND_MODE_NORMAL); + blend_mode_box->add_combo_item(tr("Darken"), BLEND_MODE_DARKEN); + blend_mode_box->add_combo_item(tr("Multiply"), BLEND_MODE_MULTIPLY); + blend_mode_box->add_combo_item(tr("Color Burn"), BLEND_MODE_COLORBURN); + blend_mode_box->add_combo_item(tr("Linear Burn"), BLEND_MODE_LINEARBURN); + blend_mode_box->add_combo_item(tr("Lighten"), BLEND_MODE_LIGHTEN); + blend_mode_box->add_combo_item(tr("Screen"), BLEND_MODE_SCREEN); + blend_mode_box->add_combo_item(tr("Color Dodge"), BLEND_MODE_COLORDODGE); + blend_mode_box->add_combo_item(tr("Linear Dodge"), BLEND_MODE_LINEARDODGE); + blend_mode_box->add_combo_item(tr("Overlay"), BLEND_MODE_OVERLAY); + blend_mode_box->add_combo_item(tr("Soft Light"), BLEND_MODE_SOFTLIGHT); + blend_mode_box->add_combo_item(tr("Hard Light"), BLEND_MODE_HARDLIGHT); + blend_mode_box->add_combo_item(tr("Vivid Light"), BLEND_MODE_VIVIDLIGHT); + blend_mode_box->add_combo_item(tr("Linear Light"), BLEND_MODE_LINEARLIGHT); + blend_mode_box->add_combo_item(tr("Pin Light"), BLEND_MODE_PINLIGHT); + blend_mode_box->add_combo_item(tr("Hard Mix"), BLEND_MODE_HARDMIX); + blend_mode_box->add_combo_item(tr("Difference"), BLEND_MODE_DIFFERENCE); + blend_mode_box->add_combo_item(tr("Exclusion"), BLEND_MODE_EXCLUSION); + blend_mode_box->add_combo_item(tr("Reflect"), BLEND_MODE_REFLECT); + blend_mode_box->add_combo_item(tr("Subtract"), BLEND_MODE_SUBTRACT); + blend_mode_box->add_combo_item(tr("Substract"), BLEND_MODE_SUBSTRACT); + blend_mode_box->add_combo_item(tr("Add"), BLEND_MODE_ADD); + blend_mode_box->add_combo_item(tr("Average"), BLEND_MODE_AVERAGE); + blend_mode_box->add_combo_item(tr("Glow"), BLEND_MODE_GLOW); + blend_mode_box->add_combo_item(tr("Negation"), BLEND_MODE_NEGATION); + blend_mode_box->add_combo_item(tr("Phoenix"), BLEND_MODE_PHOENIX); // set up gizmos top_left_gizmo = add_gizmo(GIZMO_TYPE_DOT); @@ -211,7 +228,8 @@ void TransformEffect::process_coords(double timecode, GLTextureCoords& coords, i glScalef(sx, sy, 1); // blend mode - switch (blend_mode_box->get_combo_data(timecode).toInt()) { + coords.blendmode = blend_mode_box->get_combo_data(timecode).toInt(); + /*switch (blend_mode_box->get_combo_data(timecode).toInt()) { case BLEND_MODE_NORMAL: glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); break; @@ -226,12 +244,13 @@ void TransformEffect::process_coords(double timecode, GLTextureCoords& coords, i break; default: qCritical() << "Invalid blend mode. This is a bug - please contact developers"; - } + }*/ // opacity - float color[4]; + coords.opacity *= opacity->get_double_value(timecode)*0.01; + /*float color[4]; glGetFloatv(GL_CURRENT_COLOR, color); - glColor4f(1.0, 1.0, 1.0, color[3]*(opacity->get_double_value(timecode)*0.01)); + glColor4f(1.0, 1.0, 1.0, color[3]*(opacity->get_double_value(timecode)*0.01));*/ } void TransformEffect::gizmo_draw(double, GLTextureCoords& coords) { diff --git a/project/effect.h b/project/effect.h index 6779501c4..f571a56df 100644 --- a/project/effect.h +++ b/project/effect.h @@ -74,6 +74,36 @@ enum EffectInternal { EFFECT_INTERNAL_COUNT }; +enum EffectBlendMode { + BLEND_MODE_ADD, + BLEND_MODE_AVERAGE, + BLEND_MODE_COLORBURN, + BLEND_MODE_COLORDODGE, + BLEND_MODE_DARKEN, + BLEND_MODE_DIFFERENCE, + BLEND_MODE_EXCLUSION, + BLEND_MODE_GLOW, + BLEND_MODE_HARDLIGHT, + BLEND_MODE_HARDMIX, + BLEND_MODE_LIGHTEN, + BLEND_MODE_LINEARBURN, + BLEND_MODE_LINEARDODGE, + BLEND_MODE_LINEARLIGHT, + BLEND_MODE_MULTIPLY, + BLEND_MODE_NEGATION, + BLEND_MODE_NORMAL, + BLEND_MODE_OVERLAY, + BLEND_MODE_PHOENIX, + BLEND_MODE_PINLIGHT, + BLEND_MODE_REFLECT, + BLEND_MODE_SCREEN, + BLEND_MODE_SOFTLIGHT, + BLEND_MODE_SUBSTRACT, + BLEND_MODE_SUBTRACT, + BLEND_MODE_VIVIDLIGHT, + BLEND_MODE_COUNT +}; + struct GLTextureCoords { int grid_size; @@ -102,6 +132,9 @@ struct GLTextureCoords { float textureBottomLeftX; float textureBottomLeftY; float textureBottomLeftQ; + + int blendmode; + double opacity; }; qint16 mix_audio_sample(qint16 a, qint16 b); @@ -159,7 +192,7 @@ public: const char* ffmpeg_filter; - virtual void process_image(double timecode, uint8_t* input, uint8_t* output, int size); + virtual void process_image(double timecode, uint8_t* input, uint8_t* output, int size); virtual void process_shader(double timecode, GLTextureCoords&); virtual void process_coords(double timecode, GLTextureCoords& coords, int data); virtual GLuint process_superimpose(double timecode); diff --git a/ui/renderfunctions.cpp b/ui/renderfunctions.cpp index 2546392cd..aab4b4c49 100644 --- a/ui/renderfunctions.cpp +++ b/ui/renderfunctions.cpp @@ -335,6 +335,9 @@ GLuint compose_sequence(Viewer* viewer, glBegin(GL_QUADS); + QOpenGLShaderProgram program; + program.bind(); + if (coords.grid_size <= 1) { float z = 0.0f; @@ -379,6 +382,8 @@ GLuint compose_sequence(Viewer* viewer, } } + program.release(); + glEnd(); glBindTexture(GL_TEXTURE_2D, 0); // unbind texture