![]() |
Attention | Topic was automatically imported from the old Question2Answer platform. |
![]() |
Asked By | dancaer69 |
I’ ve finished the tutorial and I have a working game, but there is a problem from part1 which doesn’t work.
At this part used a color shader in material property of the sprite which changes its color. The code for the shader is:
shader_type canvas_item;
uniform vec4 color : hint_color;
void fragment() {
COLOR.rgb = color.rgb;
COLOR.a = texture(TEXTURE, UV)
}
On the video after line “COLOR.rgb = color.rgb;”, appears a Color property in the inspector a colorpicker item to change color. Also the sprite’s rectangle changes color. In my case this has no effect in texture’s(or rectangle’s) area. The color doesn’t change.
At a later part the same shader file (which saved as color.shader ) is used to another sprite(a circle) this code:
shader_type canvas_item;
uniform vec4 color : hint_color;
uniform float speed : hint_range(0,20);
uniform float radius : hint_range(0, 1);
uniform float width : hint_range(0, 1);
void fragment() {
vec2 center = vec2(0.5);
float time = TIME * speed;
float rad = radius - 0.005 * sin(time);
float thickness = width + 0.05 * cos(time);
float dist = distance(UV, center);
COLOR.rgb = color.rgb;
COLOR.a = texture(TEXTURE, UV).a+smoothstep(thickness/2.0, 0.0, abs(dist-rad));
}
and there it works fine.
I don’n know which version of godot used in that tutorial, but I have the version: 3.2.3 stable.
Is something changed there?
I have read the comments in youtube and seems that others haven’t problem with this. Only a comment to use to some that the code gives an error(In my case there’s no errors), which suggests to use:
COLOR.r = color.r
COLOR.b = color.b
COLOR.g = color.g
instead, but this also has no effect in my case.
Any ideas?