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

Shadow meshes give error Can't use compression flag 'ARRAY_FLAG_COMPRESS_ATTRIBUTES' and null ARRAY_VERTEX #83526

Closed
lyuma opened this issue Oct 17, 2023 · 0 comments · Fixed by #83704

Comments

@lyuma
Copy link
Contributor

lyuma commented Oct 17, 2023

Godot version

4.2.beta1 a574c02

System information

Godot v4.2.beta (a574c02) - Windows 10.0.19045 - Vulkan (Forward+) - dedicated NVIDIA GeForce RTX 3090 (NVIDIA; 31.0.15.3713) - Intel(R) Core(TM) i9-9900K CPU @ 3.60GHz (16 Threads)

Issue description

Calling Mesh.surface_get_arrays() on a shadow mesh appears to print errors such as

  Can't use compression flag 'ARRAY_FLAG_COMPRESS_ATTRIBUTES' while using normals without tangent array.
  scene\resources\mesh.cpp:1795 - Condition "err != OK" is true.
  scene\resources\mesh.cpp:1936 - Index p_idx = 0 is out of bounds (surfaces.size() = 0).
  scene\resources\mesh.cpp:1916 - Index p_idx = 0 is out of bounds (surfaces.size() = 0).

and returns arrays with the ARRAY_VERTEX array being null.

My code does:

	func adjust_mesh_scale(mesh: ArrayMesh, is_shadow: bool = false):
		push_warning("Processing mesh " + str(mesh) + " is_shadow=" + str(is_shadow))
		for surf_idx in range(surf_count):
			var prim: int = mesh.surface_get_primitive_type(surf_idx)
			var fmt_compress_flags: int = mesh.surface_get_format(surf_idx)
			var arr: Array = mesh.surface_get_arrays(surf_idx)

			push_warning("Surface " + str(surf_idx) + " : Arrays len is " + str(len(arr)) + " (should be " + str(ArrayMesh.ARRAY_INDEX + 1) + ")")
			push_warning("Surface " + str(surf_idx) + " : ARRAY_VERTEX (" + str(ArrayMesh.ARRAY_VERTEX) + ") should be type " + str(typeof(PackedVector3Array())) + " : " + str(typeof(arr[0])))
			push_warning("Surface " + str(surf_idx) + " : len(arr[ARRAY_VERTEX]) is.....")
			push_warning(len(arr[0])) # Crashes on surface 1?????

		...

		if not is_shadow and mesh.shadow_mesh != mesh and mesh.shadow_mesh != null:
			adjust_mesh_scale(mesh.shadow_mesh, true)

Here is the output on this function when processing both the conventional mesh and the shadow mesh:

  core\variant\variant_utility.cpp:1033 - Processing mesh <ArrayMesh#-9223369631605918152> is_shadow=false
  core\variant\variant_utility.cpp:1033 - Surface 0 : Arrays len is 13 (should be 13)
  core\variant\variant_utility.cpp:1033 - Surface 0 : ARRAY_VERTEX (0) should be type 36 : 36
  core\variant\variant_utility.cpp:1033 - Surface 0 : len(arr[ARRAY_VERTEX]) is.....
  core\variant\variant_utility.cpp:1033 - 8280
  Can't use compression flag 'ARRAY_FLAG_COMPRESS_ATTRIBUTES' while using normals without tangent array.
  scene\resources\mesh.cpp:1795 - Condition "err != OK" is true.
  scene\resources\mesh.cpp:1936 - Index p_idx = 0 is out of bounds (surfaces.size() = 0).
  scene\resources\mesh.cpp:1916 - Index p_idx = 0 is out of bounds (surfaces.size() = 0).
  core\variant\variant_utility.cpp:1033 - Processing mesh <ArrayMesh#-9223369631589142756> is_shadow=true
  core\variant\variant_utility.cpp:1033 - Surface 0 : Arrays len is 13 (should be 13)
  core\variant\variant_utility.cpp:1033 - Surface 0 : ARRAY_VERTEX (0) should be type 36 : 0
  core\variant\variant_utility.cpp:1033 - Surface 0 : len(arr[ARRAY_VERTEX]) is.....
  res://test_post_import.gd:271 - Error calling GDScript utility function '<unknown function>': Value of type 'Nil' can't provide a length.

Steps to reproduce

  1. Open the attached project.
  2. Clear the console
  3. Reimport Godot.glb

Minimal reproduction project

mesh_post_import.zip

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

Successfully merging a pull request may close this issue.

3 participants