Balatro Shader Problem

I made a Balatro-style animated background shader for my test game.

It`s playable here(a lot of bugs in the game, so just look at the background)

On most devices it works great, but on some phones I see strange glitches . I used AI to help optimize it for mobile.

example.zip (331.0 KB)

I’m pretty new to shaders (still learning the basics), so I might be missing something simple.
Any ideas on common gotchas that could cause this across devices?

Screenshots of bad glitches are attached.

1 Like

What’s the “glitch” is about?

Here how it works for me:

I see the screenshots you attached distort the background effect, perhaps it’s a resolution problem. Do you have access to a device on which it is not working? Try debugging what values you are passing to the shader.

Check if you can get rid of a branch if (U_B(u_polar_coordinates)) - maybe you can create two versions of the shader with and without them?

I think you can remove #define FRAGCOLOR gl_FragColor and just leave gl_FragColor in fp too, don’t see much sense in this define.

The most suspicious to me is the iResolution, so please debug and check if you set it correctly on those devices, maybe they fall back to some defaults in code in some circumstances?

You can also try lowering the precision of some variables (e.g. from highp to mediump). If some variables are not changed during your game - change them to defines.

2 Likes

Thanks a lot for taking a look and for all the pointers! I’ll try your suggestions: debug the values I pass to the shader (esp. iResolution), remove the FRAGCOLOR define, test a version without the if (U_B(u_polar_coordinates)) branch, and play with precision / turning constants into #defines.

I don’t currently have a failing device on hand - the glitches only show up in external playtests on multiple models. I also suspect a resolution/viewport issue, but I’m not sure how to test this properly or where to start. Any quick tips on validating iResolution across devices, or on simulating “odd” aspect ratios/DPI locally in Defold?

1 Like

when you say “models”, I’m thinking your’re talking about mobile?
Have you tested running it via Android Studio? There you can setup different test models and choose the graphics card (if I recall correctly). Perhaps that’s a way for you to reproduce it.

2 Likes