Bloom shader rewrite.
This was SVN commit r13076.
This commit is contained in:
parent
9cd647a2a0
commit
21a70c0399
@ -1,107 +1,41 @@
|
||||
#version 110
|
||||
|
||||
varying vec2 v_tex;
|
||||
|
||||
uniform sampler2D renderedTex;
|
||||
|
||||
uniform vec2 texSize;
|
||||
|
||||
|
||||
void main()
|
||||
{
|
||||
#if BLOOM_NOP
|
||||
gl_FragColor = texture2D(renderedTex, v_tex);
|
||||
gl_FragColor.a = 1.0;
|
||||
#endif
|
||||
|
||||
#if BLOOM_PASS_H
|
||||
vec4 colour;
|
||||
|
||||
colour += texture2D(renderedTex, (gl_FragCoord.xy + vec2(-2.5, 0.0)) / texSize) * 0.05;
|
||||
colour += texture2D(renderedTex, (gl_FragCoord.xy + vec2(-1.5, 0.0)) / texSize) * 0.1;
|
||||
colour += texture2D(renderedTex, (gl_FragCoord.xy + vec2(-0.5, 0.0)) / texSize) * 0.2;
|
||||
colour += texture2D(renderedTex, (gl_FragCoord.xy + vec2( 0.0, 0.0)) / texSize) * 0.3;
|
||||
colour += texture2D(renderedTex, (gl_FragCoord.xy + vec2( 0.5, 0.0)) / texSize) * 0.2;
|
||||
colour += texture2D(renderedTex, (gl_FragCoord.xy + vec2( 1.5, 0.0)) / texSize) * 0.1;
|
||||
colour += texture2D(renderedTex, (gl_FragCoord.xy + vec2( 2.5, 0.0)) / texSize) * 0.05;
|
||||
|
||||
gl_FragColor.rgb = colour.rgb;
|
||||
vec4 colour = vec4(0.0);
|
||||
vec2 v_tex_offs = vec2(v_tex.x - 0.01, v_tex.y);
|
||||
|
||||
for (int i = 0; i < 6; ++i)
|
||||
{
|
||||
colour += texture2D(renderedTex, v_tex_offs);
|
||||
v_tex_offs += vec2(0.004, 0.0);
|
||||
}
|
||||
|
||||
gl_FragColor.rgb = colour.rgb / 6.0;
|
||||
gl_FragColor.a = 1.0;
|
||||
#endif
|
||||
|
||||
#if BLOOM_PASS_V
|
||||
vec4 colour;
|
||||
|
||||
colour += texture2D(renderedTex, (gl_FragCoord.xy + vec2(0.0, -2.5)) / texSize) * 0.05;
|
||||
colour += texture2D(renderedTex, (gl_FragCoord.xy + vec2(0.0, -1.5)) / texSize) * 0.1;
|
||||
colour += texture2D(renderedTex, (gl_FragCoord.xy + vec2(0.0, -0.5)) / texSize) * 0.2;
|
||||
colour += texture2D(renderedTex, (gl_FragCoord.xy + vec2(0.0, 0.0)) / texSize) * 0.3;
|
||||
colour += texture2D(renderedTex, (gl_FragCoord.xy + vec2(0.0, 0.5)) / texSize) * 0.2;
|
||||
colour += texture2D(renderedTex, (gl_FragCoord.xy + vec2(0.0, 1.5)) / texSize) * 0.1;
|
||||
colour += texture2D(renderedTex, (gl_FragCoord.xy + vec2(0.0, 2.5)) / texSize) * 0.05;
|
||||
|
||||
gl_FragColor.rgb = colour.rgb;
|
||||
vec4 colour = vec4(0.0);
|
||||
vec2 v_tex_offs = vec2(v_tex.x, v_tex.y - 0.01);
|
||||
|
||||
for (int i = 0; i < 6; ++i)
|
||||
{
|
||||
colour += texture2D(renderedTex, v_tex_offs);
|
||||
v_tex_offs += vec2(0.0, 0.004);
|
||||
}
|
||||
|
||||
gl_FragColor.rgb = colour.rgb / 6.0;
|
||||
gl_FragColor.a = 1.0;
|
||||
#endif
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
/*varying vec2 v_tex;
|
||||
|
||||
uniform sampler2D bgl_RenderedTexture;
|
||||
uniform sampler2D bgl_DepthTexture;
|
||||
uniform sampler2D bgl_LuminanceTexture;
|
||||
uniform float bgl_RenderedTextureWidth;
|
||||
uniform float bgl_RenderedTextureHeight;
|
||||
|
||||
#define PI 3.14159265
|
||||
|
||||
float width = bgl_RenderedTextureWidth; //texture width
|
||||
float height = bgl_RenderedTextureHeight; //texture height
|
||||
|
||||
vec2 texCoord = v_tex;
|
||||
vec2 texcoord = v_tex;
|
||||
|
||||
|
||||
float BRIGHT_PASS_THRESHOLD = 0.6;
|
||||
float BRIGHT_PASS_OFFSET = 0.6;
|
||||
|
||||
#define blurclamp 0.0015
|
||||
#define bias 0.01
|
||||
|
||||
#define KERNEL_SIZE 3.0
|
||||
|
||||
|
||||
|
||||
vec4 bright(vec2 coo)
|
||||
{
|
||||
vec4 color = texture2D(bgl_RenderedTexture, coo);
|
||||
|
||||
color = max(color - BRIGHT_PASS_THRESHOLD, 0.0);
|
||||
|
||||
return color / (color + BRIGHT_PASS_OFFSET);
|
||||
}
|
||||
|
||||
|
||||
void main0(void)
|
||||
{
|
||||
vec2 blur = vec2(clamp( bias, -blurclamp, blurclamp ));
|
||||
|
||||
vec4 col = vec4( 0, 0, 0, 0 );
|
||||
for ( float x = -KERNEL_SIZE + 1.0; x < KERNEL_SIZE; x += 1.0 )
|
||||
{
|
||||
for ( float y = -KERNEL_SIZE + 1.0; y < KERNEL_SIZE; y += 1.0 )
|
||||
{
|
||||
col += bright( texcoord + vec2( blur.x * x, blur.y * y ) );
|
||||
}
|
||||
}
|
||||
col /= ((KERNEL_SIZE+KERNEL_SIZE)-1.0)*((KERNEL_SIZE+KERNEL_SIZE)-1.0);
|
||||
|
||||
//gl_FragColor = col + texture2D(bgl_RenderedTexture, texcoord);
|
||||
|
||||
//col *= 0.9;
|
||||
gl_FragColor = 1.0 - (1.0 - col) * (1.0 - texture2D(bgl_RenderedTexture, texcoord));
|
||||
|
||||
}*/
|
||||
|
||||
}
|
@ -19,8 +19,6 @@ varying vec2 v_tex;
|
||||
|
||||
void main(void)
|
||||
{
|
||||
|
||||
|
||||
vec3 colour = texture2D(renderedTex, v_tex).rgb;
|
||||
vec3 bloomv2 = texture2D(blurTex2, v_tex).rgb;
|
||||
vec3 bloomv4 = texture2D(blurTex4, v_tex).rgb;
|
||||
@ -32,6 +30,8 @@ void main(void)
|
||||
|
||||
vec3 bloomv = (bloomv2 + bloomv4 + bloomv8) / 3.0;
|
||||
|
||||
bloomv = mix(bloomv, colour, bloom/0.2);
|
||||
|
||||
colour = max(bloomv, colour);
|
||||
|
||||
colour += vec3(brightness);
|
||||
@ -41,7 +41,6 @@ void main(void)
|
||||
colour += vec3(0.5);
|
||||
|
||||
colour = mix(vec3(dot(colour, vec3(0.299, 0.587, 0.114))), colour, saturation);
|
||||
|
||||
|
||||
gl_FragColor.rgb = colour;
|
||||
gl_FragColor.a = 1.0;
|
||||
|
Loading…
Reference in New Issue
Block a user