bgfx/examples/23-vectordisplay/fs_vectordisplay_blur.sc

32 lines
1.4 KiB
Python
Raw Normal View History

2014-11-15 19:10:44 -05:00
$input v_color0, v_texcoord0
#include <bgfx_shader.sh>
2015-05-28 18:27:00 -04:00
SAMPLER2D(s_texColor, 0);
2014-11-15 19:10:44 -05:00
2015-05-28 18:27:00 -04:00
uniform vec4 u_params;
#define u_blur_scale u_params.xy
#define u_compose_mult u_params.z
#define u_compose_alpha u_params.w
2014-11-15 19:10:44 -05:00
2015-05-28 18:27:00 -04:00
void main()
{
vec4 color;
color = texture2D(s_texColor, vec2(v_texcoord0.x-4.0*u_blur_scale.x, v_texcoord0.y-4.0*u_blur_scale.y))*0.05;
color += texture2D(s_texColor, vec2(v_texcoord0.x-3.0*u_blur_scale.x, v_texcoord0.y-3.0*u_blur_scale.y))*0.09;
color += texture2D(s_texColor, vec2(v_texcoord0.x-2.0*u_blur_scale.x, v_texcoord0.y-2.0*u_blur_scale.y))*0.12;
color += texture2D(s_texColor, vec2(v_texcoord0.x-1.0*u_blur_scale.x, v_texcoord0.y-1.0*u_blur_scale.y))*0.15;
color += texture2D(s_texColor, vec2(v_texcoord0.x+0.0*u_blur_scale.x, v_texcoord0.y+0.0*u_blur_scale.y))*0.16;
color += texture2D(s_texColor, vec2(v_texcoord0.x+1.0*u_blur_scale.x, v_texcoord0.y+1.0*u_blur_scale.y))*0.15;
color += texture2D(s_texColor, vec2(v_texcoord0.x+2.0*u_blur_scale.x, v_texcoord0.y+2.0*u_blur_scale.y))*0.12;
color += texture2D(s_texColor, vec2(v_texcoord0.x+3.0*u_blur_scale.x, v_texcoord0.y+3.0*u_blur_scale.y))*0.09;
color += texture2D(s_texColor, vec2(v_texcoord0.x+4.0*u_blur_scale.x, v_texcoord0.y+4.0*u_blur_scale.y))*0.05;
2014-11-15 19:10:44 -05:00
2015-05-28 18:27:00 -04:00
gl_FragColor = color
* vec4(u_compose_mult
, u_compose_mult
, u_compose_mult
, u_compose_mult * u_compose_alpha
);
2014-11-15 19:10:44 -05:00
}