Skip to content

There is a bizarre issue with WebGPU lighting. #31062

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

Closed
jellychen opened this issue May 8, 2025 · 4 comments
Closed

There is a bizarre issue with WebGPU lighting. #31062

jellychen opened this issue May 8, 2025 · 4 comments

Comments

@jellychen
Copy link

Description

Sometimes we inherit from Three.js's light classes to create a subclass with additional custom functions. This works fine in WebGL, but causes issues in the WebGPU renderer.

WebGPU relies on the class's constructor to locate the lightNode, and when we create a new subclass via inheritance, this process breaks.

Is this considered a bug?

Reproduction steps

empty

Code

empty

Live example

empty

Screenshots

No response

Version

175

Device

No response

Browser

No response

OS

No response

@Mugen87
Copy link
Collaborator

Mugen87 commented May 8, 2025

Do you mind sharing a small code example that demonstrates the issue? I'm afraid I don't understand the problem yet.

@jellychen
Copy link
Author

jellychen commented May 8, 2025

Do you mind sharing a small code example that demonstrates the issue? I'm afraid I don't understand the problem yet.

class MyLight extends Three.DirectionalLight {
...
};
const l = new MyLight();
scene.add(l);

Works in the WebGL renderer but not in the WebGPU renderer.

Maybe Cause of MyLight.constructor donot match any lightNode

@Mugen87
Copy link
Collaborator

Mugen87 commented May 8, 2025

In WebGPURenderer, lights are implement based on nodes. If you define a custom type, you must tell the renderer what node class should represent it.

renderer.library.addLight( THREE.DirectionalLightNode, MyLight );

Live example: https://jsfiddle.net/d60893mf/1/

@jellychen
Copy link
Author

https://jsfiddle.net/d60893mf/1/

ok thanks

@Mugen87 Mugen87 closed this as completed May 8, 2025
@Mugen87 Mugen87 added this to the r177 milestone May 8, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants