V-Sekai / godot-vrm

Importer/Exporter for VRM avatars and MToon shader. Available for Godot 4.1+ and 3.2+ in the Asset Library.
https://godotengine.org/asset-library/asset/2031
Other
287 stars 24 forks source link

Visual artifacts with material overlay in compatibility mode #63

Closed uguu-org closed 1 year ago

uguu-org commented 1 year ago

Surfaces with MToon shader appears to exhibit visual artifacts with overlay material when rendered in compatibility mode:

compatibility_renderer

Maybe some kind of z-fighting due to precision issues? All these artifacts go away if I do a global replacement of VIEW_MATRIX * MODEL_MATRIX with MODELVIEW_MATRIX under addons/Godot-MToon-Shader/*.gdshader (21 instances across 7 files):

compatibility_renderer_with_fix

This problem doesn't happen with Forward+ renderer.

forward_renderer

Unfortunately, I can't seem to reproduce this bug on any other model, but the steps I took were:

  1. Set compatibility mode.
  2. Import VRM with BasisU disabled (see https://github.com/V-Sekai/godot-vrm/issues/58).
  3. Select body node, then add new material under "Geometry -> Material Overlay".
  4. Set transparency to "Alpha" and Cull mode to "Disabled".

I understand this is not the best bug report without a proper test case, but Godot's documentation also says "use if possible" next to MODELVIEW_MATRIX, so doing this replacement seems like a good idea.

lyuma commented 1 year ago

I have applied your suggestion in master. Thanks!

I wonder if Godot 3.x has the same issue. I will consider a backport if I update VRM/MToon for Godot 3