Shaders in Godot 3 have an overhaul.
As of this version, you must:
define what kind of shader it is with shader_type
. Either spatial
, canvas_item
or particles
. I'm assuming your working in 2D so you'll want canvas_item
.
shader_type canvas_item;
define uniform textures with sampler2D
instead of texture
.
uniform sampler2D diffuse; // replaces your line 1
use vec4
instead of color
.
use texture
instead of tex
.
put your main code in a shader function. Either vertex
, fragment
and/or light
depending on what aspect of the mesh/Sprite your working with. Since your working with pixels' colours, you need to put that code of yours in a fragment shader.
Note you can use all of them in one shader if you need a combination of them.
I can go on with the changes, but these are the ones needed to convert your shader into a Godot 3 compatible one.
shader_type canvas_item;
uniform sampler2D diffuse;
void fragment() {
vec4 alpha = texture(diffuse, UV);
if(alpha.r == 1.0 && alpha.g == 0.0 && alpha.b == 1.0) {
alpha.a = 0.0;
}
COLOR = alpha;
}
Visit here to learn more about the new shading language.