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

Billboarding not working when building with precision=double #75433

Closed
joao-pedro-braz opened this issue Mar 28, 2023 · 0 comments · Fixed by #75462
Closed

Billboarding not working when building with precision=double #75433

joao-pedro-braz opened this issue Mar 28, 2023 · 0 comments · Fixed by #75462

Comments

@joao-pedro-braz
Copy link
Contributor

joao-pedro-braz commented Mar 28, 2023

Godot version

v4.1.dev.custom_build [1e0194a]

System information

Linux X11, Vulkan, Forward+, RX6600XT

Issue description

This behavior can be noticed when building the engine with double precision (precision=double).

Comparison between 4.1.dev (double precision) and 4.0.stable (single precision):

image
4.1.dev (with double precision)

image
4.0.stable (with single precision)

According to my testing, the following bit on "scene_forward_clustered.glsl" is responsible for this behavior:
image
Code for reference:

// 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(model_matrix) * 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;

Removing it and leaving the "else" path as the default gets rid of this behavior:
image
Code for reference:

vertex = (modelview * vec4(vertex, 1.0)).xyz;

image

CC-ing @clayjohn as per @Calinou request on Rocket.Chat

Steps to reproduce

Build from master with precision=double, create a scene and add a MeshInstance3D with any mesh whose Material has "billboard" enabled (both "enabled" and "Y-Billboard" fails)

Minimal reproduction project

Can be reproduced using godot-demo-projects#894.

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.

3 participants