Tyg
Member
Most blur shaders use repeatedly copying the image and shifting it which is pretty demanding and inefficient
Gamemaker has some functions that make it super easy
create a shader
in your objects draw event
sha = Blur;
gpu_set_tex_mip_enable(mip_on); // turn mipmapping on
gpu_set_tex_filter(tf_anisotropic); // anisotropic so its not chunky
shader_set(sha);
shader_set_uniform_f(shader_get_uniform(sha,"iTime"), current_time/1000); // Only needed if you want to do things like pulse the blur
shader_set_uniform_f(shader_get_uniform(sha,"iBlur"), 6); // can be a variable or even put in the shader instead of a uniform
draw_self();
shader_reset();
gpu_set_tex_mip_enable(mip_off); // turn off mipmapping
the shader:
varying vec2 v_vTexcoord;
varying vec4 v_vColour;
uniform float iBlur; // can be a var instead of a uniform
uniform float iTime; // not required
void main()
{
// float ti = fract(iTime)*10.; // not required but can be used for changeing blur or use sin() function for pulsating
gl_FragColor = v_vColour * texture2D( gm_BaseTexture, v_vTexcoord, iBlur ); // all you need to do is have the 3rd paramater bias (iBlur) which works now that we have mippmapping on can also iBlur*ti or just ti for 3rd parameter
}
blur values should be between 0.0 and 9.0
You could also use this to make LOD functions within the shader
Gamemaker has some functions that make it super easy
create a shader
in your objects draw event
sha = Blur;
gpu_set_tex_mip_enable(mip_on); // turn mipmapping on
gpu_set_tex_filter(tf_anisotropic); // anisotropic so its not chunky
shader_set(sha);
shader_set_uniform_f(shader_get_uniform(sha,"iTime"), current_time/1000); // Only needed if you want to do things like pulse the blur
shader_set_uniform_f(shader_get_uniform(sha,"iBlur"), 6); // can be a variable or even put in the shader instead of a uniform
draw_self();
shader_reset();
gpu_set_tex_mip_enable(mip_off); // turn off mipmapping
the shader:
varying vec2 v_vTexcoord;
varying vec4 v_vColour;
uniform float iBlur; // can be a var instead of a uniform
uniform float iTime; // not required
void main()
{
// float ti = fract(iTime)*10.; // not required but can be used for changeing blur or use sin() function for pulsating
gl_FragColor = v_vColour * texture2D( gm_BaseTexture, v_vTexcoord, iBlur ); // all you need to do is have the 3rd paramater bias (iBlur) which works now that we have mippmapping on can also iBlur*ti or just ti for 3rd parameter
}
blur values should be between 0.0 and 9.0
You could also use this to make LOD functions within the shader