Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add cull mode option to materials in the Advanced Import Settings dialog, ignore default Disabled cull mode #7360

Open
Calinou opened this issue Jul 23, 2023 · 0 comments

Comments

@Calinou
Copy link
Member

Calinou commented Jul 23, 2023

Describe the project you are working on

Describe the problem or limitation you are having in your project

Performance issues occur due to imported materials from 3D scenes often using Disabled cull mode as a default. This comes from either glTF or Blender materials being configured this way by default (I haven't checked thoroughly).

This is particularly the case when using the Mobile rendering method, which doesn't use a depth prepass.

Describe the feature / enhancement and how it helps to overcome the problem or limitation

Add cull mode option to materials in the Advanced Import Settings dialog. Additionally, ignore the default Disabled cull mode to avoid performance issues that are difficult to diagnose for new and returning users alike. It's generally hard to notice that you're using double-shaded rendering in Godot, unless you make the camera enter solid geometry somehow.

Describe how your proposal will work, with code, pseudo-code, mock-ups, and/or diagrams

  1. Similar to what Add layer, shadow and visibility range options to the Scene importer godot#78803 does, a Cull Mode option could be exposed on a per-material basis in the Advanced Import Settings dialog.
  2. I suggest defaulting imported 3D scenes to backface culling, and ignoring double-sided hints that are set by default by 3D DCCs. If you want to use Disabled cull mode, you'd have to pick a 4th option from the Cull Mode enum:
  • Default (Back if Disabled on source)
  • Back
  • Front
  • Disabled (Force)

The second change unfortunately breaks visual compatibility (existing scenes may have a changed appearance), but given the glTF/Blender default is ill-suited for real-time rendering, it makes sense to do so. We could print a warning in the editor when importing such materials for the first time.

If this enhancement will not be used often, can it be worked around with a few lines of script?

In some cases, yes, by assigning this script to a MeshInstance3D node. Example for forcing the Back cull mode on all materials:

@tool
extends MeshInstance3D

func _ready() -> void:
	for index in mesh.get_surface_count():
		var material := mesh.surface_get_material(index)
		material.cull_mode = BaseMaterial3D.CULL_MODE_BACK

Is there a reason why this should be core and not an add-on in the asset library?

This is about improving 3D rendering performance by optimizing the asset pipeline's output.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant