godotengine / godot

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

Gaps in Gridmap when moving camera #67673

Closed DoctorVaan closed 1 year ago

DoctorVaan commented 2 years ago

Godot version

3.5

System information

Windows 10

Issue description

Lines between gridmap cells. theyre are not always there but flicker when moving.

gridmap

-The window display properties are 1920x1080, viewport, keep. -The camera is orthogonal, 45 angle, the mesh is a 1x1x1 cube, the texture used in the albedo has no filter, gridmap cellsize is 1x1x1.

-This is the box texture (66x44). FL0 -I noted the lines are the same color as the surrounding pixels of the top square, so making the white square 1 pixel wider and taller kinda fixes the problem.

I've tried changing the gridmap cell scale property to something like 1.002, maybe helps a bit but the lines are still very obvious. I tried pixel snap in the project settings, does not help. I tried all viewport stretch settings, different resolutions, lines wont go away!

Is there a way around this?

Steps to reproduce

Spatial. Gridmap. Meshlib, 1 box with a texture (top different than walls) so lines are different color and visible, and no filter. Orthogonal Camera (but it happens aswell in perspective, just less obvious). Move the camera, and there they are!

Minimal reproduction project

GridmapTest.zip

Zireael07 commented 2 years ago

Seem to remember something very similar opened back in 3.2 (?) days?

Calinou commented 2 years ago

Related to https://github.com/godotengine/godot/issues/16337 (possible duplicate?).

I've tried changing the gridmap cell scale property to something like 1.002, maybe helps a bit but the lines are still very obvious.

You need to decrease the cell size or make meshes larger instead. Otherwise, you're actually increasing the gap's size.

I tried pixel snap in the project settings, does not help.

Pixel snap only affects 2D rendering, not 3D.

DoctorVaan commented 2 years ago

Related to https://github.com/godotengine/godot/issues/16337 (possible duplicate?).

MSAA and FSAA are both disabled.

You need to decrease the cell size or make meshes larger instead. Otherwise, you're actually increasing the gap's size.

I dont mean the cell size, there is a property in Gridmap that scales the cells, I think its called cell scale.

golddotasksquestions commented 2 years ago

I can confirm this issue.

I spend more than two hours, going through everything in OPs project. Checking all transforms, checking all project settings, checking the meshlibrary and camera ...

I also made new Gridmaps and new Meshlibrary from scratch with 1x1x1 cubes, 1.01 x 1.01 x 1.01 cubes and 1.1 x 1.1 x 1.1 cubes.

These visual horizontal and vertical lines keep appearing no matter what I do. I am convinced at this point the issue is not with the project, but with with Godot. Possibly a rendering issue.

It only seems to appear with Gridmaps and Cameras in Orthogonal mode.

Edit: I just tried to build a completely new scene from scratch, with only a Gridmap and Camera and a Meshlibrary with a single 1x1x1 cube. The camera mode is set to "Orthogonal" (Edit: as well as "Perspective") and angled at -45° on the x axis.

The issue is does not exist with a setup like this. I also created another MeshLibrary with the same 1x1x1 cube which has a SpatialMaterial and a pixelart texture (filtering disabled), again, issue is does not exist.

Then I created yet another MeshLibrary, again with the same 1x1x1 cube, but with OPs texture: image And the issue appears!

However the UV layout seems to be correct: image

DoctorVaan commented 2 years ago

It only seems to appear with Gridmaps and Cameras in Orthogonal mode.

In the minimal reproduction project that I uploaded here (and in my project too, at least on my end), perspective camera show lines aswell.

DoctorVaan commented 1 year ago

I noticed it even happens on the editor, just preview the camera and move it around with the inspector. Im assuming ppl know about this but its very hard to fix or even unsolvable right now, cuz this is a very obvious problem and not hard at all to come across (most of the properties of the few nodes used to replicate it are left at default). Hopefully 4.0 fixes this.

Calinou commented 1 year ago

Then I created yet another MeshLibrary, again with the same 1x1x1 cube, but with OPs texture:

And the issue appears!

This is a mipmap/linear filtering bleeding issue. You need to pad your texture with at least 1 pixel of the same color (if you have mipmaps disabled), or more pixels if you have mipmaps enabled. How much padding you need depends on the texture's size and the maximum mipmap level you expect to be viewed in practice.

Duplicate of https://github.com/godotengine/godot/issues/27837.

elvisish commented 1 year ago

Then I created yet another MeshLibrary, again with the same 1x1x1 cube, but with OPs texture: And the issue appears!

This is a mipmap/linear filtering bleeding issue. You need to pad your texture with at least 1 pixel of the same color (if you have mipmaps disabled), or more pixels if you have mipmaps enabled. How much padding you need depends on the texture's size and the maximum mipmap level you expect to be viewed in practice.

Duplicate of #27837.

Is this a duplicate? I'm having the same issue when the camera moves: image

elamaunt commented 7 months ago

I figured out that the issue is actual only for .gltf format exported from Blender. I switched to dae and the gaps has dissapeared. But dae has other blending issues. image