added directional blur
This commit is contained in:
@@ -46,6 +46,6 @@ void main(void) {
|
||||
gl_FragColor += texture2D(image, (vec2(gl_FragCoord.x, gl_FragCoord.y+i))/resolution)*(divider);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,26 @@
|
||||
#version 110
|
||||
|
||||
#define M_PI 3.1415926535897932384626433832795
|
||||
|
||||
uniform sampler2D image;
|
||||
|
||||
uniform float angle;
|
||||
uniform float length;
|
||||
|
||||
uniform vec2 resolution;
|
||||
|
||||
void main(void) {
|
||||
float degrees = (angle*M_PI)/180.0;
|
||||
float divider = 1.0 / ((length*2.0)+1.0);
|
||||
float sin_angle = sin(degrees);
|
||||
float cos_angle = cos(degrees);
|
||||
|
||||
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);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,10 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<effect name="Directional Blur" category="Blur">
|
||||
<row name="Length">
|
||||
<field type="double" min="0" default="10" id="length"/>
|
||||
</row>
|
||||
<row name="Angle">
|
||||
<field type="double" default="0" id="angle"/>
|
||||
</row>
|
||||
<shader vert="common.vert" frag="directionalblur.frag"/>
|
||||
</effect>
|
||||
Reference in New Issue
Block a user