I figured it out!<br><br>Huge thanks to @Alex-doc!<br><br>It turns out the problem lies in floating point values and rounding!<br><br>Here's how I fixed it. I have little experience on shaders, and how Godot works internally, so this is mostly my observations and speculations.<br>
(Once again, huge thanks to @Alex-doc for suggesting to change the alpha value!)<br><br>When I changed the alpha value to 0.5, I observed that the sprite was at half it's alpha value despite being in the proper colored mask. That lead me to try a few things, like changing the sprites modulation values (both the circle and the mask), and using textured sprites, with no apparent difference.<br><br>However, when I opened the project to test the different alpha value, I noticed the shader wasn't working in the editor. The only way I could get it to work again was to change the object color field in the material, then it worked like normal. It even worked when all I did was set the color to the exact same color using the color picker. This led me to try using the remote inspector and changing the object color in the material at run time. Similar to the editor, it worked fine and the shader was performing like it should.<br><br>I thought that was rather strange, and wondered if the editor wasn't saving the color properly, so I dug around the project files using a text editor. After making my way from the scene to the shader material, I discovered that the color saved was a more precise in number than what I printed out. So I double checked the printed color (the mask color) and noticed that they didn't match up. The printed color was rounded down a few digits more than the saved color.<br><br>It hit me that perhaps the color inputted to the material gets truncated down when it's loaded, and so the colors aren't exactly the same in value. So I adjusted the shader to work in a range instead of a equal check, and it works in the editor and while running! Problem solved!<br><br>I'm guessing that GD script (or C++) uses less bits in its floating point values than Godot's shader language. I think that's why the shader wasn't working and why it works now.<br>
<br>Here's the updated shader!<br>(released under CC0 in case anyone is wondering)<br>
uniform color Object_color;<br>uniform float Range;<br><br>if (texscreen(SCREEN_UV).r >= Object_color.r - Range && texscreen(SCREEN_UV).r <= Object_color.r + Range)<br>{<br> if (texscreen(SCREEN_UV).g >= Object_color.g - Range && texscreen(SCREEN_UV).g <= Object_color.g + Range)<br> {<br> if (texscreen(SCREEN_UV).b >= Object_color.b - Range && texscreen(SCREEN_UV).b <= Object_color.b + Range)<br> {<br> COLOR.a = tex(TEXTURE, UV).a;<br> }<br> else<br> {<br> COLOR.w = 0;<br> }<br> }<br> else<br> {<br> COLOR.w = 0;<br> }<br>}<br>else<br>{<br> COLOR.w *= 0;<br>}<br>
<br>