Skip to content
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

fix: lighting WebGPU shaders #2353

Merged
merged 6 commits into from
Mar 29, 2025

Conversation

Kaapp
Copy link
Collaborator

@Kaapp Kaapp commented Mar 17, 2025

Needed for visgl/deck.gl#9531 in order to port point-cloud-layer to WebGPU.

Change List

  • Add missing WGSL source for gouraud material
  • Fix a typo in the lighting WGSL shader
  • Fix uniform bindings not being found when a uniform is named in camelCase (e.g. pointCloud)
  • Updated wgsl_reflect as the version being used crashes when encoutering a switch statement with multiple comma-separated cases when one case is default.

@Kaapp Kaapp requested review from felixpalmer and ibgreen March 20, 2025 10:34
@@ -54,7 +54,8 @@ export function getShaderLayoutBinding(
): BindingDeclaration | null {
const bindingLayout = shaderLayout.bindings.find(
binding =>
binding.name === bindingName || `${binding.name}uniforms` === bindingName.toLocaleLowerCase()
binding.name === bindingName ||
`${binding.name.toLocaleLowerCase()}uniforms` === bindingName.toLocaleLowerCase()
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nit: Not completely sure I understand why we need this... Is it JS or WebGPU that is causing the issue. Regardless, no major objection, other than it often being better to fix issues at the source rather than loosening semantics.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@ibgreen it depends on how the end-user names uniforms in their shader, so WGSL really. the previous implementation would only work for all-lower-case names like lighting or project, but would fail if the user named a uniform in camelCase like pointCloud, for example. i figured it's not something we have direct control over for custom layers/shaders so probably need to be flexible and handle that case.

@ibgreen ibgreen merged commit fae1e77 into visgl:master Mar 29, 2025
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants