Skip to main content

Indie game storeFree gamesFun gamesHorror games
Game developmentAssetsComics
SalesBundles
Jobs
TagsGame Engines
(2 edits)

i changed sprite_width and sprite_height to sprite_get_width(sprite_index) and sprite_get_height(sprite_index)I tried changing the texture of the noise sprite to not have the opacity it previously featured, so it should do it by one pixel (the project I'm working on is pretty low in resolution). However, it didn't seem to do anything.

Heres the code in my 'Draw' step right now:

moment += spd; 

if moment >= sprite_get_width(spr_noise){     moment = 0 } shader_set(shd_glitch) 

fnc_glitch_config(moment, spr_noise, sprite_get_width(sprite_index) / image_xscale, sprite_get_height(sprite_index) / image_yscale, 1, 1) 

draw_self() 

shader_reset()

is there a way i can export from the demo? What i mean is, import the sprite, do the glitch config through the demo, then copy+paste over to my game?

I can provide more information if necessary. 

(4 edits)

I tried your code, and first, it seems I didn’t explain the use of sprite_get_width and sprite_get_height correctly. Actually, you need to either divide sprite_width by image_xscale or use sprite_get_width(sprite_index). I just didn’t expect you to have image_xscale applied in your case. So, when using sprite_get_width, there’s no need to divide by scale.

As for the code: it’s correct, and the issue could come from two things—either the "separate texture page" option isn’t enabled for the sprite/noise, or it’s related to scaling, which I didn’t mention earlier. The thing is, if you scale the object that uses the shader, it will only display correctly at whole number scales. Using non-integer scaling will make the shader behave inaccurately, not pixel-perfect.

I was aware of this issue before, but honestly, I don’t know exactly why it happens or how to fix it—or if it even needs fixing, since pixel art rarely scales at non-integer values. If scaling is the issue, I’m afraid I can’t help much for now. As I mentioned, the only solution is to use whole numbers for scaling.

If the problem isn’t with the "separate texture page" setting and you aren’t using non-integer scaling, I’m not sure what else it could be, since everything works fine on my end with your code. Please send me the dimensions of the sprite you’re using with the shader. When I initially created the shader, I noticed some issues with specific dimensions and fixed them, but it’s possible your case wasn’t covered. However, I’m fairly certain the issue is either related to scaling or the "separate texture page" setting.

thanks so much! Turns out the issue was the noise sprite didn't have 'seperate texture page' turned on! It works perfectly now!!
Thanks for all your help!