godotengine / godot

Godot Engine ā€“ Multi-platform 2D and 3D game engine
https://godotengine.org
MIT License
89.57k stars 20.36k forks source link

Vulkan Clustered: Mesh wireframes are showing on material surfaces on AMD GPUs, especially on darker surfaces #62073

Open CarlosRios opened 2 years ago

CarlosRios commented 2 years ago

Godot version

4 Alpha 10

System information

MacOS 12.3 Intel

Issue description

Screen Shot 2022-06-15 at 11 09 00 AM Screen Shot 2022-06-15 at 11 09 32 AM

I noticed this in 4 Alpha 9 but now in Alpha 10 it seems to be showing more. In Alpha 9 it was related to metallic surfaces and roughness, now it just seems to show in shadowed areas.

Steps to reproduce

Minimal reproduction project

No response

CarlosRios commented 2 years ago

The issue arises on Vulkan Clustered and not Vulkan Mobile

RandomCatDude commented 2 years ago

I've noticed this happening in pretty much all prior alphas on the clusters that have Decals in them. That's worth looking into further.

Calinou commented 2 years ago

I've noticed this happening in pretty much all prior alphas on the clusters that have Decals in them. That's worth looking into further.

Which operating system and graphics card model are you using?

CarlosRios commented 2 years ago

I'm on MacOS 12.3

GPUs AMD Radeon Pro 555X 4GB Intel UHD Graphics 630 1536 (Integrated graphics for the Intel i7)

RandomCatDude commented 2 years ago

Which operating system and graphics card model are you using?

Windows 7, and AMD RX 570

WrobotGames commented 2 years ago

This also happens for me on my laptop (AMD GPU), it does not happen om my pc (Nvidia gpu). Both run windows 11 so this isn't a platform specific issue. It may have something to do with the amd drivers. This only happens when using decals on or near the mesh. The car material is just metal = 0 and roughtness = 0 image

clayjohn commented 2 years ago

My guess is that this is due to AMD defaulting to using coarse derivatives.

Right now Godot uses the following code to calculate derivatives: https://github.com/godotengine/godot/blob/0dcf679bdc9bde359d8fd5e486eeefc56f754ec8/servers/rendering/renderer_rd/shaders/scene_forward_clustered.glsl#L850-L851

This allows the GPU driver to select whether to use coarse or fine derivatives. My guess is explicitly asking for fine derivatives would fix the issue it would be great if someone who can reproduce the problem could replace the above code with the following and test:

    vec3 vertex_ddx = dFdxFine(vertex);
    vec3 vertex_ddy = dFdyFine(vertex);
lostminds commented 1 year ago

Just want to add that this issue still exists in 4.0.beta3 on macOS 12.6.1 with an AMD Radeon Pro 560 graphics card when using the new forward+ renderer. Switching to the mobile renderer the polygon edge lines disappear.

Screen Shot 2022-11-04 at 10 37 45

I was planning to try and build godot with the change suggested by @clayjohn above, but I'm not familiar with the build system and after closing the repository it seems there have been other changes to the scene_forward_clustered.glsl file seems to have been moved and altered by other changes. So I would be grateful if someone more experienced tried making and building with this change. I'd be happy to test the build and see if the rendering issues are still there.

lostminds commented 1 year ago

Good news! Just tried it on the new 4.0.beta4 and the issues seems to be resolved here.

CarlosRios commented 1 year ago

Beta 4 looks like it fixed the issue for me as well. It does run a lot slower now however šŸ˜†

CarlosRios commented 1 year ago

Can anyone else please confirm that you're no longer viewing the mesh?

Calinou commented 1 year ago

It does run a lot slower now however :laughing:

If you can compile the engine from source, you could look into bisecting the regression to greatly speed up troubleshooting.

WrobotGames commented 1 year ago

Can anyone else please confirm that you're no longer viewing the mesh?

Its still there on my windows 11 laptop with AMD gpu (no problem on pc with nvidea). My issue is slightly different, the wireframe only shows when a decal is being projected on that mesh.

The same issue as in godot 4 alpha: https://github.com/godotengine/godot/issues/62073#issuecomment-1197225300

clayjohn commented 1 year ago

Can anyone else please confirm that you're no longer viewing the mesh?

Its still there on my windows 11 laptop with AMD gpu (no problem on pc with nvidea). My issue is slightly different, the wireframe only shows when a decal is being projected on that mesh.

The same issue as in godot 4 alpha: #62073 (comment)

Can you try it with the code change I have suggested above? https://github.com/godotengine/godot/issues/62073#issuecomment-1197352018

WrobotGames commented 1 year ago

Can you try it with the code change I have suggested above?

I've tried that change and it didn't solve the issue. (The glsl file was in the _/servers/rendering/renderer_rd/shaders/forwardclustered folder instead of the shaders folder. I replaced line 929 and 930)

Built from commit: https://github.com/godotengine/godot/commit/e6751549cf7247965d1744b8c464f5e901006f21 (Beta 4)

DesertFroggo commented 1 year ago

I'm noticing a similar issue in the current stable version of 4.0. Instead of seeing my materials at all though, I see just the wireframe and the material is applied to the wireframe. This is with AMD graphics (RX 5700) on EndeavourOS (Arch-based). This is only in the editor though. At runtime, I see the meshes and their materials just fine.

clayjohn commented 1 year ago

I'm noticing a similar issue in the current stable version of 4.0. Instead of seeing my materials at all though, I see just the wireframe and the material is applied to the wireframe. This is with AMD graphics (RX 5700) on EndeavourOS (Arch-based). This is only in the editor though. At runtime, I see the meshes and their materials just fine.

It sounds like you have wireframe debug drawing enabled. To turn it off select the "[perspective]" button in the top left corner of the 3D viewport editor and then select "debug draw normal"

DesertFroggo commented 1 year ago

It sounds like you have wireframe debug drawing enabled. To turn it off select the "[perspective]" button in the top left corner of the 3D viewport editor and then select "debug draw normal"

Yeah, that was it. I was looking for something like that in the Editor Settings window but didn't think to look in the viewport. Thanks.

lostminds commented 1 year ago

Looks like this issue has been resolved and can be closed, or are you still seeing this @WrobotGames? Or perhaps your issue was something else related to decals?

WrobotGames commented 1 year ago

Looks like this issue has been resolved and can be closed, or are you still seeing this @WrobotGames? Or perhaps your issue was something else related to decals?

The issue still persists in 4.1 Beta 2. Its the same problem as I had experienced months ago (Described in the comment with the car picture). afbeelding The sphere on the left is Metallic=1, Roughness=0. The sphere on the right in this image is the default material, which also shows a bit of the wireframe.

TaraSophieDev commented 5 months ago

Hey, this still happens in Godot 4.2.1 (also happens in 4.3.dev5)

I just tested it on my steamdeck, it works there perfectly, so I assume it works on also desktop linux with an AMD gpu.

This only happens in game on both editor build or export build.

image This seems also to happen when roughness is not 0 but near it.

image

I'm using windows 11 with an AMD Ryzen 5800u APU.

Here is the GPU Driver Data