added perspective option to corner pin
This commit is contained in:
@@ -0,0 +1,9 @@
|
||||
#version 110
|
||||
|
||||
uniform sampler2D tex;
|
||||
varying vec2 vTexCoord;
|
||||
|
||||
void main(void) {
|
||||
vec4 textureColor = texture2D(tex, vec2(vTexCoord.x, vTexCoord.y));
|
||||
gl_FragColor = textureColor;
|
||||
}
|
||||
@@ -0,0 +1,46 @@
|
||||
#version 110
|
||||
|
||||
uniform sampler2D tex;
|
||||
uniform bool perspective;
|
||||
|
||||
varying vec2 q;
|
||||
varying vec2 b1;
|
||||
varying vec2 b2;
|
||||
varying vec2 b3;
|
||||
varying vec2 vTexCoord;
|
||||
|
||||
float Wedge2D(vec2 v, vec2 w) {
|
||||
return (v.x*w.y) - (v.y*w.x);
|
||||
}
|
||||
|
||||
void main(void) {
|
||||
if (perspective) {
|
||||
gl_FragColor = texture2D(tex, vTexCoord);
|
||||
} else {
|
||||
float A = Wedge2D(b2, b3);
|
||||
float B = Wedge2D(b3, q) - Wedge2D(b1, b2);
|
||||
float C = Wedge2D(b1, q);
|
||||
|
||||
vec2 uv;
|
||||
|
||||
// solve for v
|
||||
if (abs(A) < 0.001) {
|
||||
uv.y = -C/B;
|
||||
} else {
|
||||
float discrim = B*B - 4.0*A*C;
|
||||
uv.y = 0.5 * (-B + sqrt(discrim)) / A;
|
||||
}
|
||||
|
||||
// solve for u
|
||||
vec2 denom = b1 + uv.y * b3;
|
||||
if (abs(denom.x) > abs(denom.y)) {
|
||||
uv.x = (q.x - b2.x * uv.y) / denom.x;
|
||||
} else {
|
||||
uv.x = (q.y - b2.y * uv.y) / denom.y;
|
||||
}
|
||||
|
||||
uv.y = 1.0 - uv.y;
|
||||
|
||||
gl_FragColor = texture2D(tex, uv);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,60 @@
|
||||
#version 110
|
||||
#extension GL_EXT_gpu_shader4 : enable
|
||||
|
||||
uniform bool perspective;
|
||||
uniform vec2 p0;
|
||||
uniform vec2 p1;
|
||||
uniform vec2 p2;
|
||||
uniform vec2 p3;
|
||||
|
||||
varying vec2 q;
|
||||
varying vec2 b1;
|
||||
varying vec2 b2;
|
||||
varying vec2 b3;
|
||||
varying vec2 vTexCoord;
|
||||
|
||||
void main() {
|
||||
gl_Position = gl_ModelViewProjectionMatrix * gl_Vertex;
|
||||
|
||||
if (perspective) {
|
||||
float m1 = (p3.y - p0.y)/(p3.x - p0.x);
|
||||
float c1 = p0.y - m1 * p0.x;
|
||||
float m2 = (p1.y - p2.y)/(p1.x - p2.x);
|
||||
float c2 = p2.y - m2 * p2.x;
|
||||
float mid_x = (c2 - c1) / (m1 - m2);
|
||||
float mid_y = m1 * mid_x + c1;
|
||||
|
||||
float d0 = sqrt(pow(mid_x - p0.x, 2.0) + pow(mid_y - p0.y, 2.0));
|
||||
float d1 = sqrt(pow(p1.x - mid_x, 2.0) + pow(mid_y - p1.y, 2.0));
|
||||
float d2 = sqrt(pow(p3.x - mid_x, 2.0) + pow(p3.y - mid_y, 2.0));
|
||||
float d3 = sqrt(pow(mid_x - p2.x, 2.0) + pow(p2.y - mid_y, 2.0));
|
||||
|
||||
float q;
|
||||
|
||||
switch (gl_VertexID) {
|
||||
case 0: q = (d1+d3)/d3; break;
|
||||
case 1: q = (d0+d2)/d2; break;
|
||||
case 2: q = (d3+d1)/d1; break;
|
||||
case 3: q = (d2+d0)/d0; break;
|
||||
}
|
||||
|
||||
gl_Position[0] *= q;
|
||||
gl_Position[1] *= q;
|
||||
gl_Position[3] = q;
|
||||
|
||||
vTexCoord = gl_MultiTexCoord0.xy;
|
||||
} else {
|
||||
vec2 pos;
|
||||
switch (gl_VertexID) {
|
||||
case 0: pos = p2; break; // top left
|
||||
case 1: pos = p3; break; // top right
|
||||
case 2: pos = p1; break; // bottom right
|
||||
case 3: pos = p0; break; // bottom left
|
||||
}
|
||||
|
||||
q = pos - p0;
|
||||
b1 = p1 - p0;
|
||||
b2 = p2 - p0;
|
||||
b3 = p0 - p1 - p2 + p3;
|
||||
}
|
||||
}
|
||||
-1468
File diff suppressed because it is too large
Load Diff
@@ -1,293 +0,0 @@
|
||||
#ifndef EFFECT_H
|
||||
#define EFFECT_H
|
||||
|
||||
#include <QObject>
|
||||
#include <QString>
|
||||
#include <QVector>
|
||||
#include <QColor>
|
||||
#include <QOpenGLFunctions>
|
||||
#include <QOpenGLShaderProgram>
|
||||
#include <QOpenGLTexture>
|
||||
#include <QMutex>
|
||||
#include <QThread>
|
||||
class QLabel;
|
||||
class QWidget;
|
||||
class CollapsibleWidget;
|
||||
class QGridLayout;
|
||||
class QPushButton;
|
||||
|
||||
struct Clip;
|
||||
class QXmlStreamReader;
|
||||
class QXmlStreamWriter;
|
||||
class Effect;
|
||||
class EffectRow;
|
||||
class CheckboxEx;
|
||||
class KeyframeDelete;
|
||||
|
||||
struct EffectMeta {
|
||||
QString name;
|
||||
QString category;
|
||||
QString filename;
|
||||
int internal;
|
||||
int type;
|
||||
};
|
||||
|
||||
extern QVector<EffectMeta> video_effects;
|
||||
extern QVector<EffectMeta> audio_effects;
|
||||
|
||||
double log_volume(double linear);
|
||||
void init_effects();
|
||||
Effect* create_effect(Clip* c, const EffectMeta *em);
|
||||
const EffectMeta* get_internal_meta(int internal_id);
|
||||
|
||||
extern QMutex effects_loaded;
|
||||
|
||||
#define EFFECT_TYPE_INVALID 0
|
||||
#define EFFECT_TYPE_VIDEO 1
|
||||
#define EFFECT_TYPE_AUDIO 2
|
||||
#define EFFECT_TYPE_EFFECT 3
|
||||
#define EFFECT_TYPE_TRANSITION 4
|
||||
|
||||
#define EFFECT_FIELD_DOUBLE 0
|
||||
#define EFFECT_FIELD_COLOR 1
|
||||
#define EFFECT_FIELD_STRING 2
|
||||
#define EFFECT_FIELD_BOOL 3
|
||||
#define EFFECT_FIELD_COMBO 4
|
||||
#define EFFECT_FIELD_FONT 5
|
||||
|
||||
#define EFFECT_KEYFRAME_LINEAR 0
|
||||
#define EFFECT_KEYFRAME_HOLD 1
|
||||
#define EFFECT_KEYFRAME_BEZIER 2
|
||||
|
||||
#define EFFECT_INTERNAL_TRANSFORM 0
|
||||
#define EFFECT_INTERNAL_TEXT 1
|
||||
#define EFFECT_INTERNAL_SOLID 2
|
||||
#define EFFECT_INTERNAL_NOISE 3
|
||||
#define EFFECT_INTERNAL_VOLUME 4
|
||||
#define EFFECT_INTERNAL_PAN 5
|
||||
#define EFFECT_INTERNAL_TONE 6
|
||||
#define EFFECT_INTERNAL_SHAKE 7
|
||||
#define EFFECT_INTERNAL_CROSSDISSOLVE 8
|
||||
#define EFFECT_INTERNAL_LINEARFADE 9
|
||||
#define EFFECT_INTERNAL_EXPONENTIALFADE 10
|
||||
#define EFFECT_INTERNAL_LOGARITHMICFADE 11
|
||||
#define EFFECT_INTERNAL_CORNERPIN 12
|
||||
#define EFFECT_INTERNAL_COUNT 13
|
||||
|
||||
#define KEYFRAME_TYPE_LINEAR 0
|
||||
#define KEYFRAME_TYPE_SMOOTH 1
|
||||
#define KEYFRAME_TYPE_BEZIER 2
|
||||
|
||||
#define TRAN_TYPE_OPEN 1
|
||||
#define TRAN_TYPE_CLOSE 2
|
||||
#define TRAN_TYPE_OPENWLINK 3
|
||||
#define TRAN_TYPE_CLOSEWLINK 4
|
||||
|
||||
struct GLTextureCoords {
|
||||
int grid_size;
|
||||
|
||||
int vertexTopLeftX;
|
||||
int vertexTopLeftY;
|
||||
int vertexTopRightX;
|
||||
int vertexTopRightY;
|
||||
int vertexBottomLeftX;
|
||||
int vertexBottomLeftY;
|
||||
int vertexBottomRightX;
|
||||
int vertexBottomRightY;
|
||||
|
||||
double textureTopLeftX;
|
||||
double textureTopLeftY;
|
||||
double textureTopRightX;
|
||||
double textureTopRightY;
|
||||
double textureBottomRightX;
|
||||
double textureBottomRightY;
|
||||
double textureBottomLeftX;
|
||||
double textureBottomLeftY;
|
||||
};
|
||||
|
||||
qint16 mix_audio_sample(qint16 a, qint16 b);
|
||||
|
||||
class EffectField : public QObject {
|
||||
Q_OBJECT
|
||||
public:
|
||||
EffectField(EffectRow* parent, int t);
|
||||
EffectRow* parent_row;
|
||||
int type;
|
||||
QString id;
|
||||
|
||||
QVariant get_previous_data();
|
||||
QVariant get_current_data();
|
||||
double frameToTimecode(long frame);
|
||||
long timecodeToFrame(double timecode);
|
||||
void set_current_data(const QVariant&);
|
||||
void get_keyframe_data(double timecode, int& before, int& after, double& d);
|
||||
QVariant validate_keyframe_data(double timecode, bool async = false);
|
||||
|
||||
double get_double_value(double timecode, bool async = false);
|
||||
void set_double_value(double v);
|
||||
void set_double_default_value(double v);
|
||||
void set_double_minimum_value(double v);
|
||||
void set_double_maximum_value(double v);
|
||||
|
||||
const QString get_string_value(double timecode, bool async = false);
|
||||
void set_string_value(const QString &s);
|
||||
|
||||
void add_combo_item(const QString& name, const QVariant &data);
|
||||
int get_combo_index(double timecode, bool async = false);
|
||||
const QVariant get_combo_data(double timecode);
|
||||
const QString get_combo_string(double timecode);
|
||||
void set_combo_index(int index);
|
||||
void set_combo_string(const QString& s);
|
||||
|
||||
bool get_bool_value(double timecode, bool async = false);
|
||||
void set_bool_value(bool b);
|
||||
|
||||
const QString get_font_name(double timecode, bool async = false);
|
||||
void set_font_name(const QString& s);
|
||||
|
||||
QColor get_color_value(double timecode, bool async = false);
|
||||
void set_color_value(QColor color);
|
||||
|
||||
QWidget* get_ui_element();
|
||||
void set_enabled(bool e);
|
||||
QVector<QVariant> keyframe_data;
|
||||
QWidget* ui_element;
|
||||
private:
|
||||
bool hasKeyframes();
|
||||
private slots:
|
||||
void uiElementChange();
|
||||
signals:
|
||||
void changed();
|
||||
void toggled(bool);
|
||||
};
|
||||
|
||||
class EffectRow : public QObject {
|
||||
Q_OBJECT
|
||||
public:
|
||||
EffectRow(Effect* parent, QGridLayout* uilayout, const QString& n, int row);
|
||||
~EffectRow();
|
||||
EffectField* add_field(int type, int colspan = 1);
|
||||
EffectField* field(int i);
|
||||
int fieldCount();
|
||||
void set_keyframe_now(bool undoable);
|
||||
void delete_keyframe(KeyframeDelete *kd, int index);
|
||||
void delete_keyframe_at_time(KeyframeDelete* kd, long time);
|
||||
QLabel* label;
|
||||
Effect* parent_effect;
|
||||
|
||||
bool isKeyframing();
|
||||
void setKeyframing(bool);
|
||||
|
||||
QVector<long> keyframe_times;
|
||||
QVector<int> keyframe_types;
|
||||
private slots:
|
||||
void set_keyframe_enabled(bool);
|
||||
void keyframe_ui_enabled(bool);
|
||||
void goto_previous_key();
|
||||
void toggle_key();
|
||||
void goto_next_key();
|
||||
private:
|
||||
bool keyframing;
|
||||
QGridLayout* ui;
|
||||
QString name;
|
||||
int ui_row;
|
||||
QVector<EffectField*> fields;
|
||||
|
||||
QPushButton* keyframe_enable;
|
||||
QPushButton* left_key_nav;
|
||||
QPushButton* key_addremove;
|
||||
QPushButton* right_key_nav;
|
||||
|
||||
bool just_made_unsafe_keyframe;
|
||||
};
|
||||
|
||||
class Effect : public QObject {
|
||||
Q_OBJECT
|
||||
public:
|
||||
Effect(Clip* c, const EffectMeta* em);
|
||||
~Effect();
|
||||
Clip* parent_clip;
|
||||
const EffectMeta* meta;
|
||||
int id;
|
||||
QString name;
|
||||
CollapsibleWidget* container;
|
||||
|
||||
long length; // only used for transitions
|
||||
Effect* tlink;
|
||||
|
||||
EffectRow* add_row(const QString &name);
|
||||
EffectRow* row(int i);
|
||||
int row_count();
|
||||
|
||||
bool is_enabled();
|
||||
void set_enabled(bool b);
|
||||
|
||||
virtual void refresh();
|
||||
|
||||
Effect* copy(Clip* c);
|
||||
void copy_field_keyframes(Effect *e);
|
||||
|
||||
void load(QXmlStreamReader& stream);
|
||||
void save(QXmlStreamWriter& stream);
|
||||
|
||||
// glsl handling
|
||||
void open();
|
||||
void close();
|
||||
virtual void startEffect();
|
||||
virtual void endEffect();
|
||||
|
||||
bool enable_shader;
|
||||
bool enable_coords;
|
||||
bool enable_superimpose;
|
||||
|
||||
int getIterations();
|
||||
void setIterations(int i);
|
||||
|
||||
const char* ffmpeg_filter;
|
||||
|
||||
void process_shader(double timecode);
|
||||
virtual void process_coords(double timecode, GLTextureCoords& coords);
|
||||
virtual GLuint process_superimpose(double timecode);
|
||||
virtual void process_audio(double timecode_start, double timecode_end, quint8* samples, int nb_bytes, int channel_count);
|
||||
public slots:
|
||||
void field_changed();
|
||||
private slots:
|
||||
void show_context_menu(const QPoint&);
|
||||
void delete_self();
|
||||
void move_up();
|
||||
void move_down();
|
||||
protected:
|
||||
// glsl effect
|
||||
QOpenGLShaderProgram* glslProgram;
|
||||
QString vertPath;
|
||||
QString fragPath;
|
||||
|
||||
// superimpose effect
|
||||
QImage img;
|
||||
QOpenGLTexture* texture;
|
||||
private:
|
||||
// superimpose effect
|
||||
QString script;
|
||||
|
||||
bool isOpen;
|
||||
QVector<EffectRow*> rows;
|
||||
QGridLayout* ui_layout;
|
||||
QWidget* ui;
|
||||
bool bound;
|
||||
|
||||
// superimpose functions
|
||||
virtual void redraw(double timecode);
|
||||
bool valueHasChanged(double timecode);
|
||||
QVector<QVariant> cachedValues;
|
||||
void delete_texture();
|
||||
int get_index_in_clip();
|
||||
};
|
||||
|
||||
class EffectInit : public QThread {
|
||||
public:
|
||||
EffectInit();
|
||||
protected:
|
||||
void run();
|
||||
};
|
||||
|
||||
#endif // EFFECT_H
|
||||
@@ -1,14 +0,0 @@
|
||||
#version 110
|
||||
|
||||
uniform sampler2D myTexture;
|
||||
varying vec2 vTexCoord;
|
||||
|
||||
void main(void) {
|
||||
vec4 textureColor = texture2D(myTexture, vec2(vTexCoord.x, vTexCoord.y));
|
||||
gl_FragColor = vec4(
|
||||
textureColor.r,
|
||||
textureColor.g,
|
||||
textureColor.b,
|
||||
textureColor.a
|
||||
);
|
||||
}
|
||||
@@ -1,16 +0,0 @@
|
||||
#version 110
|
||||
|
||||
uniform mediump float amount;
|
||||
uniform sampler2D myTexture;
|
||||
varying vec2 vTexCoord;
|
||||
|
||||
void main(void) {
|
||||
vec4 textureColor = texture2D(myTexture, vTexCoord);
|
||||
float amount_val = amount * 0.01;
|
||||
gl_FragColor = vec4(
|
||||
textureColor.r+((1.0-textureColor.r-textureColor.r)*amount_val),
|
||||
textureColor.g+((1.0-textureColor.g-textureColor.g)*amount_val),
|
||||
textureColor.b+((1.0-textureColor.b-textureColor.b)*amount_val),
|
||||
textureColor.a
|
||||
);
|
||||
}
|
||||
@@ -0,0 +1,121 @@
|
||||
#version 110
|
||||
|
||||
uniform vec2 resolution;
|
||||
|
||||
vec3 mod289(vec3 x) {
|
||||
return x - floor(x * (1.0 / 289.0)) * 289.0;
|
||||
}
|
||||
|
||||
vec4 mod289(vec4 x) {
|
||||
return x - floor(x * (1.0 / 289.0)) * 289.0;
|
||||
}
|
||||
|
||||
vec4 permute(vec4 x) {
|
||||
return mod289(((x * 34.0) + 1.0) * x);
|
||||
}
|
||||
|
||||
vec4 taylorInvSqrt(vec4 r) {
|
||||
return 1.79284291400159 - 0.85373472095314 * r;
|
||||
}
|
||||
|
||||
vec3 fade(vec3 t) {
|
||||
return t * t * t * (t * (t * 6.0 - 15.0) + 10.0);
|
||||
}
|
||||
|
||||
float noise(vec3 P) {
|
||||
vec3 Pi0 = floor(P),
|
||||
Pi1 = Pi0 + vec3(1.0);
|
||||
|
||||
Pi0 = mod289(Pi0);
|
||||
Pi1 = mod289(Pi1);
|
||||
|
||||
vec3 Pf0 = fract(P),
|
||||
Pf1 = Pf0 - vec3(1.0);
|
||||
|
||||
vec4 ix = vec4(Pi0.x, Pi1.x, Pi0.x, Pi1.x),
|
||||
iy = vec4(Pi0.yy, Pi1.yy),
|
||||
iz0 = Pi0.zzzz,
|
||||
iz1 = Pi1.zzzz,
|
||||
ixy = permute(permute(ix) + iy),
|
||||
ixy0 = permute(ixy + iz0),
|
||||
ixy1 = permute(ixy + iz1),
|
||||
gx0 = ixy0 * (1.0 / 7.0),
|
||||
gy0 = fract(floor(gx0) * (1.0 / 7.0)) - 0.5;
|
||||
|
||||
gx0 = fract(gx0);
|
||||
|
||||
vec4 gz0 = vec4(0.5) - abs(gx0) - abs(gy0),
|
||||
sz0 = step(gz0, vec4(0.0));
|
||||
|
||||
gx0 -= sz0 * (step(0.0, gx0) - 0.5);
|
||||
gy0 -= sz0 * (step(0.0, gy0) - 0.5);
|
||||
|
||||
vec4 gx1 = ixy1 * (1.0 / 7.0),
|
||||
gy1 = fract(floor(gx1) * (1.0 / 7.0)) - 0.5;
|
||||
|
||||
gx1 = fract(gx1);
|
||||
|
||||
vec4 gz1 = vec4(0.5) - abs(gx1) - abs(gy1),
|
||||
sz1 = step(gz1, vec4(0.0));
|
||||
|
||||
gx1 -= sz1 * (step(0.0, gx1) - 0.5);
|
||||
gy1 -= sz1 * (step(0.0, gy1) - 0.5);
|
||||
|
||||
vec3 g000 = vec3(gx0.x, gy0.x, gz0.x),
|
||||
g100 = vec3(gx0.y, gy0.y, gz0.y),
|
||||
g010 = vec3(gx0.z, gy0.z, gz0.z),
|
||||
g110 = vec3(gx0.w, gy0.w, gz0.w),
|
||||
g001 = vec3(gx1.x, gy1.x, gz1.x),
|
||||
g101 = vec3(gx1.y, gy1.y, gz1.y),
|
||||
g011 = vec3(gx1.z, gy1.z, gz1.z),
|
||||
g111 = vec3(gx1.w, gy1.w, gz1.w);
|
||||
|
||||
vec4 norm0 = taylorInvSqrt(vec4(dot(g000, g000), dot(g010, g010), dot(g100, g100), dot(g110, g110)));
|
||||
g000 *= norm0.x;
|
||||
g010 *= norm0.y;
|
||||
g100 *= norm0.z;
|
||||
g110 *= norm0.w;
|
||||
|
||||
vec4 norm1 = taylorInvSqrt(vec4(dot(g001, g001), dot(g011, g011), dot(g101, g101), dot(g111, g111)));
|
||||
g001 *= norm1.x;
|
||||
g011 *= norm1.y;
|
||||
g101 *= norm1.z;
|
||||
g111 *= norm1.w;
|
||||
|
||||
float n000 = dot(g000, Pf0),
|
||||
n100 = dot(g100, vec3(Pf1.x, Pf0.yz)),
|
||||
n010 = dot(g010, vec3(Pf0.x, Pf1.y, Pf0.z)),
|
||||
n110 = dot(g110, vec3(Pf1.xy, Pf0.z)),
|
||||
n001 = dot(g001, vec3(Pf0.xy, Pf1.z)),
|
||||
n101 = dot(g101, vec3(Pf1.x, Pf0.y, Pf1.z)),
|
||||
n011 = dot(g011, vec3(Pf0.x, Pf1.yz)),
|
||||
n111 = dot(g111, Pf1);
|
||||
|
||||
vec3 fade_xyz = fade(Pf0);
|
||||
vec4 n_z = mix(vec4(n000, n100, n010, n110), vec4(n001, n101, n011, n111), fade_xyz.z);
|
||||
vec2 n_yz = mix(n_z.xy, n_z.zw, fade_xyz.y);
|
||||
|
||||
return mix(n_yz.x, n_yz.y, fade_xyz.x);
|
||||
}
|
||||
|
||||
void main( void ) {
|
||||
float time = 2.0;
|
||||
vec2 noiseFactor = vec2(2.0, 2.0);
|
||||
float noiseFactorTime = 2.0;
|
||||
|
||||
vec2 p = gl_FragCoord.xy / resolution.y;
|
||||
//p *= vec2(800, 600);
|
||||
//p += mouse * 1.0;
|
||||
//float z = 1.0;
|
||||
//float speed = 1.0;
|
||||
|
||||
//p.y += time * 0.1;
|
||||
|
||||
vec2 nx = vec2(p.x * noiseFactor.x, p.y * noiseFactor.y);
|
||||
|
||||
float v = noise(vec3(nx, time * noiseFactorTime) * 3.0) * 6.28318531;
|
||||
v = v * 0.15 + 0.5;
|
||||
|
||||
gl_FragColor = vec4(vec3(v), 1.0);
|
||||
|
||||
}
|
||||
@@ -0,0 +1,7 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<effect name="Find Edges" category="Color">
|
||||
<row name="Bypass">
|
||||
<field type="bool" default="0" id="amount"/>
|
||||
</row>
|
||||
<shader vert="common.vert" frag="findedges.frag"/>
|
||||
</effect>
|
||||
@@ -1,7 +1,7 @@
|
||||
#ifndef AUDIONOISEEFFECT_H
|
||||
#define AUDIONOISEEFFECT_H
|
||||
|
||||
#include "../effect.h"
|
||||
#include "project/effect.h"
|
||||
|
||||
class AudioNoiseEffect : public Effect {
|
||||
public:
|
||||
|
||||
@@ -1,7 +1,12 @@
|
||||
#include "cornerpineffect.h"
|
||||
|
||||
#include "io/path.h"
|
||||
#include "project/clip.h"
|
||||
#include "debug.h"
|
||||
|
||||
CornerPinEffect::CornerPinEffect(Clip *c, const EffectMeta *em) : Effect(c, em) {
|
||||
enable_coords = true;
|
||||
enable_shader = true;
|
||||
|
||||
EffectRow* top_left = add_row("Top Left:");
|
||||
top_left_x = top_left->add_field(EFFECT_FIELD_DOUBLE);
|
||||
@@ -27,6 +32,9 @@ CornerPinEffect::CornerPinEffect(Clip *c, const EffectMeta *em) : Effect(c, em)
|
||||
bottom_right_y = bottom_right->add_field(EFFECT_FIELD_DOUBLE);
|
||||
bottom_right_y->id = "bottomrighty";
|
||||
|
||||
perspective = add_row("Perspective:")->add_field(EFFECT_FIELD_BOOL);
|
||||
perspective->set_bool_value(false);
|
||||
|
||||
connect(top_left_x, SIGNAL(changed()), this, SLOT(field_changed()));
|
||||
connect(top_left_y, SIGNAL(changed()), this, SLOT(field_changed()));
|
||||
connect(top_right_x, SIGNAL(changed()), this, SLOT(field_changed()));
|
||||
@@ -35,6 +43,10 @@ CornerPinEffect::CornerPinEffect(Clip *c, const EffectMeta *em) : Effect(c, em)
|
||||
connect(bottom_left_y, SIGNAL(changed()), this, SLOT(field_changed()));
|
||||
connect(bottom_right_x, SIGNAL(changed()), this, SLOT(field_changed()));
|
||||
connect(bottom_right_y, SIGNAL(changed()), this, SLOT(field_changed()));
|
||||
connect(perspective, SIGNAL(changed()), this, SLOT(field_changed()));
|
||||
|
||||
vertPath = "cornerpin.vert";
|
||||
fragPath = "cornerpin.frag";
|
||||
}
|
||||
|
||||
void CornerPinEffect::process_coords(double timecode, GLTextureCoords &coords) {
|
||||
@@ -48,5 +60,13 @@ void CornerPinEffect::process_coords(double timecode, GLTextureCoords &coords) {
|
||||
coords.vertexBottomLeftY += bottom_left_y->get_double_value(timecode);
|
||||
|
||||
coords.vertexBottomRightX += bottom_right_x->get_double_value(timecode);
|
||||
coords.vertexBottomRightY += bottom_right_y->get_double_value(timecode);
|
||||
coords.vertexBottomRightY += bottom_right_y->get_double_value(timecode);
|
||||
}
|
||||
|
||||
void CornerPinEffect::process_shader(double timecode, GLTextureCoords &coords) {
|
||||
glslProgram->setUniformValue("p0", (GLfloat) coords.vertexBottomLeftX, (GLfloat) coords.vertexBottomLeftY);
|
||||
glslProgram->setUniformValue("p1", (GLfloat) coords.vertexBottomRightX, (GLfloat) coords.vertexBottomRightY);
|
||||
glslProgram->setUniformValue("p2", (GLfloat) coords.vertexTopLeftX, (GLfloat) coords.vertexTopLeftY);
|
||||
glslProgram->setUniformValue("p3", (GLfloat) coords.vertexTopRightX, (GLfloat) coords.vertexTopRightY);
|
||||
glslProgram->setUniformValue("perspective", perspective->get_bool_value(timecode));
|
||||
}
|
||||
|
||||
@@ -1,13 +1,14 @@
|
||||
#ifndef CORNERPINEFFECT_H
|
||||
#define CORNERPINEFFECT_H
|
||||
|
||||
#include "../effect.h"
|
||||
#include "project/effect.h"
|
||||
|
||||
class CornerPinEffect : public Effect {
|
||||
Q_OBJECT
|
||||
public:
|
||||
CornerPinEffect(Clip* c, const EffectMeta* em);
|
||||
void process_coords(double timecode, GLTextureCoords& coords);
|
||||
void process_coords(double timecode, GLTextureCoords& coords);
|
||||
void process_shader(double timecode, GLTextureCoords& coords);
|
||||
private:
|
||||
EffectField* top_left_x;
|
||||
EffectField* top_left_y;
|
||||
@@ -17,6 +18,7 @@ private:
|
||||
EffectField* bottom_left_y;
|
||||
EffectField* bottom_right_x;
|
||||
EffectField* bottom_right_y;
|
||||
EffectField* perspective;
|
||||
};
|
||||
|
||||
#endif // CORNERPINEFFECT_H
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
#ifndef CROSSDISSOLVETRANSITION_H
|
||||
#define CROSSDISSOLVETRANSITION_H
|
||||
|
||||
#include "../effect.h"
|
||||
#include "project/effect.h"
|
||||
|
||||
class CrossDissolveTransition : public Effect {
|
||||
public:
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
#ifndef EXPONENTIALFADETRANSITION_H
|
||||
#define EXPONENTIALFADETRANSITION_H
|
||||
|
||||
#include "../effect.h"
|
||||
#include "project/effect.h"
|
||||
|
||||
class ExponentialFadeTransition : public Effect {
|
||||
public:
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
#ifndef LINEARFADETRANSITION_H
|
||||
#define LINEARFADETRANSITION_H
|
||||
|
||||
#include "../effect.h"
|
||||
#include "project/effect.h"
|
||||
|
||||
class LinearFadeTransition : public Effect {
|
||||
public:
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
#ifndef LOGARITHMICFADETRANSITION_H
|
||||
#define LOGARITHMICFADETRANSITION_H
|
||||
|
||||
#include "../effect.h"
|
||||
#include "project/effect.h"
|
||||
|
||||
class LogarithmicFadeTransition : public Effect {
|
||||
public:
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
#ifndef PANEFFECT_H
|
||||
#define PANEFFECT_H
|
||||
|
||||
#include "../effect.h"
|
||||
#include "project/effect.h"
|
||||
|
||||
class PanEffect : public Effect {
|
||||
public:
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
#ifndef SHAKEEFFECT_H
|
||||
#define SHAKEEFFECT_H
|
||||
|
||||
#include "../effect.h"
|
||||
#include "project/effect.h"
|
||||
|
||||
#define RANDOM_VAL_SIZE 30
|
||||
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
#ifndef SOLIDEFFECT_H
|
||||
#define SOLIDEFFECT_H
|
||||
|
||||
#include "../effect.h"
|
||||
#include "project/effect.h"
|
||||
|
||||
class QOpenGLTexture;
|
||||
#include <QImage>
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
#ifndef TEXTEFFECT_H
|
||||
#define TEXTEFFECT_H
|
||||
|
||||
#include "../effect.h"
|
||||
#include "project/effect.h"
|
||||
|
||||
#include <QFont>
|
||||
#include <QImage>
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
#ifndef TONEEFFECT_H
|
||||
#define TONEEFFECT_H
|
||||
|
||||
#include "../effect.h"
|
||||
#include "project/effect.h"
|
||||
|
||||
class ToneEffect : public Effect {
|
||||
public:
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
#ifndef TRANSFORMEFFECT_H
|
||||
#define TRANSFORMEFFECT_H
|
||||
|
||||
#include "../effect.h"
|
||||
#include "project/effect.h"
|
||||
|
||||
class TransformEffect : public Effect {
|
||||
Q_OBJECT
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
#ifndef VOLUMEEFFECT_H
|
||||
#define VOLUMEEFFECT_H
|
||||
|
||||
#include "../effect.h"
|
||||
#include "project/effect.h"
|
||||
|
||||
class VolumeEffect : public Effect {
|
||||
public:
|
||||
|
||||
@@ -0,0 +1,13 @@
|
||||
#version 110
|
||||
|
||||
uniform float amount;
|
||||
|
||||
uniform sampler2D myTexture;
|
||||
varying vec2 vTexCoord;
|
||||
|
||||
void main(void) {
|
||||
vec4 textureColor = texture2D(myTexture, vTexCoord);
|
||||
float amount_val = amount * 0.01;
|
||||
vec3 col = textureColor.rgb+((vec3(1.0)-textureColor.rgb-textureColor.rgb)*vec3(amount_val));
|
||||
gl_FragColor = vec4(col, textureColor.a);
|
||||
}
|
||||
@@ -0,0 +1,47 @@
|
||||
#version 110
|
||||
|
||||
uniform vec2 resolution;
|
||||
uniform float time;
|
||||
|
||||
uniform float amount;
|
||||
uniform bool color;
|
||||
uniform bool blend;
|
||||
|
||||
uniform sampler2D myTexture;
|
||||
varying vec2 vTexCoord;
|
||||
|
||||
// precision lowp float;
|
||||
|
||||
float PHI = 1.61803398874989484820459 * 00000.1; // Golden Ratio
|
||||
float PI = 3.14159265358979323846264 * 00000.1; // PI
|
||||
float SQ2 = 1.41421356237309504880169 * 10000.0; // Square Root of Two
|
||||
|
||||
float gold_noise(vec2 coordinate, float seed){
|
||||
return fract(tan(distance(coordinate*(seed+PHI), vec2(PHI, PI)))*SQ2)*(amount*0.01);
|
||||
}
|
||||
|
||||
void main(void) {
|
||||
vec3 noise;
|
||||
if (color) {
|
||||
noise = vec3(gold_noise(vTexCoord, time + 42069.0), gold_noise(vTexCoord, time + 69220.0), gold_noise(vTexCoord, time + 1337.0));
|
||||
} else {
|
||||
noise = vec3(gold_noise(vTexCoord, time + 69420.0));
|
||||
}
|
||||
|
||||
if (blend) {
|
||||
noise = (noise - vec3(amount*0.005))*vec3(2.0);
|
||||
|
||||
vec4 textureColor = texture2D(myTexture, vec2(vTexCoord.x, vTexCoord.y));
|
||||
gl_FragColor = vec4(textureColor.rgb+noise, textureColor.a);
|
||||
} else {
|
||||
gl_FragColor = vec4(noise, 1.0);
|
||||
}
|
||||
}
|
||||
|
||||
/*void main(void) {
|
||||
vec4 textureColor = texture2D(myTexture, vec2(vTexCoord.x, vTexCoord.y));
|
||||
textureColor.r += gold_noise(resolution);
|
||||
textureColor.g += gold_noise(resolution);
|
||||
textureColor.b += gold_noise(resolution);
|
||||
gl_FragColor = textureColor;
|
||||
}*/
|
||||
@@ -0,0 +1,13 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<effect name="Noise" category="Color">
|
||||
<row name="Amount">
|
||||
<field type="double" min="0" default="20" max="100" id="amount"/>
|
||||
</row>
|
||||
<row name="Color Noise">
|
||||
<field type="bool" default="0" id="color"/>
|
||||
</row>
|
||||
<row name="Blend">
|
||||
<field type="bool" default="1" id="blend"/>
|
||||
</row>
|
||||
<shader vert="common.vert" frag="noise.frag"/>
|
||||
</effect>
|
||||
@@ -1,43 +0,0 @@
|
||||
#include "qpainterwrapper.h"
|
||||
|
||||
#include <QPainter>
|
||||
#include "debug.h"
|
||||
|
||||
// exposes several QPainter functions to QJSEngine
|
||||
|
||||
QPainterWrapper painter_wrapper;
|
||||
|
||||
QPainterWrapper::QPainterWrapper() {}
|
||||
|
||||
QColor get_color_from_string(const QString& s) {
|
||||
dout << s;
|
||||
|
||||
// workaround for alpha
|
||||
if (s.at(0) == '#' && s.length() == 9) {
|
||||
QColor color(s.left(7));
|
||||
color.setAlpha(s.mid(7).toInt(NULL, 16));
|
||||
return color;
|
||||
} else {
|
||||
return QColor(s);
|
||||
}
|
||||
}
|
||||
|
||||
void QPainterWrapper::fill(const QString& c) {
|
||||
img->fill(get_color_from_string(c));
|
||||
}
|
||||
|
||||
void QPainterWrapper::fillRect(int x, int y, int width, int height, const QString& brush) {
|
||||
painter->fillRect(x, y, width, height, get_color_from_string(brush));
|
||||
}
|
||||
|
||||
void QPainterWrapper::drawRect(int x, int y, int width, int height) {
|
||||
painter->drawRect(x, y, width, height);
|
||||
}
|
||||
|
||||
void QPainterWrapper::setPen(const QString& pen) {
|
||||
painter->setPen(get_color_from_string(pen));
|
||||
}
|
||||
|
||||
void QPainterWrapper::setBrush(const QString& brush) {
|
||||
painter->setBrush(get_color_from_string(brush));
|
||||
}
|
||||
@@ -1,24 +0,0 @@
|
||||
#ifndef QPAINTERWRAPPER_H
|
||||
#define QPAINTERWRAPPER_H
|
||||
|
||||
#include <QObject>
|
||||
|
||||
class QPainter;
|
||||
|
||||
class QPainterWrapper : public QObject {
|
||||
Q_OBJECT
|
||||
public:
|
||||
QPainterWrapper();
|
||||
QImage* img;
|
||||
QPainter* painter;
|
||||
public slots:
|
||||
void fill(const QString& color);
|
||||
void fillRect(int x, int y, int width, int height, const QString& brush);
|
||||
void drawRect(int x, int y, int width, int height);
|
||||
void setPen(const QString& pen);
|
||||
void setBrush(const QString& brush);
|
||||
};
|
||||
|
||||
extern QPainterWrapper painter_wrapper;
|
||||
|
||||
#endif // QPAINTERWRAPPER_H
|
||||
@@ -1 +0,0 @@
|
||||
<RCC/>
|
||||
@@ -11,7 +11,7 @@ uniform sampler2D myTexture;
|
||||
varying vec2 vTexCoord;
|
||||
|
||||
void main(void) {
|
||||
vec2 center = vec2(center_x, center_y);
|
||||
vec2 center = vec2((resolution.x*0.5)+center_x, (resolution.y*0.5)+center_y);
|
||||
|
||||
vec2 uv = vTexCoord.st;
|
||||
|
||||
@@ -28,6 +28,4 @@ void main(void) {
|
||||
tc += center;
|
||||
vec3 color = texture2D(myTexture, tc / resolution).rgb;
|
||||
gl_FragColor = vec4(color, 1.0);
|
||||
|
||||
|
||||
}
|
||||
@@ -1,7 +1,7 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<effect name="Swirl" category="Distort">
|
||||
<row name="Radius">
|
||||
<field type="double" min="0" default="10" id="radius"/>
|
||||
<field type="double" min="0" default="200" id="radius"/>
|
||||
</row>
|
||||
<row name="Angle">
|
||||
<field type="double" default="10" id="angle"/>
|
||||
@@ -1,12 +1,10 @@
|
||||
#version 110
|
||||
|
||||
// uniform float evolution;
|
||||
uniform float frequency;
|
||||
uniform float intensity;
|
||||
uniform float evolution;
|
||||
uniform bool vertical;
|
||||
|
||||
uniform mediump float amount_val;
|
||||
uniform sampler2D myTexture;
|
||||
varying vec2 vTexCoord;
|
||||
|
||||
Reference in New Issue
Block a user