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

MultiMesh won't display in web (MultiMeshInstance2D & RenderingServer) #81926

Closed
Pizza-Script opened this issue Sep 19, 2023 · 1 comment · Fixed by #81575
Closed

MultiMesh won't display in web (MultiMeshInstance2D & RenderingServer) #81926

Pizza-Script opened this issue Sep 19, 2023 · 1 comment · Fixed by #81575

Comments

@Pizza-Script
Copy link

Godot version

v4.1.1.stable.official [bd6af8e]

System information

Godot v4.1.1.stable - Windows 10.0.19045 - Vulkan (Compatibility) - NVIDIA GeForce GTX 1660 SUPER (NVIDIA; 31.0.15.3623) - 11th Gen Intel(R) Core(TM) i7-11700 @ 2.50GHz (16 Threads)

Issue description

Browser receives errors when trying to use both MultiMeshInstance2D and RenderingServer.multimesh_*

Chrome - Version 116.0.5845.188 (Official Build) (64-bit):

[.WebGL-00007DF006C86900] GL_INVALID_OPERATION: Vertex shader input type does not match the type of the bound vertex attribute.

01 Chrome

Firefox - 117.0.1 (64-bit):

WebGL warning: drawElementsInstanced: Vertex attrib 5 requires data of type UINT, but is being supplied with type FLOAT.

01 Firefox

Steps to reproduce

Can view files and Itch.IO project here - https://quietgodot.itch.io/web-multimesh?secret=hyR14x8ZiMmxMP6X4rx9476fmTo

Was using the following minimal code:

For MultiMeshInstance2D

func _ready() -> void:
	for index in multimesh.instance_count:
		multimesh.set_instance_transform_2d(index, Transform2D(0, Vector2(index * 16 + 16, 16)))

For RenderingServer

var unit_texture: Texture2D = preload("icon.svg")
var unit_size: Vector2 = Vector2(16.0, 16.0)
var unit_mid: Vector2 = Vector2(8.0, 8.0)
var unit_count: int = 100

var quad_mesh: QuadMesh = QuadMesh.new()
var unit_rid: RID = RenderingServer.canvas_item_create()
var mesh_rid: RID = RenderingServer.multimesh_create()

func _ready() -> void:
	quad_mesh.size = unit_size
	quad_mesh.center_offset = Vector3(unit_mid.x, unit_mid.y, 0.0)
	RenderingServer.multimesh_set_mesh(mesh_rid, quad_mesh.get_rid())
	RenderingServer.multimesh_allocate_data(mesh_rid, unit_count, RenderingServer.MULTIMESH_TRANSFORM_2D)
	RenderingServer.canvas_item_set_parent(unit_rid, get_canvas_item())

	for unit_index in unit_count:
		RenderingServer.multimesh_instance_set_transform_2d(mesh_rid, unit_index, Transform2D(0, Vector2(randi() % 1025, randi() % 769)))

	RenderingServer.canvas_item_add_multimesh(unit_rid, mesh_rid, unit_texture)

Minimal reproduction project

project.zip

@bitsawer
Copy link
Member

Thanks for the report. Looks like a 2D version bug report of #80980 (GridMap uses MultiMeshInstance internally), both of these should be fixed by #81575

I'll keep this open as it is still slighly different from the other report and is also directly about 2D and MultiMesh.

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.

2 participants