much faster box blur
This commit is contained in:
+13
-33
@@ -9,42 +9,22 @@ uniform vec2 resolution;
|
||||
uniform bool horiz_blur;
|
||||
uniform bool vert_blur;
|
||||
|
||||
uniform bool opt;
|
||||
|
||||
void main(void) {
|
||||
float rad = floor(radius);
|
||||
float x_rad = (horiz_blur) ? rad : 0.5;
|
||||
float y_rad = (vert_blur) ? rad : 0.5;
|
||||
vec2 texCoord = gl_FragCoord.xy/resolution;
|
||||
if (radius == 0.0 || (!horiz_blur && !vert_blur)) {
|
||||
gl_FragColor = texture2D(image, gl_FragCoord.xy/resolution);
|
||||
gl_FragColor = texture2D(image, texCoord);
|
||||
} else {
|
||||
float divider = 1.0 / ((radius*2.0)+1.0);
|
||||
if (horiz_blur && vert_blur) {
|
||||
divider *= divider;
|
||||
|
||||
gl_FragColor = texture2D(image, gl_FragCoord.xy/resolution)*divider;
|
||||
|
||||
for (float i=1.0;i<=radius;i++) {
|
||||
gl_FragColor += texture2D(image, (vec2(gl_FragCoord.x-i, gl_FragCoord.y))/resolution)*(divider);
|
||||
gl_FragColor += texture2D(image, (vec2(gl_FragCoord.x+i, gl_FragCoord.y))/resolution)*(divider);
|
||||
gl_FragColor += texture2D(image, (vec2(gl_FragCoord.x, gl_FragCoord.y+i))/resolution)*(divider);
|
||||
gl_FragColor += texture2D(image, (vec2(gl_FragCoord.x, gl_FragCoord.y-i))/resolution)*(divider);
|
||||
}
|
||||
|
||||
for (float x=1.0;x<=radius;x++) {
|
||||
for (float y=1.0;y<=radius;y++) {
|
||||
gl_FragColor += texture2D(image, (vec2(gl_FragCoord.x-x, gl_FragCoord.y-y))/resolution)*(divider);
|
||||
gl_FragColor += texture2D(image, (vec2(gl_FragCoord.x+x, gl_FragCoord.y+y))/resolution)*(divider);
|
||||
gl_FragColor += texture2D(image, (vec2(gl_FragCoord.x-x, gl_FragCoord.y+y))/resolution)*(divider);
|
||||
gl_FragColor += texture2D(image, (vec2(gl_FragCoord.x+x, gl_FragCoord.y-y))/resolution)*(divider);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
gl_FragColor = texture2D(image, gl_FragCoord.xy/resolution)*(divider);
|
||||
|
||||
for (float i=1.0;i<=radius;i++) {
|
||||
if (horiz_blur) {
|
||||
gl_FragColor += texture2D(image, (vec2(gl_FragCoord.x-i, gl_FragCoord.y))/resolution)*(divider);
|
||||
gl_FragColor += texture2D(image, (vec2(gl_FragCoord.x+i, gl_FragCoord.y))/resolution)*(divider);
|
||||
} else {
|
||||
gl_FragColor += texture2D(image, (vec2(gl_FragCoord.x, gl_FragCoord.y-i))/resolution)*(divider);
|
||||
gl_FragColor += texture2D(image, (vec2(gl_FragCoord.x, gl_FragCoord.y+i))/resolution)*(divider);
|
||||
}
|
||||
float divider = 1.0;
|
||||
if (horiz_blur) divider /= rad;
|
||||
if (vert_blur) divider /= rad;
|
||||
for (float x=-x_rad+0.5;x<=x_rad;x+=2.0) {
|
||||
for (float y=-y_rad+0.5;y<=y_rad;y+=2.0) {
|
||||
gl_FragColor += texture2D(image, (vec2(gl_FragCoord.x+x, gl_FragCoord.y+y))/resolution)*(divider);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -9,5 +9,8 @@
|
||||
<row name="Vertical">
|
||||
<field type="bool" default="1" id="vert_blur"/>
|
||||
</row>
|
||||
<row name="Opt">
|
||||
<field type="bool" default="0" id="opt"/>
|
||||
</row>
|
||||
<shader vert="common.vert" frag="boxblur.frag"/>
|
||||
</effect>
|
||||
+3
-3
@@ -1,7 +1,7 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<effect name="Volumetric Light" category="Stylize">
|
||||
<effect name="Invert" category="Color">
|
||||
<row name="Amount">
|
||||
<field type="double" min="0" default="100" id="amount"/>
|
||||
<field type="double" min="0" default="100" max="100" id="amount"/>
|
||||
</row>
|
||||
<shader vert="common.vert" frag="volumetriclight.frag"/>
|
||||
<shader vert="common.vert" frag="invert.frag"/>
|
||||
</effect>
|
||||
@@ -1,7 +1,7 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<effect name="Invert" category="Color">
|
||||
<effect name="Volumetric Light" category="Stylize">
|
||||
<row name="Amount">
|
||||
<field type="double" min="0" default="100" max="100" id="amount"/>
|
||||
<field type="double" min="0" default="100" id="amount"/>
|
||||
</row>
|
||||
<shader vert="common.vert" frag="invert.frag"/>
|
||||
<shader vert="common.vert" frag="volumetriclight.frag"/>
|
||||
</effect>
|
||||
+12
-19
@@ -256,6 +256,9 @@ void ViewerWidget::process_effect(Clip* c, Effect* e, double timecode, GLTexture
|
||||
}
|
||||
}
|
||||
|
||||
int motion_blur_prog = 0;
|
||||
int motion_blur_lim = 4;
|
||||
|
||||
GLuint ViewerWidget::compose_sequence(QVector<Clip*>& nests, bool render_audio) {
|
||||
Sequence* s = viewer->seq;
|
||||
long playhead = s->playhead;
|
||||
@@ -473,25 +476,7 @@ GLuint ViewerWidget::compose_sequence(QVector<Clip*>& nests, bool render_audio)
|
||||
glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
|
||||
glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
|
||||
|
||||
glBegin(GL_QUADS);
|
||||
|
||||
// calculate the Q coordinate
|
||||
/*double m1 = ((double)coords.vertexTopRightY - (double)coords.vertexBottomLeftY)/((double)coords.vertexTopRightX - (double)coords.vertexBottomLeftX);
|
||||
double c1 = (double)coords.vertexBottomLeftY - m1 * (double)coords.vertexBottomLeftX;
|
||||
double m2 = ((double)coords.vertexBottomRightY - (double)coords.vertexTopLeftY)/((double)coords.vertexBottomRightX - (double)coords.vertexTopLeftX);
|
||||
double c2 = (double)coords.vertexTopLeftY - m2 * (double)coords.vertexTopLeftX;
|
||||
double mid_x = (c2 - c1) / (m1 - m2);
|
||||
double mid_y = m1 * mid_x + c1;
|
||||
|
||||
double d0 = qSqrt(qPow(mid_x - (double)coords.vertexBottomLeftX, 2) + qPow(mid_y - (double)coords.vertexBottomLeftY, 2));
|
||||
double d1 = qSqrt(qPow((double)coords.vertexBottomRightX - mid_x, 2) + qPow(mid_y - (double)coords.vertexBottomRightY, 2));
|
||||
double d2 = qSqrt(qPow((double)coords.vertexTopRightX - mid_x, 2) + qPow((double)coords.vertexTopRightY - mid_y, 2));
|
||||
double d3 = qSqrt(qPow(mid_x - (double)coords.vertexTopLeftX, 2) + qPow((double)coords.vertexTopLeftY - mid_y, 2));
|
||||
|
||||
double q0 = (d0 + d2)/d2;
|
||||
double q1 = (d1 + d3)/d3;
|
||||
double q2 = (d2 + d0)/d0;
|
||||
double q3 = (d3 + d1)/d1;*/
|
||||
glBegin(GL_QUADS);
|
||||
|
||||
if (coords.grid_size <= 1) {
|
||||
glTexCoord2f(coords.textureTopLeftX, coords.textureTopLeftY); // top left
|
||||
@@ -545,6 +530,14 @@ GLuint ViewerWidget::compose_sequence(QVector<Clip*>& nests, bool render_audio)
|
||||
}
|
||||
|
||||
glPopMatrix();
|
||||
|
||||
/*GLfloat motion_blur_frac = (GLfloat) motion_blur_prog / (GLfloat) motion_blur_lim;
|
||||
if (motion_blur_prog == 0) {
|
||||
glAccum(GL_LOAD, motion_blur_frac);
|
||||
} else {
|
||||
glAccum(GL_ACCUM, motion_blur_frac);
|
||||
}
|
||||
motion_blur_prog++;*/
|
||||
}
|
||||
} else {
|
||||
if (render_audio || (config.enable_audio_scrubbing && audio_scrub)) {
|
||||
|
||||
Reference in New Issue
Block a user