shaders: added stroke shader
This commit is contained in:
@@ -27,6 +27,7 @@ void NodeFactory::Initialize()
|
||||
library_.append(new ExternalNode(":/shaders/boxblur.xml"));
|
||||
library_.append(new ExternalNode(":/shaders/opacity.xml"));
|
||||
library_.append(new ExternalNode(":/shaders/solid.xml"));
|
||||
library_.append(new ExternalNode(":/shaders/stroke.xml"));
|
||||
library_.append(new ExternalNode(":/shaders/alphaover.xml"));
|
||||
library_.append(new ExternalNode(":/shaders/dropshadow.xml"));
|
||||
library_.append(new ExternalTransition(":/shaders/crossdissolve.xml"));
|
||||
|
||||
@@ -5,6 +5,7 @@
|
||||
|
||||
<!-- Effect Category -->
|
||||
<category lang="en_US">Stylize</category>
|
||||
<category lang="en_GB">Stylise</category>
|
||||
|
||||
<!-- Effect Description -->
|
||||
<description lang="en_US">
|
||||
@@ -16,9 +17,10 @@
|
||||
<name lang="en_US">Input</name>
|
||||
</param>
|
||||
|
||||
<!-- Parameter: Softness Input -->
|
||||
<!-- Parameter: Color Input -->
|
||||
<param id="color_in" type="color">
|
||||
<name lang="en_US">Color</name>
|
||||
<name lang="en_GB">Colour</name>
|
||||
</param>
|
||||
|
||||
<!-- Parameter: Softness Input -->
|
||||
|
||||
@@ -16,6 +16,8 @@
|
||||
<file>opacity.xml</file>
|
||||
<file>solid.frag</file>
|
||||
<file>solid.xml</file>
|
||||
<file>stroke.frag</file>
|
||||
<file>stroke.xml</file>
|
||||
<file>videoinput.frag</file>
|
||||
<file>videoinput.vert</file>
|
||||
</qresource>
|
||||
|
||||
@@ -0,0 +1,61 @@
|
||||
#version 110
|
||||
|
||||
// Standard inputs
|
||||
uniform vec2 ove_resolution;
|
||||
varying vec2 ove_texcoord;
|
||||
uniform int ove_iteration;
|
||||
|
||||
// Node parameter inputs
|
||||
uniform sampler2D tex_in;
|
||||
uniform vec3 color_in;
|
||||
uniform float radius_in;
|
||||
uniform float opacity_in;
|
||||
|
||||
void main(void) {
|
||||
if (radius_in == 0.0 || opacity_in == 0.0) {
|
||||
// No-op, do nothing
|
||||
gl_FragColor = texture2D(tex_in, ove_texcoord);
|
||||
return;
|
||||
}
|
||||
|
||||
float radius = ceil(radius_in);
|
||||
|
||||
float stroke_weight = 0.0;
|
||||
|
||||
// Loop over box
|
||||
for (float i=-radius + 0.5; i<=radius; i += 2.0) {
|
||||
float x_coord = i / ove_resolution.x;
|
||||
|
||||
for (float j=-radius + 0.5; j<=radius; j += 2.0) {
|
||||
float y_coord = j / ove_resolution.y;
|
||||
|
||||
if (abs(length(vec2(i, j))) < radius) {
|
||||
// Get pixel here
|
||||
stroke_weight += texture2D(tex_in, ove_texcoord + vec2(x_coord, y_coord)).a;
|
||||
|
||||
if (stroke_weight >= 1.0) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (stroke_weight >= 1.0) {
|
||||
stroke_weight = 1.0;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
stroke_weight *= opacity_in * 0.01;
|
||||
|
||||
// Make RGBA color
|
||||
vec4 stroke_col = vec4(vec3(1.0) * stroke_weight, stroke_weight);
|
||||
//vec4 stroke_col = vec4(color_in * stroke_weight, stroke_weight);
|
||||
|
||||
// Alpha over color here
|
||||
vec4 pixel_here = texture2D(tex_in, ove_texcoord);
|
||||
|
||||
stroke_col *= 1.0 - pixel_here.a;
|
||||
stroke_col += pixel_here;
|
||||
|
||||
gl_FragColor = stroke_col;
|
||||
}
|
||||
@@ -0,0 +1,43 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<effect id="org.olivevideoeditor.Olive.gaussianblur">
|
||||
<!-- Effect Name -->
|
||||
<name lang="en_US">Stroke</name>
|
||||
|
||||
<!-- Effect Category -->
|
||||
<category lang="en_US">Stylize</category>
|
||||
<category lang="en_GB">Stylise</category>
|
||||
|
||||
<!-- Effect Description -->
|
||||
<description lang="en_US">
|
||||
Creates a stroke outline around an image.
|
||||
</description>
|
||||
|
||||
<!-- Parameter: Texture Input -->
|
||||
<param id="tex_in" type="texture">
|
||||
<name lang="en_US">Input</name>
|
||||
</param>
|
||||
|
||||
<!-- Parameter: Color Value -->
|
||||
<param id="color_in" type="color">
|
||||
<name lang="en_US">Color</name>
|
||||
<name lang="en_GB">Colour</name>
|
||||
</param>
|
||||
|
||||
<!-- Parameter: Radius Value -->
|
||||
<param id="radius_in" type="float">
|
||||
<name lang="en_US">Radius</name>
|
||||
<min>0</min>
|
||||
<default>10</default>
|
||||
</param>
|
||||
|
||||
<!-- Parameter: Opacity Value -->
|
||||
<param id="opacity_in" type="float">
|
||||
<name lang="en_US">Opacity</name>
|
||||
<min>0</min>
|
||||
<default>100</default>
|
||||
<max>100</max>
|
||||
</param>
|
||||
|
||||
<!-- Qt Resource path to fragment shader -->
|
||||
<fragment url=":/shaders/stroke.frag" />
|
||||
</effect>
|
||||
Reference in New Issue
Block a user