godotengine / godot

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

GLB/GLTF Import Rendering Issues on both Mobile/GL Compatible renders. #92292

Open MangoDragonHub opened 4 months ago

MangoDragonHub commented 4 months ago

Tested versions

System information

Windows 10 - Godot 4.2.2 Stable - Vulkan(Mobile) and GL Compatible

Issue description

I have uploaded a small issue on Reddit about me uploading my models from Blender to Godot (GLTF). Link to Thread I managed to try and dig for what was the issue and it turns out I was only getting this rendering bug in every renderer except the default Forward+ mode. Below I'll attach in-editor shots where some models render properly while others aren't RenderingBug_ForwardPlus RenderingBug_VKMobile RenderingBug_CMB

Steps to reproduce

As of right now, I'm using Blender 3.6 LTS Export Mesh to GLTF 2.0 into Godot. Set Renderer type to either Vulkan(Mobile) or GL Compatible. Check in see in both In Editor and Import Mesh Window if the mesh is properly rendering correctly.

Minimal reproduction project (MRP)

Unfortunately, the compression of my file is too large (106 MB) in size. I tried 7Zip, but Github does not except that file format.

Chaosus commented 3 months ago

Textures of bugged models have size of power of 2 (e.g. 2048x2048)?

MangoDragonHub commented 3 months ago

Yes, they are the 2048x2048. Power of two.

clayjohn commented 3 months ago

Could you please upload an MRP to make this easier for contributors to troubleshoot?

An MRP is a project that is as small as can be while still reproducing the bug you are reporting. We include the MRP in the bug reporting template as including one greatly increases the chance that a contributor will be able to reproduce the bug you reported and be able to fix it.

If your asset is too large to upload to Github, you can use another host. Ideally though you would create a project that is as small as possible

MangoDragonHub commented 3 months ago

I made a small project link using Proton Mail. Please take good care of it. https://drive.proton.me/urls/KGBEKQDMGG#FQ1SovzlGTuI

clayjohn commented 3 months ago

I've confirmed the bug exists in both 4.2.2 and 4.3 beta 1 and is present in the compatibility and mobile backends (Forward+ works fine). ~Accordingly, this is likely a rendering bug, not an import bug~

The problem appears to come from 3 things:

  1. The importer is importing the mesh with back face culling disabled
  2. The importer is importing the mesh with transparency (depth pre-pass mode)
  3. Depth prepass appears to be broken on the compatibility and mobile renderers so we don't get proper per-pixel depth testing
MangoDragonHub commented 3 months ago

If I can take a wild guess, No. 3 maybe the case. The hair material renders correctly and that has transparency in its material and this mesh's normals are facing the front prior to exporting from Blender.

clayjohn commented 3 months ago

Hmmm, for me the hair shows the same issue as the rest of the body:

image

clayjohn commented 3 months ago

Note for whoever decides to work on this, I just confirmed in RenderDoc that depth is not being written by the body in the depth prepass (when it should)

dhoverml commented 3 months ago

Depth prepass appears to be broken on the compatibility and mobile renderers so we don't get proper per-pixel depth testing

Here is a MRP for testing Depth Pre-Pass on Mobile: alphaprepassmobilebug.zip

This MRP was used in this comment

xsellier commented 2 months ago

I've confirmed the bug exists in both 4.2.2 and 4.3 beta 1 and is present in the compatibility and mobile backends (Forward+ works fine). ~Accordingly, this is likely a rendering bug, not an import bug~

The problem appears to come from 3 things:

1. The importer is importing the mesh with back face culling disabled

2. The importer is importing the mesh with transparency (depth pre-pass mode)

3. Depth prepass appears to be broken on the compatibility and mobile renderers so we don't get proper per-pixel depth testing

Hey,

Many thanks for your comment because I made a workaround for this specific issue. It's not perfect but it renders OK now. For every single Material the project uses, I attach this script to it:

@tool
extends BaseMaterial3D

func _init():
  var rendering_device = RenderingServer.get_rendering_device()

  if rendering_device == null:
    transparency = Transparency.TRANSPARENCY_ALPHA_DEPTH_PRE_PASS
    cull_mode = CullMode.CULL_DISABLED

Then the mesh renders properly (with some weird stuff, but It's better than it used to)

With the script attached to the materials: image

Without any script image