gats1212
Member
Hey guys. I'm using a blur shader to ehh blur layers that are closer to the camera. However this process is not working as intended because there are grey outlines.
However I was looking why is this happening and I found that this happens because the blur shader is not intended for transparent images or surfaces. How can I fix this? I tried multiplying the RGB with the alpha.
And this is how I use it:
However I was looking why is this happening and I found that this happens because the blur shader is not intended for transparent images or surfaces. How can I fix this? I tried multiplying the RGB with the alpha.
Code:
const int Quality = 16;
const float Distance = 0.1;
const int Directions = 32;
varying vec2 v_vTexcoord;
varying vec4 v_vColour;
const float Pi = 3.14159265359;
const float Tau = Pi*2.0;
void main() {
vec4 Color;
vec4 TempColor;
for(float dir = 0.0;dir<1.0;dir+=1.0/float(Directions)) {
float xvar = (Distance*2.0+Distance)*sin(dir*Tau);
float yvar = (Distance*2.0+Distance)*cos(dir*Tau);
for(float i = 0.0;i < 1.0;i+=1.0/float(Quality)) {
float dis = i*Distance;
TempColor = texture2D(gm_BaseTexture,vec2(v_vTexcoord.x+xvar*dis,v_vTexcoord.y+yvar*dis));
TempColor.rgb *=TempColor.a;
Color += TempColor;
}
}
Color /= float(Quality)*float(Directions)+1.0;
gl_FragColor = Color *v_vColour;
}
Code:
var xx=camera_get_view_width(view_camera[0])*2;
var yy=camera_get_view_height(view_camera[0])*2;
if !surface_exists(surface_front1) {
surface_front1=surface_create(xx,yy);
}
if !surface_exists(surface_front2) {
surface_front2=surface_create(xx,yy);
}
surface_set_target(surface_front1);
draw_clear_alpha(c_white,0);
draw_tilemap(front_tile,-camera_get_view_x(view_camera[0]),-camera_get_view_y(view_camera[0]));
surface_reset_target();
surface_set_target(surface_front2);
draw_clear_alpha(c_white,0);
shader_set(shd_blur_simple);
draw_surface(surface_front1,0,0);
shader_reset();
surface_reset_target();
draw_surface_ext(surface_front2,camera_get_view_x(view_camera[0]),camera_get_view_y(view_camera[0]),1,1,0,c_white,1);
Attachments
-
33.3 KB Views: 7