Godot: GPU particles don't work without disable z

Created on 24 Jan 2020  路  6Comments  路  Source: godotengine/godot

3.2.rc2 and alpha3 or earlier on 3.1 stable it works

Windows 10

Particles do not work without putting disable z on.
3.2.rc2
bug

3.1 stable
bug

Just add particle put some mesh on pass 1 and add process material.

bug high priority regression rendering

Most helpful comment

This commit seems to be the issue: 00b15c19b7adcad21465f731f76e1888f1553da2

I guess the specifications for the atan(y,x) function in GLSL ES 3.0 isn't clear enough, so the special case atan(y,0) returns undefined on some machines and +-pi/2 on others.

I'm making a PR with a possible fix. PR: #36031

If you want to quickly test the fix but don't want to compile the whole engine, you can just create a gpu Particles node -> create new ParticlesMaterial -> click on the arrow next to ParticlesMaterial and click "Convert to ShaderMaterial", then click on the Shader and replace these 2 lines:

float angle1_rad = atan(direction.x, direction.z) + rand_from_seed_m1_p1(alt_seed) * spread_rad;
float angle2_rad = atan(direction.y, abs(direction.z)) + rand_from_seed_m1_p1(alt_seed) * spread_rad * (1.0 - flatness);

with this:

float angle1_rad = rand_from_seed_m1_p1(alt_seed) * spread_rad;
float angle2_rad = rand_from_seed_m1_p1(alt_seed) * spread_rad * (1.0 - flatness);
angle1_rad += direction.z != 0.0 ? atan(direction.x, direction.z) : sign(direction.x) * (pi / 2.0);
angle2_rad += direction.z != 0.0 ? atan(direction.y, abs(direction.z)) : sign(direction.y) * (pi / 2.0);

All 6 comments

I can't reproduce this issue on Windows 10 NVidia GTX 1050 GPU. Tested on Master and on rc2.

Are you getting any sort of error message? I can see that you have an error in your output from the video.

Might be related: #30906

Still happening on 3.2 stable.
output/debugger/console don't show any errors.
GPU is OpenGL ES 3.0 Renderer: GeForce GTX 950M/PCIe/SSE2

Tested on Linux with Intel HD 630 and AMD Radeon RX Vega M (both using Mesa 19.3.2) and I can't reproduce the issue.

It does seem to affect both some Windows Nvidia and iOS users judging by duplicate issues.

Intel 620 on Linux Manjaro (Mesa 19.3.2) here and I can't reproduce either.

This commit seems to be the issue: 00b15c19b7adcad21465f731f76e1888f1553da2

I guess the specifications for the atan(y,x) function in GLSL ES 3.0 isn't clear enough, so the special case atan(y,0) returns undefined on some machines and +-pi/2 on others.

I'm making a PR with a possible fix. PR: #36031

If you want to quickly test the fix but don't want to compile the whole engine, you can just create a gpu Particles node -> create new ParticlesMaterial -> click on the arrow next to ParticlesMaterial and click "Convert to ShaderMaterial", then click on the Shader and replace these 2 lines:

float angle1_rad = atan(direction.x, direction.z) + rand_from_seed_m1_p1(alt_seed) * spread_rad;
float angle2_rad = atan(direction.y, abs(direction.z)) + rand_from_seed_m1_p1(alt_seed) * spread_rad * (1.0 - flatness);

with this:

float angle1_rad = rand_from_seed_m1_p1(alt_seed) * spread_rad;
float angle2_rad = rand_from_seed_m1_p1(alt_seed) * spread_rad * (1.0 - flatness);
angle1_rad += direction.z != 0.0 ? atan(direction.x, direction.z) : sign(direction.x) * (pi / 2.0);
angle2_rad += direction.z != 0.0 ? atan(direction.y, abs(direction.z)) : sign(direction.y) * (pi / 2.0);
Was this page helpful?
0 / 5 - 0 ratings