Shader gaps when using gpu_set_texrepeat(true);

cordon

Member
I have spent a good 12 hours working with shaders at this point.
The main problem I have is while I do have the desired look and feel of my shader (used for fog), there are gaps in the middle and on the sides of the shader.
This is not the desired effect, and I cannot for the life of me figure out what to do to fix it.
yoyo games query.png
Is there a setting I need to change to make the shader not have gaps and fill the whole rectangle? Any help would be great!
 

cordon

Member
btw, heres my code
//Create
uniTime = shader_get_uniform(shader_wave, "time");
//Draw
shader_set(shader_wave);
gpu_set_texrepeat(true);
gpu_set_tex_filter(false);
shader_set_uniform_f(uniTime,current_time/5000);
draw_self();
shader_reset();

//Shader code:
varying vec2 v_vTexcoord; //x,y
varying vec4 v_vColour; //r,g,b,a

uniform float time;//time in ms

void main()
{
float xoffset = 0.02*sin(time*3.0+12.0*v_vTexcoord.y);
float yoffset = 0.06*(1.0+cos(time*.9+25.0*v_vTexcoord.x));
gl_FragColor = vec4(.6,.6,.6,.3) * texture2D(gm_BaseTexture, vec2(v_vTexcoord.x+xoffset, -1.0*(0.6 - v_vTexcoord.y+ yoffset)));
}
 

Gizmo199

Member
Looks like the issue is that it is rippling a single texture (image) from the texture page, and on the other sides of that texture are other single textures (or lack thereof).

Pretty much the UVs of 'gm_BaseTexture' is trying to pull pixels from outside the sprites dimensions to smear into it. This is a classic shader delimna but usually can be fixed using either a surface, or by tiling sprites.

Instead of using 'draw_self()' and gpu_texrepeat you could try 'draw_sprite_tiled' and then set the shader. Not at my computer right now so unfortunately I cant test anything but lmk if that helps/works! :)

Edit: this might not be exactly the case but that's what it looks like to me. :p

Edit2: also, if you are wanting just a rectangle / small area you could use a surface and draw the tiled sprite with the shader to the surface. Something like:
GML:
surface_set_target(fogsurf)
shader_set(fog_shader)
draw_sprite_tiled_ext(...);
shader_reset();

draw_surface(fogsurf, fogx, fogy)
 
Last edited:
Top