Added Gaussian blur post-process shader
Added ability to manually input values in post-process shader menu
This commit is contained in:
@@ -9,21 +9,18 @@ uniform sampler2DRect RenderTexture;
|
||||
uniform float bloomStrength;
|
||||
|
||||
varying vec4 gl_TexCoord[gl_MaxTextureCoords];
|
||||
|
||||
float blurWeights[4] = float[4](.05,.1,.2,.3);
|
||||
|
||||
void main(void)
|
||||
{
|
||||
float blurWeights[7];
|
||||
blurWeights[0] = 0.05;
|
||||
blurWeights[1] = 0.1;
|
||||
blurWeights[2] = 0.2;
|
||||
blurWeights[3] = 0.3;
|
||||
blurWeights[4] = 0.2;
|
||||
blurWeights[5] = 0.1;
|
||||
blurWeights[6] = 0.05;
|
||||
|
||||
vec3 color = vec3(0,0,0);
|
||||
for (int i = 0; i < 7; i++){
|
||||
color += vec3(texture2DRect(RenderTexture, gl_TexCoord[i].st)) * blurWeights[i];
|
||||
}
|
||||
vec3 color = blurWeights[0] * texture2DRect(RenderTexture, gl_TexCoord[0].st).rgb;
|
||||
color+= blurWeights[1] * texture2DRect(RenderTexture, gl_TexCoord[1].st).rgb;
|
||||
color+= blurWeights[2] * texture2DRect(RenderTexture, gl_TexCoord[2].st).rgb;
|
||||
color+= blurWeights[3] * texture2DRect(RenderTexture, gl_TexCoord[3].st).rgb;
|
||||
color+= blurWeights[2] * texture2DRect(RenderTexture, gl_TexCoord[4].st).rgb;
|
||||
color+= blurWeights[1] * texture2DRect(RenderTexture, gl_TexCoord[5].st).rgb;
|
||||
color+= blurWeights[0] * texture2DRect(RenderTexture, gl_TexCoord[6].st).rgb;
|
||||
|
||||
color *= bloomStrength;
|
||||
|
||||
|
||||
@@ -0,0 +1,28 @@
|
||||
uniform sampler2DRect RenderTexture;
|
||||
uniform int horizontalPass;
|
||||
|
||||
uniform float offset[2] = float[2]( 1.3846153846, 3.2307692308 );
|
||||
uniform float weight[3] = float[3]( 0.2270270270, 0.3162162162, 0.0702702703 );
|
||||
|
||||
void main(void)
|
||||
{
|
||||
vec4 color = texture2DRect(RenderTexture, gl_TexCoord[0].st)*weight[0];
|
||||
|
||||
|
||||
if(horizontalPass == 1)
|
||||
{
|
||||
color += weight[1] * texture2DRect(RenderTexture, vec2(gl_TexCoord[0].x+offset[0],gl_TexCoord[0].y));
|
||||
color += weight[1] * texture2DRect(RenderTexture, vec2(gl_TexCoord[0].x-offset[0],gl_TexCoord[0].y));
|
||||
color += weight[2] * texture2DRect(RenderTexture, vec2(gl_TexCoord[0].x+offset[1],gl_TexCoord[0].y));
|
||||
color += weight[2] * texture2DRect(RenderTexture, vec2(gl_TexCoord[0].x-offset[1],gl_TexCoord[0].y));
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
color += weight[1] * texture2DRect(RenderTexture, vec2(gl_TexCoord[0].x,gl_TexCoord[0].y+offset[0]));
|
||||
color += weight[1] * texture2DRect(RenderTexture, vec2(gl_TexCoord[0].x,gl_TexCoord[0].y-offset[0]));
|
||||
color += weight[2] * texture2DRect(RenderTexture, vec2(gl_TexCoord[0].x,gl_TexCoord[0].y+offset[1]));
|
||||
color += weight[2] * texture2DRect(RenderTexture, vec2(gl_TexCoord[0].x,gl_TexCoord[0].y-offset[1]));
|
||||
}
|
||||
gl_FragColor = color;
|
||||
}
|
||||
Reference in New Issue
Block a user