Skip to content

WebGPURenderer: MeshPhysicalMaterial creation is 10x slower than in WebGLRenderer #31675

@hybridherbst

Description

@hybridherbst

Description

Creating a regular MeshPhysicalMaterial is 10x slower in WebGPURenderer compared to WebGLRenderer. The WebGL backend shows the same slowness.

From doing a performance trace, it looks like long chains of "getNodeType" happen on every creation, even for the same material parameters. Maybe something is not/incorrectly cached?

I do understand creating a material every frame is not something one should do; nonetheless, I believe it shouldn't be 10x slower.

Reproduction steps

  1. Run the attached fiddle
  2. Switch from "WebGPU" to "WebGL"
  3. Note performance improves 10x

Code

  const material = new THREE.MeshPhysicalMaterial({
    color: new THREE.Color().setHSL(Math.random(), 0.7, 0.5),
    roughness: Math.random() * 0.5 + 0.25,
    metalness: Math.random() * 0.5,
    transparent: true,
    clearcoat: 1.0,
    transmission: 1.0,
    opacity: 0.8,
  });

Live example

Screenshots

No response

Version

r179

Related:

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions