diff --git a/effects/effect.cpp b/effects/effect.cpp
index 4e09326ad..bc2592cae 100644
--- a/effects/effect.cpp
+++ b/effects/effect.cpp
@@ -307,6 +307,8 @@ Effect::Effect(Clip* c, const EffectMeta *em) :
shader_frag_path_ = attr.value().toString();
} else if (attr.name() == "iterations") {
setIterations(attr.value().toInt());
+ } else if (attr.name() == "function") {
+ shader_function_name_ = attr.value().toString();
}
}
}/* else if (reader.name() == "superimpose" && reader.isStartElement()) {
@@ -757,7 +759,17 @@ void Effect::open() {
}
if (!frag_shader_str.isEmpty()) {
- shader_program_ = olive::shader::GetPipeline("process", frag_shader_str);
+
+ QString shader_func;
+
+ if (!shader_function_name_.isEmpty()) {
+ shader_func = shader_function_name_;
+ } else {
+ shader_func = "process";
+ }
+
+ shader_program_ = olive::shader::GetPipeline(shader_func, frag_shader_str);
+
}
/*
diff --git a/effects/effect.h b/effects/effect.h
index 2e3252d8b..6871009a7 100644
--- a/effects/effect.h
+++ b/effects/effect.h
@@ -226,6 +226,7 @@ protected:
QOpenGLShaderProgramPtr shader_program_;
QString shader_vert_path_;
QString shader_frag_path_;
+ QString shader_function_name_;
// superimpose effect
QImage img;
diff --git a/effects/shaders/boxblur.frag b/effects/shaders/boxblur.frag
index 3da0380bc..a9479c135 100644
--- a/effects/shaders/boxblur.frag
+++ b/effects/shaders/boxblur.frag
@@ -1,16 +1,10 @@
-#version 110
-
-uniform sampler2D image;
-
uniform float radius;
-uniform vec2 resolution;
uniform bool horiz_blur;
uniform bool vert_blur;
uniform int iteration;
+uniform vec2 resolution;
-varying vec2 vTexCoord;
-
-void main(void) {
+vec4 process(vec4 col) {
float rad = ceil(radius);
float divider = 1.0 / rad;
@@ -19,15 +13,15 @@ void main(void) {
if (iteration == 0 && horiz_blur && !radius_is_zero) {
for (float x=-rad+0.5;x<=rad;x+=2.0) {
- color += texture2D(image, (vec2(gl_FragCoord.x+x, gl_FragCoord.y))/resolution)*(divider);
+ color += texture2D(texture, vec2(gl_FragCoord.x+x, gl_FragCoord.y)/resolution)*(divider);
}
- gl_FragColor = color;
+ return color;
} else if (iteration == 1 && vert_blur && !radius_is_zero) {
for (float x=-rad+0.5;x<=rad;x+=2.0) {
- color += texture2D(image, (vec2(gl_FragCoord.x, gl_FragCoord.y+x))/resolution)*(divider);
+ color += texture2D(texture, vec2(gl_FragCoord.x, gl_FragCoord.y+x)/resolution)*(divider);
}
- gl_FragColor = color;
+ return color;
} else {
- gl_FragColor = texture2D(image, vTexCoord);
+ return col;
}
-}
\ No newline at end of file
+}
diff --git a/effects/shaders/boxblur.xml b/effects/shaders/boxblur.xml
index a6c0cb491..59bf40ca2 100644
--- a/effects/shaders/boxblur.xml
+++ b/effects/shaders/boxblur.xml
@@ -9,5 +9,5 @@
-
+
\ No newline at end of file
diff --git a/effects/shaders/chromaticaberration.frag b/effects/shaders/chromaticaberration.frag
index ff9ddfa96..1b795f348 100644
--- a/effects/shaders/chromaticaberration.frag
+++ b/effects/shaders/chromaticaberration.frag
@@ -1,22 +1,17 @@
-#version 110
-
-uniform vec2 resolution;
-
-uniform sampler2D tex;
-varying vec2 vTexCoord;
-
uniform float red_amount;
uniform float green_amount;
uniform float blue_amount;
-void main(void) {
+uniform vec2 resolution;
+
+vec4 process(vec4 col) {
vec2 rOffset = vec2(red_amount*0.01)/resolution;
vec2 gOffset = vec2(green_amount*0.01)/resolution;
vec2 bOffset = vec2(blue_amount*0.01)/resolution;
- vec4 rValue = texture2D(tex, vTexCoord - rOffset);
- vec4 gValue = texture2D(tex, vTexCoord - gOffset);
- vec4 bValue = texture2D(tex, vTexCoord - bOffset);
+ vec4 rValue = texture2D(texture, v_texcoord - rOffset);
+ vec4 gValue = texture2D(texture, v_texcoord - gOffset);
+ vec4 bValue = texture2D(texture, v_texcoord - bOffset);
- gl_FragColor = vec4(rValue.r, gValue.g, bValue.b, texture2D(tex, vTexCoord).a);
+ return vec4(rValue.r, gValue.g, bValue.b, col.a);
}
\ No newline at end of file
diff --git a/effects/shaders/crop.frag b/effects/shaders/crop.frag
index 7fed98944..062f22c2f 100644
--- a/effects/shaders/crop.frag
+++ b/effects/shaders/crop.frag
@@ -1,5 +1,3 @@
-#version 110
-
uniform float left;
uniform float top;
uniform float right;
@@ -7,28 +5,20 @@ uniform float bottom;
uniform float feather;
uniform mediump float amount_val;
-uniform sampler2D myTexture;
-varying vec2 vTexCoord;
-void main(void) {
- vec4 textureColor = texture2D(myTexture, vec2(vTexCoord.x, vTexCoord.y));
- float alpha = textureColor.a;
+vec4 process(vec4 col) {
+ float alpha = col.a;
if (feather == 0.0) {
- if (vTexCoord.x < (left*0.01) || vTexCoord.y < (top*0.01) || vTexCoord.x > (1.0-(right*0.01)) || vTexCoord.y > (1.0-(bottom*0.01))) {
+ if (v_texcoord.x < (left*0.01) || v_texcoord.y < (top*0.01) || v_texcoord.x > (1.0-(right*0.01)) || v_texcoord.y > (1.0-(bottom*0.01))) {
alpha = 0.0;
}
} else {
float f = pow(2.0, 10.0-(feather*0.1));
- if (left > 0.0) alpha = alpha * clamp(((vTexCoord.x+(0.5/f))-(left*0.01))*f, 0.0, 1.0); // left
- if (top > 0.0) alpha = alpha * clamp(((vTexCoord.y+(0.5/f))-(top*0.01))*f, 0.0, 1.0); // top
- if (right > 0.0) alpha = alpha * clamp((((1.0-vTexCoord.x)+(0.5/f))-(right*0.01))*f, 0.0, 1.0); // right
- if (bottom > 0.0) alpha = alpha * clamp((((1.0-vTexCoord.y)+(0.5/f))-(bottom*0.01))*f, 0.0, 1.0); // bottom
+ if (left > 0.0) alpha = alpha * clamp(((v_texcoord.x+(0.5/f))-(left*0.01))*f, 0.0, 1.0); // left
+ if (top > 0.0) alpha = alpha * clamp(((v_texcoord.y+(0.5/f))-(top*0.01))*f, 0.0, 1.0); // top
+ if (right > 0.0) alpha = alpha * clamp((((1.0-v_texcoord.x)+(0.5/f))-(right*0.01))*f, 0.0, 1.0); // right
+ if (bottom > 0.0) alpha = alpha * clamp((((1.0-v_texcoord.y)+(0.5/f))-(bottom*0.01))*f, 0.0, 1.0); // bottom
}
- gl_FragColor = vec4(
- textureColor.r*alpha,
- textureColor.g*alpha,
- textureColor.b*alpha,
- alpha
- );
+ return vec4(col.rgb*alpha, alpha);
}
\ No newline at end of file
diff --git a/effects/shaders/directionalblur.frag b/effects/shaders/directionalblur.frag
index e04d350ed..86c8ac079 100644
--- a/effects/shaders/directionalblur.frag
+++ b/effects/shaders/directionalblur.frag
@@ -1,15 +1,11 @@
-#version 110
-
#define M_PI 3.1415926535897932384626433832795
-uniform sampler2D image;
-
uniform float angle; // degrees
uniform float length;
uniform vec2 resolution;
-void main(void) {
+vec4 process(vec4 col) {
if (length > 0.0) {
float ceillen = ceil(length);
float radians = (angle*M_PI)/180.0;
@@ -21,10 +17,10 @@ void main(void) {
for (float i=-ceillen+0.5;i<=ceillen;i+=2.0) {
float y = sin_angle * i;
float x = cos_angle * i;
- color += texture2D(image, vec2(gl_FragCoord.x+x, gl_FragCoord.y+y)/resolution)*(divider);
+ color += texture2D(texture, vec2(gl_FragCoord.x+x, gl_FragCoord.y+y)/resolution)*(divider);
}
- gl_FragColor = color;
+ return color;
} else {
- gl_FragColor = texture2D(image, gl_FragCoord.xy/resolution);
+ return col;
}
}
\ No newline at end of file
diff --git a/effects/shaders/common.frag b/effects/shaders/discard/common.frag
similarity index 100%
rename from effects/shaders/common.frag
rename to effects/shaders/discard/common.frag
diff --git a/effects/shaders/common.vert b/effects/shaders/discard/common.vert
similarity index 100%
rename from effects/shaders/common.vert
rename to effects/shaders/discard/common.vert
diff --git a/effects/shaders/discard/invert.frag b/effects/shaders/discard/invert.frag
new file mode 100644
index 000000000..bcfa87612
--- /dev/null
+++ b/effects/shaders/discard/invert.frag
@@ -0,0 +1,7 @@
+uniform float amount;
+
+vec4 process(vec4 col) {
+ float amount_val = amount * 0.01;
+ vec3 color = col.rgb+((vec3(1.0)-col.rgb-col.rgb)*vec3(amount_val));
+ return vec4(color, col.a);
+}
\ No newline at end of file
diff --git a/effects/shaders/invert.xml b/effects/shaders/discard/invert.xml
similarity index 100%
rename from effects/shaders/invert.xml
rename to effects/shaders/discard/invert.xml
diff --git a/effects/shaders/posterize.frag b/effects/shaders/discard/posterize.frag
similarity index 59%
rename from effects/shaders/posterize.frag
rename to effects/shaders/discard/posterize.frag
index a3144450b..85ee2c1dc 100644
--- a/effects/shaders/posterize.frag
+++ b/effects/shaders/discard/posterize.frag
@@ -1,19 +1,13 @@
-#version 110
-
-uniform sampler2D sceneTex; // 0
uniform float gamma_cent; // 0.6
uniform float numColors; // 8.0
-varying vec2 vTexCoord;
-
-void main() {
+vec4 process(vec4 color) {
float gamma = gamma_cent*0.01;
- vec4 color = texture2D(sceneTex, vTexCoord);
vec3 c = color.rgb;
c = pow(c, vec3(gamma, gamma, gamma));
c = c * numColors;
c = floor(c);
c = c / numColors;
c = pow(c, vec3(1.0/gamma));
- gl_FragColor = vec4(c, color.a);
+ return vec4(c, color.a);
}
\ No newline at end of file
diff --git a/effects/shaders/posterize.xml b/effects/shaders/discard/posterize.xml
similarity index 100%
rename from effects/shaders/posterize.xml
rename to effects/shaders/discard/posterize.xml
diff --git a/effects/shaders/discard/volumetriclight.frag b/effects/shaders/discard/volumetriclight.frag
new file mode 100644
index 000000000..bf27e17d7
--- /dev/null
+++ b/effects/shaders/discard/volumetriclight.frag
@@ -0,0 +1,15 @@
+uniform float amount;
+
+uniform vec2 resolution; // screen resolution
+
+vec4 process(vec4 col) {
+ float alpha = texture2D(texture, v_texcoord)[3];
+
+ vec3 p = gl_FragCoord.xyz/vec3(resolution, 1.0)-.5;
+ vec4 color = texture2D(texture,.5+(p.xy*=.992));
+ vec3 o = color.rgb;
+ for (float i=0.;i 0.0) {
vec2 distance = vec2((gl_FragCoord.x - (resolution.x/2.0) - center_x), (gl_FragCoord.y - (resolution.y/2.0) - center_y));
@@ -28,10 +25,10 @@ void main(void) {
for (float i=-limit+0.5;i<=limit;i+=2.0) {
float y = sin_angle * i;
float x = cos_angle * i;
- color += texture2D(image, vec2(gl_FragCoord.x+x, gl_FragCoord.y+y)/resolution)*(divider);
+ color += texture2D(texture, vec2(gl_FragCoord.x+x, gl_FragCoord.y+y)/resolution)*(divider);
}
- gl_FragColor = color;
+ return color;
} else {
- gl_FragColor = texture2D(image, gl_FragCoord.xy/resolution);
+ return col;
}
}
\ No newline at end of file
diff --git a/effects/shaders/ripple.frag b/effects/shaders/ripple.frag
index 03c91a5ce..b9fc951f0 100644
--- a/effects/shaders/ripple.frag
+++ b/effects/shaders/ripple.frag
@@ -1,7 +1,3 @@
-#version 110
-
-varying vec2 vTexCoord;
-
uniform float speed;
uniform float intensity;
uniform float frequency;
@@ -12,10 +8,9 @@ uniform bool stretch;
uniform vec2 resolution; // Screen resolution
uniform float time; // time in seconds
-uniform sampler2D tex0; // scene buffer
-void main(void) {
- vec2 texCoord = vTexCoord;
+vec4 process(vec4 col) {
+ vec2 texCoord = v_texcoord;
vec2 center = vec2(1.0);
if (!stretch) {
@@ -29,6 +24,6 @@ void main(void) {
vec2 p = 2.0 * texCoord - center;
float len = length(p);
- vec2 uv = vTexCoord + (p/len)*cos((frequency*0.01)*(len*12.0-real_time*(speed*0.05)))*(intensity*0.0005);
- gl_FragColor = texture2D(tex0,uv);
+ vec2 uv = v_texcoord + (p/len)*cos((frequency*0.01)*(len*12.0-real_time*(speed*0.05)))*(intensity*0.0005);
+ return texture2D(texture, uv);
}
\ No newline at end of file
diff --git a/effects/shaders/sphere.frag b/effects/shaders/sphere.frag
index 2445b37a4..6496dd5b3 100644
--- a/effects/shaders/sphere.frag
+++ b/effects/shaders/sphere.frag
@@ -1,9 +1,4 @@
-#version 110
-
-varying vec2 vTexCoord;
-
uniform vec2 resolution; // Screen resolution
-uniform sampler2D tex0; // scene buffer
uniform float xoff;
uniform float yoff;
@@ -12,8 +7,8 @@ uniform bool tile;
uniform bool hide_edges;
uniform bool stretch;
-void main(void) {
- vec2 texCoord = vTexCoord;
+vec4 process(vec4 col) {
+ vec2 texCoord = v_texcoord;
vec2 offset = vec2(1.0);
@@ -28,7 +23,7 @@ void main(void) {
}
vec2 p = 2.0 * texCoord - offset;
- vec2 adj_tc = 2.0 * vTexCoord - 1.0;
+ vec2 adj_tc = 2.0 * v_texcoord - 1.0;
float r = dot(p,p);
if (r > 1.0) discard;
float f = (1.0-sqrt(1.0-r))/(r);
@@ -39,7 +34,7 @@ void main(void) {
uv.x = mod(uv.x, 1.0);
uv.y = mod(uv.y, 1.0);
} else if (hide_edges && (uv.x < 0.0 || uv.x > 1.0 || uv.y < 0.0 || uv.y > 1.0)) {
- discard;
+ return vec4(0.0);
}
- gl_FragColor = vec4(texture2D(tex0,uv));
-}
\ No newline at end of file
+ return vec4(texture2D(texture,uv));
+}
diff --git a/effects/shaders/swirl.frag b/effects/shaders/swirl.frag
index e820e3394..94facd048 100644
--- a/effects/shaders/swirl.frag
+++ b/effects/shaders/swirl.frag
@@ -1,5 +1,3 @@
-#version 110
-
// Swirl effect parameters
uniform float radius;
uniform float angle;
@@ -7,13 +5,10 @@ uniform float center_x;
uniform float center_y;
uniform vec2 resolution;
-uniform sampler2D myTexture;
-varying vec2 vTexCoord;
-
-void main(void) {
+vec4 process(vec4 col) {
vec2 center = vec2((resolution.x*0.5)+center_x, (resolution.y*0.5)+center_y);
- vec2 uv = vTexCoord.st;
+ vec2 uv = v_texcoord.st;
vec2 tc = uv * resolution;
tc -= center;
@@ -26,6 +21,5 @@ void main(void) {
tc = vec2(dot(tc, vec2(c, -s)), dot(tc, vec2(s, c)));
}
tc += center;
- vec3 color = texture2D(myTexture, tc / resolution).rgb;
- gl_FragColor = vec4(color, 1.0);
+ return texture2D(texture, tc / resolution);
}
\ No newline at end of file
diff --git a/effects/shaders/volumetriclight.frag b/effects/shaders/volumetriclight.frag
deleted file mode 100644
index cfeeb9252..000000000
--- a/effects/shaders/volumetriclight.frag
+++ /dev/null
@@ -1,19 +0,0 @@
-#version 110
-
-uniform float amount;
-
-uniform sampler2D tex0;
-uniform vec2 resolution; // screen resolution
-varying vec2 vTexCoord;
-#define T texture2D(tex0,.5+(p.xy*=.992))
-
-void main() {
- float alpha = texture2D(tex0, vTexCoord)[3];
-
- vec3 p = gl_FragCoord.xyz/vec3(resolution, 1.0)-.5;
- vec3 o = T.rgb;
- for (float i=0.;i 1.0 || x < 0.0 || x > 1.0) {
- discard;
+ return vec4(0.0);
} else {
- vec4 textureColor = texture2D(myTexture, vec2(x, y));
- gl_FragColor = vec4(
- textureColor.r,
- textureColor.g,
- textureColor.b,
- textureColor.a
- );
+ return texture2D(texture, vec2(x, y));
}
}
\ No newline at end of file
diff --git a/panels/project.cpp b/panels/project.cpp
index c0ad3439a..697265aa9 100644
--- a/panels/project.cpp
+++ b/panels/project.cpp
@@ -1115,6 +1115,7 @@ void Project::save_folder(QXmlStreamWriter& stream, int type, bool set_ids_only,
stream.writeAttribute("speed", QString::number(f->speed));
stream.writeAttribute("alphapremul", QString::number(f->alpha_is_associated));
stream.writeAttribute("startnumber", QString::number(f->start_number));
+ stream.writeAttribute("colorspace", f->Colorspace());
stream.writeAttribute("proxy", QString::number(f->proxy));
stream.writeAttribute("proxypath", f->proxy_path);
diff --git a/project/loadthread.cpp b/project/loadthread.cpp
index ca1c49cd5..20ddc66d6 100644
--- a/project/loadthread.cpp
+++ b/project/loadthread.cpp
@@ -356,6 +356,8 @@ bool LoadThread::load_worker(QFile& f, QXmlStreamReader& stream, int type) {
f->proxy_path = attr.value().toString();
} else if (attr.name() == "startnumber") {
f->start_number = attr.value().toInt();
+ } else if (attr.name() == "colorspace") {
+ f->SetColorspace(attr.value().toString());
}
}
diff --git a/timeline/clip.cpp b/timeline/clip.cpp
index c5c62f9e5..a6242a7fe 100644
--- a/timeline/clip.cpp
+++ b/timeline/clip.cpp
@@ -573,6 +573,10 @@ bool Clip::Retrieve()
f->glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
f->glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
+ // set texture wrapping to clamp
+ f->glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
+ f->glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
+
// queue an allocation ahead
allocate_data = true;