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

Vulkan: Decal and Light3D distance fade uses view plane distance, resulting in unstable fading when the camera rotates (unlike GeometryInstance3D) #58513

Closed
Tracked by #57284
Calinou opened this issue Feb 24, 2022 · 6 comments

Comments

@Calinou
Copy link
Member

Calinou commented Feb 24, 2022

Godot version

4.0.dev (872e8a4)

System information

Fedora 34, GeForce GTX 1080 (NVIDIA 495.46)

Issue description

Decal's distance fade works using a view plane distance calculation, rather than an actual distance between the camera and the Decal node:

real_t distance = -p_camera_inverse_xform.xform(xform.origin).z;
if (storage->decal_is_distance_fade_enabled(decal)) {
float fade_begin = storage->decal_get_distance_fade_begin(decal);
float fade_length = storage->decal_get_distance_fade_length(decal);
if (distance > fade_begin) {
if (distance > fade_begin + fade_length) {
continue; // do not use this decal, its invisible
}
}
}

This means that decals that should be hidden due to distance may be visible again when the camera is rotated. Not only this increases GPU performance demands, but this also makes the image appear less stable in motion. The issue is more noticeable at higher camera FOVs, but even at the default FOV, it's quite visible already.

GeometryInstance3D visibility ranges do not suffer from this issue, as a distance_to() function is used. We should use the same formula for all kinds of LOD to ensure consistency, while making sure that LOD does not break with orthogonal cameras.

Since #58512 uses the same distance fade calculation, it's also affected by this issue.

simplescreenrecorder-2022-02-25_00.02.14.mp4

Steps to reproduce

  • Add a MeshInstance3D node with a primitive mesh resource for the decal to be projected on.
  • Add a Decal node. Set an Albedo texture (icon.png or a new NoiseTexture will do).
  • Enable Distance Fade on the Decal node.
  • Move at least 10 units away from the Decal node, then rotate the camera in the editor slowly.
  • Notice the decal will slowly appear again as you rotate the camera, despite being more than 10 units away from the Decal.

Minimal reproduction project

test_decal_distance_fade.zip

@Calinou Calinou added this to the 4.0 milestone Feb 24, 2022
@Calinou Calinou changed the title Vulkan: Decal distance fade uses view plane distance, resulting in unstable fading when the camera rotates (unlike GeometryInstance3D) Vulkan: Decal and Light3D distance fade uses view plane distance, resulting in unstable fading when the camera rotates (unlike GeometryInstance3D) Mar 10, 2022
@elvisish

This comment was marked as off-topic.

@Calinou
Copy link
Member Author

Calinou commented Dec 17, 2022

I've got even weirder issues with Decals in 4.0: #70231

This is an unrelated issue. Please don't hijack issues with comments like these – just create a new issue instead.

@elvisish
Copy link

I've got even weirder issues with Decals in 4.0: #70231

This is an unrelated issue. Please don't hijack issues with comments like these – just create a new issue instead.

I didn't hijack, how is this not the same issue as I'm having? The decals don't display properly when the camera rotates, exactly the same issue here (except my example has some additional issues).

@Calinou
Copy link
Member Author

Calinou commented Dec 18, 2022

I didn't hijack, how is this not the same issue as I'm having? The decals don't display properly when the camera rotates, exactly the same issue here (except my example has some additional issues).

According to that issue's description, you don't seem to have distance fade enabled on the decals (it's disabled by default). Hence, it's a different issue entirely. We can't know for sure anyway as you didn't upload a minimal reproduction project 🙂

@elvisish
Copy link

I didn't hijack, how is this not the same issue as I'm having? The decals don't display properly when the camera rotates, exactly the same issue here (except my example has some additional issues).

According to that issue's description, you don't seem to have distance fade enabled on the decals (it's disabled by default). Hence, it's a different issue entirely. We can't know for sure anyway as you didn't upload a minimal reproduction project 🙂

Ah okay, I didn't realize this issue was with distance fade, it just seemed very similar to problems I'm having with decals.

@clayjohn clayjohn moved this to Todo in 4.x Priority Issues Jan 13, 2023
@clayjohn clayjohn moved this from Todo to In Progress in 4.x Priority Issues Jan 13, 2023
@clayjohn
Copy link
Member

Fixed by #71709

@github-project-automation github-project-automation bot moved this from In Progress to Done in 4.x Priority Issues Jan 23, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Archived in project
Development

Successfully merging a pull request may close this issue.

3 participants