Shader + Scratch Texture instance stays only in .exe

Godot Version

4.4.1

Question

Hello all!

I am a Computer Science student, and I have a game module. I started using Godot in December (2024) so I am fairly new.

Right now I have a bug that I cannot seem to solve.

When I export the .exe, and I run it on desktop (not the computer I use to code the game), it runs fine. But, with every other computer I have tested on I get the same bug.

So, for context, I have a mini game in my game that has a scratch texture. So how I set it up is two sprites on top of each other, and a scratch texture/shader is then used to scratch off the top sprite to reaveal what is below.

But, it’s like an instance is stored or something, because it only works the first time, after that it looks like the top sprite is already scratched off. Even with other mini games that uses the same code.

I am using queue.free() at the end of each mini game. But perhaps the instance stays? I have also played around with different export settings. I just can’t seem to find a way to fix it. I have also looked at the specs of each of these computers where it doesn’t run, and it seems normal.

I am happy to provide the code or .exe if anyone wants more information. This bug is impacting my marks, and I need to get it fixed before demo day (in November).

So for future reference, this is a good start, but you missed a couple of key pieces of information in asking your question. I’m going to assume that you have a Shader Resource inside a ShaderMaterial, and you are applying that ShaderMaterial to every object.

If so, your problem is that you only have a single instance of the Shader Resource. So when you scratch it off, it appear the same for every other object it is applied to. To solve this, you need to either right-click on the Shader Resource inside the ShaderMaterial for each object and select Make Unique, or you need to use duplicate() and make a new instance of the Shader Resource every time.

So, after many weeks of struggling, I finally fixed it.

  • Refresh mode of the subview port is set to refresh and then never.
  • Changed the colour of the subview port to #000000 (not sure if that was the issue, but it did seem to help).

I was already doing what you you had suggested.

Thanks for the response!

1 Like