Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

GPUParticles3D billboarding is affected by particle's global rotation when precision=double #76388

Open
cridenour opened this issue Apr 24, 2023 · 3 comments · May be fixed by #89165
Open

GPUParticles3D billboarding is affected by particle's global rotation when precision=double #76388

cridenour opened this issue Apr 24, 2023 · 3 comments · May be fixed by #89165

Comments

@cridenour
Copy link
Contributor

Godot version

v4.0.2.stable.custom_build [285ca46]

System information

Windows 10, Forward+

Issue description

With #76003 and #75462 I thought my particle issues were solved, but in testing I've noticed more billboard strangeness. Finally debugged it to the global rotation of the particles node.

anim

This issue is not present in non-double precision builds.

Steps to reproduce

  1. Create a GPUParticles3D in a double precision build
  2. Set billboarding in the material
  3. Rotate the particles node or its parent

Minimal reproduction project

double-particles-2.zip

@cridenour
Copy link
Contributor Author

Wondering / hoping if #72638 will improve this situation. Will take a closer look this weekend if I get a chance.

@cridenour
Copy link
Contributor Author

As noted in #89020 - can be worked around by enabled Rotate Y in the process material.

@ecmjohnson
Copy link
Contributor

ecmjohnson commented Mar 3, 2024

This issue is caused by the following block in the shader code scene_forward_clustered.glsl after the #CODE : VERTEX:

#ifdef USE_DOUBLE_PRECISION
// We separate the basis from the origin because the basis is fine with single point precision.
// Then we combine the translations from the model matrix and the view matrix using emulated doubles.
// We add the result to the vertex and ignore the final lost precision.
vec3 model_origin = model_matrix[3].xyz;
if (is_multimesh) {
vertex = mat3(matrix) * vertex;
model_origin = double_add_vec3(model_origin, model_precision, matrix[3].xyz, vec3(0.0), model_precision);
}
vertex = mat3(inv_view_matrix * modelview) * vertex;
vec3 temp_precision; // Will be ignored.
vertex += double_add_vec3(model_origin, model_precision, scene_data.inv_view_matrix[3].xyz, view_precision, temp_precision);
vertex = mat3(scene_data.view_matrix) * vertex;
#else
vertex = (modelview * vec4(vertex, 1.0)).xyz;
#endif

If you remove the USE_DOUBLE_PRECISION branch, then this issue goes away.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants