0 votes

I applied an outline shader to my object (2D game) and I get some errors in the console. The shader runs without problems though.

Here is a pic of the console:

Here is the shader code:

shader_type canvas_item;

uniform float width;
uniform vec4 outline_color : hint_color;

void fragment()
    vec2 size = (vec2(width) * TEXTURE_PIXEL_SIZE);

    vec4 sprite_color = texture(TEXTURE, UV);

    float alpha = sprite_color.a;
    alpha += texture(TEXTURE, UV + vec2(0.0, -size.y)).a;
    alpha += texture(TEXTURE, UV + vec2(size.x, -size.y)).a;
    alpha += texture(TEXTURE, UV + vec2(size.x, 0.0)).a;
    alpha += texture(TEXTURE, UV + vec2(size.x, size.y)).a;
    alpha += texture(TEXTURE, UV + vec2(0.0, size.y)).a;
    alpha += texture(TEXTURE, UV + vec2(-size.x, size.y)).a;
    alpha += texture(TEXTURE, UV + vec2(-size.x, 0.0)).a;
    alpha += texture(TEXTURE, UV + vec2(-size.x, -size.y)).a;

    vec3 final_color = mix(outline_color.rgb, sprite_color.rgb, sprite_color.a);
    COLOR = vec4(final_color, clamp(alpha, 0.0, 1.0));

I use GLES2. Godot 3.2.3
I'm not sure if I should ignore these errors or somehow fix them.

Error message 1:

E 0:00:00.580   get_current_version: Condition "!cc" is true. Returned: __null
  <C++-Quellcode>drivers/gles2/shader_gles2.cpp:221 @ get_current_version()

Error message 2:

E 0:00:00.582   bind: Condition "!version" is true. Returned: false
  <C++-Quellcode>drivers/gles2/shader_gles2.cpp:89 @ bind()

Error message 3-8:

E 0:00:00.596   _get_uniform: Condition "!version" is true. Returned: -1
  <C++-Quellcode>drivers/gles2/shader_gles2.h:267 @ _get_uniform()
in Engine by (44 points)

1 Answer

0 votes
Best answer

I think I solved it, I guess? Not exactly sure.
Anyways, I replaced

uniform float width;
uniform vec4 outline_color : hint_color;


const float width = 40.0;
const vec4 outline_color = vec4(1.0, 0.0, 0.0, 1.0);

and the errors went away. Now I can't set the values in the inspector. But atleast it works.
If anyone could identify what caused the problem, that would be good.

by (44 points)
Welcome to Godot Engine Q&A, where you can ask questions and receive answers from other members of the community.

Please make sure to read How to use this Q&A? before posting your first questions.
Social login is currently unavailable. If you've previously logged in with a Facebook or GitHub account, use the I forgot my password link in the login box to set a password for your account. If you still can't access your account, send an email to webmaster@godotengine.org with your username.