Generic blur effect
This commit is contained in:
parent
5cfca250b1
commit
c5732c38ba
3 changed files with 58 additions and 0 deletions
37
Effects/blur.eff
Normal file
37
Effects/blur.eff
Normal file
|
@ -0,0 +1,37 @@
|
||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<PropertyList>
|
||||||
|
<name>Effects/blur</name>
|
||||||
|
<parameters>
|
||||||
|
<blurOffset_x>0.0</blurOffset_x>
|
||||||
|
<blurOffset_y>0.0</blurOffset_y>
|
||||||
|
<buffer-name></buffer-name>
|
||||||
|
</parameters>
|
||||||
|
<technique n="11">
|
||||||
|
<pass>
|
||||||
|
<texture-unit>
|
||||||
|
<unit>0</unit>
|
||||||
|
<type>buffer</type>
|
||||||
|
<name><use>buffer-name</use></name>
|
||||||
|
</texture-unit>
|
||||||
|
<program>
|
||||||
|
<vertex-shader>Shaders/blur.vert</vertex-shader>
|
||||||
|
<fragment-shader>Shaders/blur.frag</fragment-shader>
|
||||||
|
</program>
|
||||||
|
<uniform>
|
||||||
|
<name>input_tex</name>
|
||||||
|
<type>sampler-2d</type>
|
||||||
|
<value type="int">0</value>
|
||||||
|
</uniform>
|
||||||
|
<uniform>
|
||||||
|
<name>blurOffset_x</name>
|
||||||
|
<type>float</type>
|
||||||
|
<value type="float"><use>blurOffset_x</use></value>
|
||||||
|
</uniform>
|
||||||
|
<uniform>
|
||||||
|
<name>blurOffset_y</name>
|
||||||
|
<type>float</type>
|
||||||
|
<value type="float"><use>blurOffset_y</use></value>
|
||||||
|
</uniform>
|
||||||
|
</pass>
|
||||||
|
</technique>
|
||||||
|
</PropertyList>
|
17
Shaders/blur.frag
Normal file
17
Shaders/blur.frag
Normal file
|
@ -0,0 +1,17 @@
|
||||||
|
#version 120
|
||||||
|
uniform sampler2D input_tex;
|
||||||
|
uniform vec2 fg_BufferSize;
|
||||||
|
uniform float blurOffset_x;
|
||||||
|
uniform float blurOffset_y;
|
||||||
|
const float f[5] = float[](0.0, 1.0, 2.0, 3.0, 4.0);
|
||||||
|
const float w[5] = float[](0.2270270270, 0.1945945946, 0.1216216216, 0.0540540541, 0.0162162162 );
|
||||||
|
void main() {
|
||||||
|
vec2 blurOffset = vec2(blurOffset_x, blurOffset_y) / fg_BufferSize;
|
||||||
|
vec2 coords = gl_TexCoord[0].xy;
|
||||||
|
vec4 color = vec4( texture2D( input_tex, coords + f[0] * blurOffset ).rgb * w[0], 1.0 );
|
||||||
|
for (int i=1; i<5; ++i ) {
|
||||||
|
color.rgb += texture2D( input_tex, coords - f[i] * blurOffset ).rgb * w[i];
|
||||||
|
color.rgb += texture2D( input_tex, coords + f[i] * blurOffset ).rgb * w[i];
|
||||||
|
}
|
||||||
|
gl_FragColor = color;
|
||||||
|
}
|
4
Shaders/blur.vert
Normal file
4
Shaders/blur.vert
Normal file
|
@ -0,0 +1,4 @@
|
||||||
|
void main() {
|
||||||
|
gl_Position = gl_Vertex;
|
||||||
|
gl_TexCoord[0] = gl_MultiTexCoord0;
|
||||||
|
}
|
Loading…
Reference in a new issue