godotengine / godot

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

Black lines flickering on mesh surface during movement #25303

Open anantn opened 5 years ago

anantn commented 5 years ago

Godot version:

3.0.5

OS/device including version:

Mac OS X 10.14.2 Radeon Pro Vega 20 4080 MB

Issue description:

When composing a scene in GDScript by placing meshes aligned with each other, black lines appear on the surface of these meshes when under a DirectionalLight. These lines always appear on the surface of the mesh that faces the directional light, and are always horizontal (x-axis, never on the y or z axes).

Here are some screenshots of the lines:

image image image

Link to video with the problem

Steps to reproduce:

Open minimal reproduction project and play to reproduce.

Or in your own project, place simple cube meshes through GDScript, a DirectionalLight facing the top, and move a camera affixed to a KinematicBody on the surface.

Minimal reproduction project: flicker.zip

anantn commented 5 years ago

FWIW: this does not occur when using the built-in meshes in Godot, only when importing a cube mesh from Blender. I've tried all formats (.dae, .glx, .obj) which all give the same flickering effect. Unfortunately, can't use the built-in mesh for this project since it does not have 6 surfaces to paint material on.

anantn commented 5 years ago

Thanks to Alastor001 on Reddit, I tried this sample project in the master build of Godot and can confirm that the issue does not occur on v3.1.beta.

bojidar-bg commented 5 years ago

Closing as fixed then. If someone manages to reproduce the original issue, this issue might be reopened.

anantn commented 5 years ago

I spoke too soon, the issue is still prevalant on 3.1beta3 or master builds, just appearing at the different positions and offsets :( @bojidar-bg Repro is the same as before, can we re-open?

bojidar-bg commented 5 years ago

Reopening as per the comment above.

kaadmy commented 5 years ago

This seems to be due to floating point inaccuracies from the imported mesh, try disabling compression in the mesh import options.

You can also snap the mesh to grid in Blender after selecting the entire mesh and zooming in so the grid is the level you want to snap to:

Calinou commented 4 years ago

@anantn Does following @kaadmy's advice solve the issue?

anantn commented 4 years ago

@kaadmy @Calinou Thanks for the tip! Unfortunately, it doesn't seem to help. I am using "OBJ As Mesh" in the Import As dialog and there is no disable compression option, am I missing something?

I also tried snapping the mesh to grid but the line artifacts still appear. This continues to happen on the latest version (3.1.2.stable)

anantn commented 4 years ago

It seems this occurs even when not using an import from Blender. I tried using a simple cube ArrayMesh with the same results.

clutteroth commented 3 years ago

Hi there! I am experiencing the same issue in Godot 3.2.3.stable.mono.official running on a 64-bit Win10 Home PC with NVidia GeForce RTX 2080Ti. Lines flicker in a tiled mesh surface, see light grey horizontal lines on the road in the attached screenshot. As anantn reports, this happens only when using a directional light. flickering_lines

Calinou commented 3 years ago

As anantn reports, this happens only when using a directional light.

Does the DirectionalLight have shadows enabled? Does rotating the DirectionalLight improve the situation?

Also, I wonder if this is due to linear shadow filtering being used in GLES3. If you can't reproduce this when using the GLES2 renderer, then that must be the cause of the issue. Also, this issue is also unrelated to OP's, which is caused by a different problem.

clutteroth commented 3 years ago

The DirectionalLight has shadows disabled. Enabling shadows does not fix it. I have tried a few different rotations but that doesn't fix it, either. Also, after switching from GLES3 to GLES2 the problem still persists.

Would posting a test scene demonstrating the problem help?

Calinou commented 3 years ago

Would posting a test scene demonstrating the problem help?

Yes, as always :slightly_smiling_face:

clutteroth commented 3 years ago

Ok, here a test project illustrating the problem. It looks as if a grey vertical line appears not only with a DirectionalLight but also with an OmniLight -- see Test scene. glitch.zip

mamadreflex commented 3 years ago

hello. same problem here in godot 3.2.3 mono.

I have this problem with gridmap and kenny pack. doesn't show any flicker in editor but in game when moving gray lines happen some times. i test different ways (light,shadow,GLES2, etc) but seems its imported mesh problem they don't stick together well. when i test it with built-in mesh there isn't problem.

i test gridmap and normal mesh both act same. again seems imported obj problem. seems they width is float 0.9999 for example.

starwolfy commented 3 years ago

I have experienced this issue too. I have resolved this by slightly rotating my meshes in Blender by a few fractions of degrees and re-exporting them to Godot. It takes a lot of decimal tweaking, re-exporting, and checking if the black lines are (almost) gone.

However, the graphical glitches are still visible in my game after having applied this solution, but they are no longer noticeable to the untrained eye.