CanvasShader works in editor but not in game

:information_source: Attention Topic was automatically imported from the old Question2Answer platform.
:bust_in_silhouette: Asked By darkshadow

Hi All, pretty new to shaders but I want to remove a particular color from some icons. In the editor the code works and I have this:

editor view
editor view

but when I run the game the shader doesn’t seem to work:

game view
game view

I’ve used the color picker tool to select the right color which is 0x075f00, I’ve checked in gimp and it’s the same value. Is godot doing something to change the pixel values in game?

shader_type canvas_item;
uniform vec4 alpha_mask: hint_color;

void fragment(){
  COLOR = texture(TEXTURE, UV); //read from texture
  if(vec3(COLOR.r, COLOR.g, COLOR.b) == vec3(alpha_mask.r, alpha_mask.g, alpha_mask.b))
	    COLOR.a = 0.0;

Which operating system are you using?

Also, can you reproduce this issue after disabling batching in the Project Settings then restarting the editor?

Calinou | 2021-06-14 21:56

Ubuntu 20.04 and yes disabling batching same issue, editor is fine but the game/scene is not

darkshadow | 2021-06-15 20:12