godotengine / godot

Godot Engine – Multi-platform 2D and 3D game engine
https://godotengine.org
MIT License
91.52k stars 21.26k forks source link

Noise in shaders does not work correctly on new NVIDIA graphics cards. #76343

Open Lexpartizan opened 1 year ago

Lexpartizan commented 1 year ago

Godot version

4,02 stable

System information

Windows 10, GTX 1050, forward+

Issue description

I am working on a sky shader and everything works correctly on my computer with an old video card. However, users of the new series of video cards (4070 like) complain that the shader does not work. It was found out that it is the noise function that does not work correctly. Moreover, I used fundamentally different noise functions, but all of them not work.

I get this correct result from the noise. image But users of new video cards get this. image

Everything is complicated by the fact that I do not have a modern video card for tests. And since everything works for me, I can't figure out the reason.

It's very similar to this error https://github.com/godotengine/godot/issues/67150, BUT I don't use the sin function in noise.

Steps to reproduce

There are two types of noise - texture-based and procedural. Both work correctly on older video cards. And both don't work on the new ones. For procedural noise, just uncomment the last line in the shader.

Minimal reproduction project

noise glitch.zip

Calinou commented 1 year ago

I can confirm this on 4.0.2.stable (Linux, GeForce RTX 4090 with NVIDIA 530.41.03):

image

This is a bug in the NVIDIA driver. However, given this comment, it's unlikely NVIDIA will fix it anytime soon. I suggest creating a documentation page with common hardware-specific gotchas instead.

If you can build the Direct3D 12 PR, it's worth checking whether the issue occurs when using Direct3D 12.

clayjohn commented 1 year ago

In addition to Calinou's answer, unfortunately with these types of issues there isn't much we can do. We don't have any meaningful control over the shader compiler, it's all in the GPU's driver.

Zireael07 commented 1 year ago

Can the driver bug be documented somewhere? As more people buy those cards, more people will be exposed to the problem

Calinou commented 1 year ago

Can the driver bug be documented somewhere? As more people buy those cards, more people will be exposed to the problem

This is what I mentioned above.

Breush commented 3 months ago

Been playing around, and removing all lowp keywords from the shaders resolves the issue.

Calinou commented 3 months ago

Been playing around, and removing all lowp keywords from the shaders solves the issue.

That's strange, since lowp and mediump are normally ignored on desktop platforms. However, NVIDIA Turing and later GPUs support native FP16 compute (half-precision float), so maybe NVIDIA decided to make lowp and mediump effective on desktop…