0 votes

I'm a novice to coding and I'm watching a youtube video on how to make a shader in Godot, but along the process I received a text message error stating, "expected one return statement from a non void value." Can someone please help?

shadertype canvasitem;

uniform vec3 color = vec3(0.33,0.15,0.82);


float rand(vec2 coord){ return fract(sin(dot(coord, vec2(56,78)) *
1000.0) * 1000.0); }

float noise(vec2 coord){ vec2 i = floor(coord); vec2 f = fract(coord); float a = rand(i); float b = rand(i + vec2(1.0,
0.0)); float c = rand(i); + vec2(1.0, 0.0); float d = rand(i); + vec2(1.0, 0.0); }

it's in this section where I am receiving the error.

void fragment(){
    COLOR = vec4(color, rand(UV));
}
in Engine by (12 points)
edited by

1 Answer

0 votes

You declared a function called noise returning a variable of type float. However, in the code for that function you never return anything (i.e. you return void).

So either change the return type of your function:

void noise(vec2 coord) {
    // ...
}

or make sure you actually return a float value:

float noise(vec2 coord) {
    // ...
    return 0.0;
}
by (10,483 points)

thank you so much!

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 Frequently asked questions and 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.