Skip to content

Depth Pre-Pass transparency breaks batching #103954

Open
godotengine/godot-docs
#10762
@bikemurt

Description

@bikemurt

Tested versions

-Reproducible in 4.4-stable, 4.4-rc3, 4.4-rc2, 4.4-rc1, 4.4-dev1
-Not reproducible in 4.3-stable

System information

Windows 11 - Vulkan Forward+ - NVidia GeForce RTX 3050 Ti Laptop GPU

Issue description

Batching breaks in the Forward+ renderer when a material has the Transparency set to Depth Pre-Pass. I tested both the RenderingServer API as well as the node approach (MeshInstance3D) and the result is the same.

In Godot 4.3-stable, we can see the expected result, 3 draw calls (shadows disabled for simplicity):

Image

In Godot 4.4-dev1, we see the regression (showing 2433 draw calls):

Image

Steps to reproduce

The core of the code is to instantiate a bunch of meshes with a few materials - we expect the batcher to be able to sort these properly and reduce draw calls in Forward+.

@onready var node_3d: Node3D = $Node3D
const BOX_MESH = preload("res://box_mesh.tres")
const MATERIALS := {
	0: preload("res://red.tres"),
	1: preload("res://blue.tres"),
	2: preload("res://green.tres")
}
func node_test() -> void:
	var mat := 0
	
	for x in range(100):
		for z in range(100):
			var m := MeshInstance3D.new()
			m.mesh = BOX_MESH
			
			var t := Transform3D()
			t.origin = Vector3(-100,0,-100) + Vector3(2 * x, 0, 2 * z)
			m.transform = t
			m.set_surface_override_material(0, MATERIALS[mat])
			
			node_3d.add_child(m)
			
			mat += 1
			if mat >= 3: mat = 0

Minimal reproduction project (MRP)

instancing-test.zip

Run the MRP, check the Total Draw Calls from the Monitors tab.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions