Closed catafest closed 12 months ago
You need to use get_surface_override_material(0)
to get the Surface Material Override (instead of the per-mesh Material).
What Calinou said. There are 3 material "levels".
The one on the mesh resource. -> Mesh.surface_get_material(surface_index)
The one on the mesh instance that replaces any material from the mesh in that surface slot -> MeshInstance3D.get_surface_override_material(surface_index)
The one on the visual instance that overrides everything -> GeometryInstance3D.get_material_override()
Error:
Invalid call. Nonexistent function 'get_surface_override_material' in base 'QuadMesh'
for this source code:
`
func _ready():
print(mesh)
material = mesh.get_surface_override_material(0)
`
As mentioned that function is part of the MeshInstance3D
, not part of the Mesh
.
Godot version
v4.1.2.rc1.mono.official [58f0cae4a]
System information
Vulkan API 1.3.242 - Forward+ - Using Vulkan Device #0: NVIDIA - NVIDIA GeForce GTX 950
Issue description
I tried to get the Surface Material Override from a QuadMesh, to get a shader and use it in GDscript. I saw some issues about surface_get_material(0) but I'm not sure is fixed I used this GDScript source code :
The error is:
Steps to reproduce
create a QuadMesh, add a shader, and try to get the Surface Material Override
Minimal reproduction project
Try this project to see the error GITHUB_Issues_catafest.zip