Skip to content

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

Closed
@Pizza-Script

Description

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

Activity

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

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions