Hey guys I am having an issue with a shockwave effect I implemented into my game using this youtube tutorial from the gaming reverend @The Reverend . I noticed one of the comments mentioned there was an issue with other objects being drawn incorrectly while the shader was active and the creator said to make a thread here and tag him. I have noticed it when I am drawing things with transparency like the godrays in this example.
Here's a gif demonstrating the problem.
Shockwave changing godrays in background
I have checked the blend modes for the object and they seem to be written correctly and reset to normal but I haven't found the cause of the issue. I'm pretty inexperienced with shaders so i'm looking for help if possible.
Here's the post draw event code incase that helps
Many Thanks
Here's a gif demonstrating the problem.
Shockwave changing godrays in background
I have checked the blend modes for the object and they seem to be written correctly and reset to normal but I haven't found the cause of the issue. I'm pretty inexperienced with shaders so i'm looking for help if possible.
Here's the post draw event code incase that helps
GML:
/// @description Draw surface for shockwave
//Just draw the application surface if the list of waves is empty
//else draw the application surface distorted by the shader.
var wave_list_size = ds_list_size(list_of_waves)
if (wave_list_size <= 0)
{draw_surface(application_surface,0,0);}
else
{
//Set values
var fx_strength = 0.05;
var aberration = 1;
var subimage = 0;
//Create waves surface
if (!surface_exists(srf_waves))
{
srf_waves = surface_create(view_w * srf_waves_scale, view_h * srf_waves_scale);
tex_waves = surface_get_texture(srf_waves);
}
texture_set_interpolation(true);
//Draw wave sprite to wave surface
surface_set_target(srf_waves);
draw_clear_alpha($FF7F7F,1);
gpu_set_blendmode_ext(bm_dest_colour,bm_src_colour)
shader_set(shd_add_normals);
var w, this_wave;
//var wave_list_size = ds_list_size(list_of_waves)
for (w = 0; w < wave_list_size; w++)
{
this_wave = list_of_waves[|w];
draw_sprite_ext(sprite,subimage,
(this_wave[|waveparam.xx] - __view_get( e__VW.XView, 0 )) * srf_waves_scale,
(this_wave[|waveparam.yy] - __view_get( e__VW.YView, 0 )) * srf_waves_scale,
this_wave[|waveparam.scale] * srf_waves_scale,
this_wave[|waveparam.scale] * srf_waves_scale,
0, c_white, this_wave[|waveparam.alpha]);
}
shader_reset();
gpu_set_blendmode(bm_normal);
surface_reset_target();
//Draw application surface with waves as 2d texture;
shader_set(shader);
shader_set_uniform_f(u_fx_strength, fx_strength);
shader_set_uniform_f(u_aspect, aspect);
shader_set_uniform_f(u_aberration, aberration);
texture_set_stage(u_tex_waves, tex_waves);
draw_surface(application_surface, 0, 0);
shader_reset();
texture_set_interpolation(false);
}