Hi, with 3.2 Godot version is not possible to assign a uniform variable in a function, but maybe I remember not correctly that with the old versions it could be done.

For example:

shader_type canvas_item;

uniform float t; 

vec2 fb( vec3 p, float m)
{ 
  vec2 t=vec2(bo(p,vec3(5,1,3)),3);
}

Any suggestions? Thanks in advance -j

Why don't you just rename either the uniform, or the inner function variable? That should get rid of the redefinition error.

@SIsilicon28 said: Why don't you just rename either the uniform, or the inner function variable? That should get rid of the redefinition error.

Because the variable is processed in multiple functions. Keep in mind that I posted a little piece of code, to make my request understandable.

@jospic said:

@SIsilicon28 said: Why don't you just rename either the uniform, or the inner function variable? That should get rid of the redefinition error.

Because the variable is processed in multiple functions. Keep in mind that I posted a little piece of code, to make my request understandable.

Well in that case, could you please show the entirety of your shader so that I could give a better answer?

Thanks. For fun I have converted various shaders from shadertoy and this is one of them, already partially converted.

Bruh. That code is barely human readable, but here's what I discovered anyway. Those uniforms aren't meant to be uniforms. You should define them at the beginning of the fragment shader and pass them through the functions manually. Their definition in each function should include inout so that it can be modified by the function.

mp( vec3 p, inout vec3 pp, inout vec3 bp, inout float tt, inout float b, inout float bb, inout float g, inout float g2)
{

...

void fragment() {
	float t=0.0, tt=0.0, b=0.0, g=0.0, g2=0.0, bb=0.0; 
 	vec3 np=vec3(0.0), bp=vec3(0.0), pp=vec3(0.0), po=vec3(0.0), no=vec3(0.0), al=vec3(0.0), ld=vec3(0.0);
	...

I've tried to do it, but proved to be a difficult task. Good luck with that!

Hi, following your suggestions I did it! As soon as I have some time, I will publish it on my repository on GitHub and send you the link. Thank you, have a nice day. -j

25 days later
3 years later