optimized blur and added effects
This commit is contained in:
@@ -9,8 +9,6 @@ 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;
|
||||
|
||||
@@ -9,8 +9,5 @@
|
||||
<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>
|
||||
@@ -0,0 +1,22 @@
|
||||
#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) {
|
||||
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);
|
||||
|
||||
gl_FragColor = vec4(rValue.r, gValue.g, bValue.b, texture2D(tex, vTexCoord).a);
|
||||
}
|
||||
@@ -0,0 +1,13 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<effect name="Chromatic Aberration" category="Stylize">
|
||||
<row name="Red Amount">
|
||||
<field type="double" default="350" id="red_amount"/>
|
||||
</row>
|
||||
<row name="Green Amount">
|
||||
<field type="double" default="-40" id="green_amount"/>
|
||||
</row>
|
||||
<row name="Blue Amount">
|
||||
<field type="double" default="-250" id="blue_amount"/>
|
||||
</row>
|
||||
<shader vert="common.vert" frag="chromaticaberration.frag"/>
|
||||
</effect>
|
||||
@@ -0,0 +1,44 @@
|
||||
#version 110
|
||||
|
||||
uniform sampler2D tex0;
|
||||
uniform float time;
|
||||
uniform vec2 resolution;
|
||||
uniform float stitching_size;
|
||||
uniform bool invert;
|
||||
|
||||
varying vec2 vTexCoord;
|
||||
|
||||
vec4 PostFX(sampler2D tex, vec2 uv, float time) {
|
||||
vec4 c = vec4(0.0);
|
||||
float size = stitching_size;
|
||||
vec2 cPos = uv * resolution;
|
||||
vec2 tlPos = floor(cPos / vec2(size, size));
|
||||
tlPos *= size;
|
||||
int remX = int(mod(cPos.x, size));
|
||||
int remY = int(mod(cPos.y, size));
|
||||
if (remX == 0 && remY == 0)
|
||||
tlPos = cPos;
|
||||
vec2 blPos = tlPos;
|
||||
blPos.y += (size - 1.0);
|
||||
if ((remX == remY) ||
|
||||
(((int(cPos.x) - int(blPos.x)) == (int(blPos.y) - int(cPos.y)))))
|
||||
{
|
||||
if (!invert)
|
||||
c = vec4(0.2, 0.15, 0.05, 1.0);
|
||||
else
|
||||
c = texture2D(tex, tlPos * vec2(1.0/resolution.x, 1.0/resolution.y)) * 1.4;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (!invert)
|
||||
c = texture2D(tex, tlPos * vec2(1.0/resolution.x, 1.0/resolution.y)) * 1.4;
|
||||
else
|
||||
c = vec4(0.0, 0.0, 0.0, 1.0);
|
||||
}
|
||||
return c;
|
||||
}
|
||||
|
||||
void main(void) {
|
||||
vec2 uv = vTexCoord;
|
||||
gl_FragColor = PostFX(tex0, uv, time);
|
||||
}
|
||||
@@ -0,0 +1,10 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<effect name="Cross Stitch" category="Stylize">
|
||||
<row name="Size">
|
||||
<field type="double" default="6" id="stitching_size"/>
|
||||
</row>
|
||||
<row name="Invert">
|
||||
<field type="bool" default="0" id="invert"/>
|
||||
</row>
|
||||
<shader vert="common.vert" frag="crossstitch.frag"/>
|
||||
</effect>
|
||||
@@ -10,17 +10,18 @@ uniform float length;
|
||||
uniform vec2 resolution;
|
||||
|
||||
void main(void) {
|
||||
float radians = (angle*M_PI)/180.0;
|
||||
float divider = 1.0 / ((length*2.0)+1.0);
|
||||
float sin_angle = sin(radians);
|
||||
float cos_angle = cos(radians);
|
||||
if (length > 0.0) {
|
||||
float radians = (angle*M_PI)/180.0;
|
||||
float divider = 1.0 / length;
|
||||
float sin_angle = sin(radians);
|
||||
float cos_angle = cos(radians);
|
||||
|
||||
gl_FragColor = texture2D(image, gl_FragCoord.xy/resolution)*(divider);
|
||||
for (float i=1.0;i<=length;i++) {
|
||||
float y = sin_angle * i;
|
||||
float x = cos_angle * i;
|
||||
|
||||
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);
|
||||
for (float i=-length+0.5;i<=length;i+=2.0) {
|
||||
float y = sin_angle * i;
|
||||
float x = cos_angle * i;
|
||||
gl_FragColor += texture2D(image, vec2(gl_FragCoord.x+x, gl_FragCoord.y+y)/resolution)*(divider);
|
||||
}
|
||||
} else {
|
||||
gl_FragColor = texture2D(image, gl_FragCoord.xy/resolution);
|
||||
}
|
||||
}
|
||||
+15
-46
@@ -10,6 +10,8 @@ uniform vec2 resolution;
|
||||
uniform bool horiz_blur;
|
||||
uniform bool vert_blur;
|
||||
|
||||
uniform bool opt;
|
||||
|
||||
float gaussian(float x, float sigma) {
|
||||
return (1.0/(sigma*sqrt(2.0*M_PI)))*exp(-0.5*pow(x/sigma, 2.0));
|
||||
}
|
||||
@@ -22,56 +24,23 @@ void main(void) {
|
||||
if (radius == 0.0 || sigma == 0.0 || (!horiz_blur && !vert_blur)) {
|
||||
gl_FragColor = texture2D(image, gl_FragCoord.xy/resolution);
|
||||
} else {
|
||||
float middleWeight = gaussian(0.0, sigma);
|
||||
float sum = middleWeight;
|
||||
float rad = floor(radius);
|
||||
float x_rad = horiz_blur ? rad : 0.5;
|
||||
float y_rad = vert_blur ? rad : 0.5;
|
||||
|
||||
if (horiz_blur && vert_blur) {
|
||||
for (float i=1.0;i<=radius;i++) {
|
||||
sum += (4.0*gaussian2(i, 0.0, sigma));
|
||||
}
|
||||
float sum = 0.0;
|
||||
|
||||
for (float x=1.0;x<=radius;x++) {
|
||||
for (float y=1.0;y<=radius;y++) {
|
||||
sum += (4.0*gaussian2(x, y, sigma));
|
||||
}
|
||||
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) {
|
||||
sum += gaussian2(x, y, sigma);
|
||||
}
|
||||
|
||||
gl_FragColor = texture2D(image, gl_FragCoord.xy/resolution)*(middleWeight/sum);
|
||||
}
|
||||
|
||||
for (float i=1.0;i<=radius;i++) {
|
||||
float weight = (gaussian2(i, 0.0, sigma)/sum);
|
||||
gl_FragColor += texture2D(image, (vec2(gl_FragCoord.x-i, gl_FragCoord.y))/resolution)*(weight);
|
||||
gl_FragColor += texture2D(image, (vec2(gl_FragCoord.x+i, gl_FragCoord.y))/resolution)*(weight);
|
||||
gl_FragColor += texture2D(image, (vec2(gl_FragCoord.x, gl_FragCoord.y+i))/resolution)*(weight);
|
||||
gl_FragColor += texture2D(image, (vec2(gl_FragCoord.x, gl_FragCoord.y-i))/resolution)*(weight);
|
||||
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) {
|
||||
float weight = (gaussian2(x, y, sigma)/sum);
|
||||
gl_FragColor += texture2D(image, (vec2(gl_FragCoord.x+x, gl_FragCoord.y+y))/resolution)*(weight);
|
||||
}
|
||||
|
||||
for (float x=1.0;x<=radius;x++) {
|
||||
for (float y=1.0;y<=radius;y++) {
|
||||
float weight = (gaussian2(x, y, sigma)/sum);
|
||||
gl_FragColor += texture2D(image, (vec2(gl_FragCoord.x-x, gl_FragCoord.y-y))/resolution)*(weight);
|
||||
gl_FragColor += texture2D(image, (vec2(gl_FragCoord.x+x, gl_FragCoord.y+y))/resolution)*(weight);
|
||||
gl_FragColor += texture2D(image, (vec2(gl_FragCoord.x-x, gl_FragCoord.y+y))/resolution)*(weight);
|
||||
gl_FragColor += texture2D(image, (vec2(gl_FragCoord.x+x, gl_FragCoord.y-y))/resolution)*(weight);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
for (float i=1.0;i<=radius;i++) {
|
||||
sum += (2.0*gaussian(i, sigma));
|
||||
}
|
||||
|
||||
gl_FragColor = texture2D(image, gl_FragCoord.xy/resolution)*(middleWeight/sum);
|
||||
|
||||
for (float i=1.0;i<=radius;i++) {
|
||||
float weight = gaussian(i, sigma)/sum;
|
||||
if (horiz_blur) {
|
||||
gl_FragColor += texture2D(image, (vec2(gl_FragCoord.x-i, gl_FragCoord.y))/resolution)*(weight);
|
||||
gl_FragColor += texture2D(image, (vec2(gl_FragCoord.x+i, gl_FragCoord.y))/resolution)*(weight);
|
||||
} else {
|
||||
gl_FragColor += texture2D(image, (vec2(gl_FragCoord.x, gl_FragCoord.y-i))/resolution)*(weight);
|
||||
gl_FragColor += texture2D(image, (vec2(gl_FragCoord.x, gl_FragCoord.y+i))/resolution)*(weight);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -12,5 +12,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="gaussianblur.frag"/>
|
||||
</effect>
|
||||
+15
-17
@@ -10,26 +10,24 @@ uniform float center_y;
|
||||
uniform vec2 resolution;
|
||||
|
||||
void main(void) {
|
||||
vec2 distance = vec2((gl_FragCoord.x - (resolution.x/2.0) - center_x), (gl_FragCoord.y - (resolution.y/2.0) - center_y));
|
||||
if (radius > 0.0) {
|
||||
vec2 distance = vec2((gl_FragCoord.x - (resolution.x/2.0) - center_x), (gl_FragCoord.y - (resolution.y/2.0) - center_y));
|
||||
|
||||
float angle = atan(distance.y/distance.x);
|
||||
float sin_angle = sin(angle);
|
||||
float cos_angle = cos(angle);
|
||||
float angle = atan(distance.y/distance.x);
|
||||
float sin_angle = sin(angle);
|
||||
float cos_angle = cos(angle);
|
||||
|
||||
//float multiplier = pow(length((2.0 * (distance / resolution)) - 1.0), 2.0);
|
||||
float multiplier = length(distance/resolution);
|
||||
float multiplier = length(distance/resolution);
|
||||
|
||||
float limit = radius * multiplier;
|
||||
float limit = ceil(radius * multiplier);
|
||||
|
||||
float divider = 1.0 / ((floor(limit)*2.0)+1.0);
|
||||
|
||||
gl_FragColor = texture2D(image, gl_FragCoord.xy/resolution)*(divider);
|
||||
|
||||
for (float i=1.0;i<=limit;i++) {
|
||||
float y = sin_angle * i;
|
||||
float x = cos_angle * i;
|
||||
|
||||
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);
|
||||
float divider = 1.0 / limit;
|
||||
for (float i=-limit+0.5;i<=limit;i+=2.0) {
|
||||
float y = sin_angle * i;
|
||||
float x = cos_angle * i;
|
||||
gl_FragColor += texture2D(image, vec2(gl_FragCoord.x+x, gl_FragCoord.y+y)/resolution)*(divider);
|
||||
}
|
||||
} else {
|
||||
gl_FragColor = texture2D(image, gl_FragCoord.xy/resolution);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,27 @@
|
||||
#version 110
|
||||
|
||||
uniform sampler2D sceneTex; // 0
|
||||
uniform float lensRadiusX;
|
||||
uniform float lensRadiusY;
|
||||
uniform bool circular;
|
||||
uniform vec2 resolution;
|
||||
// uniform vec2 lensRadius; // 0.45, 0.38
|
||||
|
||||
varying vec2 vTexCoord;
|
||||
|
||||
void main(void) {
|
||||
if (lensRadiusX == 0.0) {
|
||||
discard;
|
||||
}
|
||||
vec4 c = texture2D(sceneTex, vTexCoord);
|
||||
vec2 vignetteCoord = vTexCoord;
|
||||
if (circular) {
|
||||
float ar = (resolution.x/resolution.y);
|
||||
vignetteCoord.x *= ar;
|
||||
vignetteCoord.x -= (1.0-(1.0/ar));
|
||||
}
|
||||
float dist = distance(vignetteCoord, vec2(0.5,0.5));
|
||||
float size = (lensRadiusX*0.01);
|
||||
c *= smoothstep(size, size*0.99*(1.0-lensRadiusY*0.01), dist);
|
||||
gl_FragColor = c;
|
||||
}
|
||||
@@ -0,0 +1,13 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<effect name="Vignette" category="Stylize">
|
||||
<row name="Size">
|
||||
<field type="double" min="0" default="45" id="lensRadiusX"/>
|
||||
</row>
|
||||
<row name="Softness">
|
||||
<field type="double" min="0" default="38" id="lensRadiusY"/>
|
||||
</row>
|
||||
<row name="Circular">
|
||||
<field type="bool" default="false" id="circular"/>
|
||||
</row>
|
||||
<shader vert="common.vert" frag="vignette.frag"/>
|
||||
</effect>
|
||||
+2
-2
@@ -59,7 +59,7 @@ void MainWindow::setup_layout(bool reset) {
|
||||
|
||||
bool load_default = true;
|
||||
|
||||
if (!reset) {
|
||||
/*if (!reset) {
|
||||
QFile panel_config(get_data_path() + "/layout");
|
||||
if (panel_config.exists() && panel_config.open(QFile::ReadOnly)) {
|
||||
if (restoreState(panel_config.readAll(), 0)) {
|
||||
@@ -67,7 +67,7 @@ void MainWindow::setup_layout(bool reset) {
|
||||
}
|
||||
panel_config.close();
|
||||
}
|
||||
}
|
||||
}*/
|
||||
|
||||
if (load_default) {
|
||||
addDockWidget(Qt::TopDockWidgetArea, panel_project);
|
||||
|
||||
Reference in New Issue
Block a user