fixed bugs in the blur shaders
This commit is contained in:
@@ -11,14 +11,14 @@ uniform bool vert_in;
|
||||
|
||||
void main(void) {
|
||||
if (radius_in == 0.0
|
||||
|| (iteration == 0 && !horiz_in)
|
||||
|| (iteration == 1 && !vert_in)) {
|
||||
gl_FragColor = texture2D(image, ove_texcoord);
|
||||
|| (ove_iteration == 0 && !horiz_in)
|
||||
|| (ove_iteration == 1 && !vert_in)) {
|
||||
gl_FragColor = texture2D(tex_in, ove_texcoord);
|
||||
return;
|
||||
}
|
||||
|
||||
// We only sample on hard pixels, so we don't accept decimal radii
|
||||
float real_radius = ceil(radius);
|
||||
float real_radius = ceil(radius_in);
|
||||
|
||||
// Calculate the weight of each pixel based on the radius
|
||||
float divider = 1.0 / real_radius;
|
||||
@@ -26,12 +26,12 @@ void main(void) {
|
||||
vec4 composite = vec4(0.0);
|
||||
for (float i=-real_radius+0.5;i<=real_radius;i+=2.0) {
|
||||
vec2 pixel_coord = ove_texcoord;
|
||||
if (iteration == 0) {
|
||||
if (ove_iteration == 0) {
|
||||
pixel_coord.x += i/ove_resolution.x;
|
||||
} else if (iteration == 1) {
|
||||
} else if (ove_iteration == 1) {
|
||||
pixel_coord.y += i/ove_resolution.y;
|
||||
}
|
||||
composite += texture2D(image, pixel_coord) * divider;
|
||||
composite += texture2D(tex_in, pixel_coord) * divider;
|
||||
}
|
||||
gl_FragColor = composite;
|
||||
}
|
||||
|
||||
@@ -12,7 +12,7 @@
|
||||
</description>
|
||||
|
||||
<!-- Parameter: Texture Input -->
|
||||
<param id="tex_in" type="texture" iteration_in="1">
|
||||
<param id="tex_in" type="texture" iterative_input="1">
|
||||
<name lang="en_US">Input</name>
|
||||
</param>
|
||||
|
||||
@@ -26,13 +26,13 @@
|
||||
<!-- Parameter: Horizontal Enable -->
|
||||
<param id="horiz_in" type="bool">
|
||||
<name lang="en_US">Horizontal</name>
|
||||
<default>true</default>
|
||||
<default>1</default>
|
||||
</param>
|
||||
|
||||
<!-- Parameter: Vertical Enable -->
|
||||
<param id="vert_in" type="bool">
|
||||
<name lang="en_US">Vertical</name>
|
||||
<default>true</default>
|
||||
<default>1</default>
|
||||
</param>
|
||||
|
||||
<!-- Qt Resource path to fragment shader -->
|
||||
|
||||
@@ -37,7 +37,7 @@ void main(void) {
|
||||
|
||||
// Using (3 * sigma) because 3 standard deviations covers 97% of the blur according to this document:
|
||||
// http://chemaguerra.com/gaussian-filter-radius/
|
||||
float radius = ceil(3.0 * sigma);
|
||||
float radius = ceil(3.0 * sigma_in);
|
||||
|
||||
// Use gaussian formula to calculate the weight of all pixels
|
||||
float sum = 0.0;
|
||||
|
||||
@@ -12,7 +12,7 @@
|
||||
</description>
|
||||
|
||||
<!-- Parameter: Texture Input -->
|
||||
<param id="tex_in" type="texture" iteration_in="1">
|
||||
<param id="tex_in" type="texture" iterative_input="1">
|
||||
<name lang="en_US">Input</name>
|
||||
</param>
|
||||
|
||||
@@ -26,13 +26,13 @@
|
||||
<!-- Parameter: Horizontal Enable -->
|
||||
<param id="horiz_in" type="bool">
|
||||
<name lang="en_US">Horizontal</name>
|
||||
<field type="bool" default="1" id=""/>
|
||||
<default>1</default>
|
||||
</param>
|
||||
|
||||
<!-- Parameter: Vertical Enable -->
|
||||
<param id="vert_in" type="bool">
|
||||
<name lang="en_US">Vertical</name>
|
||||
<default>true</default>
|
||||
<default>1</default>
|
||||
</param>
|
||||
|
||||
<!-- Qt Resource path to fragment shader -->
|
||||
|
||||
@@ -1,6 +1,8 @@
|
||||
<RCC>
|
||||
<qresource prefix="/shaders">
|
||||
<file>alphaover.frag</file>
|
||||
<file>boxblur.frag</file>
|
||||
<file>boxblur.xml</file>
|
||||
<file>crossdissolve.frag</file>
|
||||
<file>diptoblack.frag</file>
|
||||
<file>gaussianblur.frag</file>
|
||||
|
||||
Reference in New Issue
Block a user