Skip to content

WebGPURenderer: on camera switch the shader of skinned mesh is recompiled unnecessarily #32524

@SebastianTusk

Description

@SebastianTusk

Description

On rendering with a secondary camera the shader of a skinned mesh gets regenerated. There might be circumstances where this is necessary (no idea). But in the general case the generated shader is (almost) identically to the previously generated one. The only difference is the unnecessary renumbering of the bone buffer. e.g.

uniform NodeBuffer_1179 {
	mat4 buffer1179[2];
};

GLSLNodeBuilder.js#L1575
The number comes from node.id and changes. Otherwise the shader is unchanged. But it is triggering a cache miss and therefore a recompile.

Reproduction steps

  1. Use the WebGL backend. WebGPURenderer({ forceWebGL: true })
  2. Have two cameras.
  3. Have a skinned mesh.
  4. Watch WebGLBackend._completeCompile with a breakpoint.
  5. Switch between cameras.
  6. Observe WebGLBackend._completeCompile being called twice for the same object and material.

Code

// code goes here

Live example

https://jsfiddle.net/1byfwaj4/

Screenshots

No response

Version

0.181.2

Device

Desktop

Browser

Chrome

OS

Windows

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions