Godot version:
3.1 61b41d6
OS/device including version:
Ubuntu 18.04
Issue description:
When I opened FPS Demo then this error appear:
1 shader_type particles;
2 uniform float spread;
3 uniform float flatness;
4 uniform float initial_linear_velocity;
5 uniform float initial_angle;
6 uniform float angular_velocity;
7 uniform float orbit_velocity;
8 uniform float linear_accel;
9 uniform float radial_accel;
10 uniform float tangent_accel;
11 uniform float damping;
12 uniform float scale;
13 uniform float hue_variation;
14 uniform float anim_speed;
15 uniform float anim_offset;
16 uniform float initial_linear_velocity_random;
17 uniform float initial_angle_random;
18 uniform float angular_velocity_random;
19 uniform float orbit_velocity_random;
20 uniform float linear_accel_random;
21 uniform float radial_accel_random;
22 uniform float tangent_accel_random;
23 uniform float damping_random;
24 uniform float scale_random;
25 uniform float hue_variation_random;
26 uniform float anim_speed_random;
27 uniform float anim_offset_random;
28 uniform float emission_sphere_radius;
29 uniform vec4 color_value : hint_color;
30 uniform int trail_divisor;
31 uniform vec3 gravity;
32
33
34 float rand_from_seed(inout uint seed) {
35 int k;
36 int s = int(seed);
37 if (s == 0)
38 s = 305420679;
39 k = s / 127773;
40 s = 16807 * (s - k * 127773) - 2836 * k;
41 if (s < 0)
42 s += 2147483647;
43 seed = uint(s);
44 return float(seed % uint(65536)) / 65535.0;
45 }
46
47 float rand_from_seed_m1_p1(inout uint seed) {
48 return rand_from_seed(seed) * 2.0 - 1.0;
49 }
50
51 uint hash(uint x) {
52 x = ((x >> uint(16)) ^ x) * uint(73244475);
53 x = ((x >> uint(16)) ^ x) * uint(73244475);
54 x = (x >> uint(16)) ^ x;
55 return x;
56 }
57
58 void vertex() {
59 uint base_number = NUMBER / uint(trail_divisor);
60 uint alt_seed = hash(base_number + uint(1) + RANDOM_SEED);
61 float angle_rand = rand_from_seed(alt_seed);
62 float scale_rand = rand_from_seed(alt_seed);
63 float hue_rot_rand = rand_from_seed(alt_seed);
64 float anim_offset_rand = rand_from_seed(alt_seed);
65 float pi = 3.14159;
66 float degree_to_rad = pi / 180.0;
67
68 if (RESTART) {
69 float tex_linear_velocity = 0.0;
70 float tex_angle = 0.0;
71 float tex_anim_offset = 0.0;
72 float spread_rad = spread * degree_to_rad;
73 float angle1_rad = rand_from_seed_m1_p1(alt_seed) * spread_rad;
74 float angle2_rad = rand_from_seed_m1_p1(alt_seed) * spread_rad * (1.0 - flatness);
75 vec3 direction_xz = vec3(sin(angle1_rad), 0, cos(angle1_rad));
76 vec3 direction_yz = vec3(0, sin(angle2_rad), cos(angle2_rad));
77 direction_yz.z = direction_yz.z / max(0.0001,sqrt(abs(direction_yz.z))); // better uniform distribution
78 vec3 direction = vec3(direction_xz.x * direction_yz.z, direction_yz.y, direction_xz.z * direction_yz.z);
79 direction = normalize(direction);
80 VELOCITY = direction * initial_linear_velocity * mix(1.0, rand_from_seed(alt_seed), initial_linear_velocity_random);
81 float base_angle = (initial_angle + tex_angle) * mix(1.0, angle_rand, initial_angle_random);
82 CUSTOM.x = base_angle * degree_to_rad;
83 CUSTOM.y = 0.0;
84 CUSTOM.z = (anim_offset + tex_anim_offset) * mix(1.0, anim_offset_rand, anim_offset_random);
85 TRANSFORM[3].xyz = normalize(vec3(rand_from_seed(alt_seed) * 2.0 - 1.0, rand_from_seed(alt_seed) * 2.0 - 1.0, rand_from_seed(alt_seed) * 2.0 - 1.0)) * emission_sphere_radius;
86 VELOCITY = (EMISSION_TRANSFORM * vec4(VELOCITY, 0.0)).xyz;
87 TRANSFORM = EMISSION_TRANSFORM * TRANSFORM;
88 } else {
89 CUSTOM.y += DELTA / LIFETIME;
90 float tex_linear_velocity = 0.0;
91 float tex_angular_velocity = 0.0;
92 float tex_linear_accel = 0.0;
93 float tex_radial_accel = 0.0;
94 float tex_tangent_accel = 0.0;
95 float tex_damping = 0.0;
96 float tex_angle = 0.0;
97 float tex_anim_speed = 0.0;
98 float tex_anim_offset = 0.0;
99 vec3 force = gravity;
100 vec3 pos = TRANSFORM[3].xyz;
101 // apply linear acceleration
102 force += length(VELOCITY) > 0.0 ? normalize(VELOCITY) * (linear_accel + tex_linear_accel) * mix(1.0, rand_from_seed(alt_seed), linear_accel_random) : vec3(0.0);
103 // apply radial acceleration
104 vec3 org = EMISSION_TRANSFORM[3].xyz;
105 vec3 diff = pos - org;
106 force += length(diff) > 0.0 ? normalize(diff) * (radial_accel + tex_radial_accel) * mix(1.0, rand_from_seed(alt_seed), radial_accel_random) : vec3(0.0);
107 // apply tangential acceleration;
108 vec3 crossDiff = cross(normalize(diff), normalize(gravity));
109 force += length(crossDiff) > 0.0 ? normalize(crossDiff) * ((tangent_accel + tex_tangent_accel) * mix(1.0, rand_from_seed(alt_seed), tangent_accel_random)) : vec3(0.0);
110 // apply attractor forces
111 VELOCITY += force * DELTA;
112 // orbit velocity
113 if (damping + tex_damping > 0.0) {
114 float v = length(VELOCITY);
115 float damp = (damping + tex_damping) * mix(1.0, rand_from_seed(alt_seed), damping_random);
116 v -= damp * DELTA;
117 if (v < 0.0) {
118 VELOCITY = vec3(0.0);
119 } else {
120 VELOCITY = normalize(VELOCITY) * v;
121 }
122 }
123 float base_angle = (initial_angle + tex_angle) * mix(1.0, angle_rand, initial_angle_random);
124 base_angle += CUSTOM.y * LIFETIME * (angular_velocity + tex_angular_velocity) * mix(1.0, rand_from_seed(alt_seed) * 2.0 - 1.0, angular_velocity_random);
125 CUSTOM.x = base_angle * degree_to_rad;
126 CUSTOM.z = (anim_offset + tex_anim_offset) * mix(1.0, anim_offset_rand, anim_offset_random) + CUSTOM.y * (anim_speed + tex_anim_speed) * mix(1.0, rand_from_seed(alt_seed), anim_speed_random);
127 }
128 float tex_scale = 1.0;
129 float tex_hue_variation = 0.0;
130 float hue_rot_angle = (hue_variation + tex_hue_variation) * pi * 2.0 * mix(1.0, hue_rot_rand * 2.0 - 1.0, hue_variation_random);
131 float hue_rot_c = cos(hue_rot_angle);
132 float hue_rot_s = sin(hue_rot_angle);
133 mat4 hue_rot_mat = mat4(vec4(0.299, 0.587, 0.114, 0.0),
134 vec4(0.299, 0.587, 0.114, 0.0),
135 vec4(0.299, 0.587, 0.114, 0.0),
136 vec4(0.000, 0.000, 0.000, 1.0)) +
137 mat4(vec4(0.701, -0.587, -0.114, 0.0),
138 vec4(-0.299, 0.413, -0.114, 0.0),
139 vec4(-0.300, -0.588, 0.886, 0.0),
140 vec4(0.000, 0.000, 0.000, 0.0)) * hue_rot_c +
141 mat4(vec4(0.168, 0.330, -0.497, 0.0),
142 vec4(-0.328, 0.035, 0.292, 0.0),
143 vec4(1.250, -1.050, -0.203, 0.0),
144 vec4(0.000, 0.000, 0.000, 0.0)) * hue_rot_s;
145 COLOR = hue_rot_mat * color_value;
146
147 TRANSFORM[0].xyz = normalize(TRANSFORM[0].xyz);
148 TRANSFORM[1].xyz = normalize(TRANSFORM[1].xyz);
149 TRANSFORM[2].xyz = normalize(TRANSFORM[2].xyz);
150 float base_scale = mix(scale * tex_scale, 1.0, scale_random * scale_rand);
151 if (base_scale == 0.0) {
152 base_scale = 0.000001;
153 }
154 TRANSFORM[0].xyz *= base_scale;
155 TRANSFORM[1].xyz *= base_scale;
156 TRANSFORM[2].xyz *= base_scale;
157 }
158
159
SHADER ERROR: (null): Invalid arguments for built-in function: vec3(float,int,float)
At: :75.
ERROR: _update_shader: Condition ' err != OK ' is true.
At: drivers/gles3/rasterizer_storage_gles3.cpp:2150.
Before(don't remeber when, maybe with alpha or early beta) this error doesn't occur.
Minimal reproduction project:
https://docs.godotengine.org/en/latest/_downloads/Godot_FPS_Finished.zip
Same here, it's an issue with the particle shader.
This is caused by this in the perticles_material.cpp
code += " vec3 direction_xz = vec3(sin(angle1_rad), 0, cos(angle1_rad));\n";
code += " vec3 direction_yz = vec3(0, sin(angle2_rad), cos(angle2_rad));\n";
where the 2 0
s should probably 0.0
s
Screenshaders not working here, might be related. The ColorRect is just plain white insted of showing the Screenshader effect.
@substract any errors?
Its look like a regression.. Not reproducable at beta 6 but introduced in beta 7 :
I think those are expected issues following fd68bb2596bff1990711862f90b4763553d2edac. Mobile drivers don't convert 0 to float, so we now have to be explicit everywhere. CC @reduz
Sorry guys, this is actually expected and you will have to fix it. It's in the GLSL ES 3.0 spec and was leading to these type of shaders not working on mobile. This is not a bug and it worked before because desktop drivers are generally more permissive than mobile ones.
If anyone volunteers to modify the shader compiler to make it keep working and change it to do implicit conversions for the constant nodes to the right type, feel free. You can undo https://github.com/godotengine/godot/commit/fd68bb2596bff1990711862f90b4763553d2edac and instead add the conversion code. Else from my part I will leave it as is, which is already conformant.
Have to say i'm quite upset with this. (And the Discord server _seems_ to agree.)
Not only do we now need to refactor nearly every shader in all our projects. But none of the tutorials and resources factor in this change.
And note that this is not a simple "lets just change a line of code" refactor. It appears that you can not perform inline typecasting. Meaning
vec2(float(TEXTURE.x, float(TEXTURE.y))
must actually be written as
float x = float(TEXTURE.x);
float y = float(TEXTURE.y);
vec2(x, y);
I can see how it makes sense to make this change, it helps mobile along, which is ultimately what we are keeping GLES around for. But now? In 3.1? I really hope someone takes a look at adding the conversion code.
I think an important thing to note here is that this change is breaking the GUI particle materials (which is the problem OP was encountering). Which I think is a definite problem, since it's probably fair to assume that any material made through the GUI should be able to compile/run.
EDIT:
Specifically, it's breaking on the lines 75 & 76 in the original post
Double edit:
I read through this issue too fast and didn't realize people were already mentioning it's the particle material that's broken before the issue was closed. Still should be fixed IMO
@TheDuriel No, that actually looks like it's broken, inline typecasting should work
I thought of a way to fix this relatively easy
Hint: 0.0 works for literals, in case that is what you have in the source, then it is an easy conversation
Most helpful comment
Sorry guys, this is actually expected and you will have to fix it. It's in the GLSL ES 3.0 spec and was leading to these type of shaders not working on mobile. This is not a bug and it worked before because desktop drivers are generally more permissive than mobile ones.