Skip to content

Conversation

@ryantrem
Copy link
Member

@ryantrem ryantrem commented Jun 2, 2025

ShadowOnlyMaterial does not currently have a native wgsl implementation, which means it has to be converted to glsl at runtime, which is not ideal. Switching to BackgroundMaterial solves this, plus it removes the dependency on @babylonjs/materials.

I also switched the skybox material over to BackgroundMaterial since it can do what we need in a lighter weight way (unlit + reflection blur). In doing so, it revealed a bug in BackgroundMaterial's wgls fragment shader implementation, where it was simply missing uniforms. when referencing the vReflectionMicrosurfaceInfos uniform.

This PR also includes a few other small Viewer changes related to shadows:

  • Store the shadow light as type ShadowLight instead of Spotlight. This is really just in preparation to switch to DirectionalLight, which will be a different PR.
  • Set ShadowGenerator.enableSoftTransparentShadow = true; (feedback from @Popov72).
  • Set ShadowGenerator.bias = radius / 1000; (feedback from @Popov72, and we'll see if we need to also allow the user to explicitly override the bias).

@ryantrem ryantrem requested a review from sebavan June 2, 2025 23:27
@ryantrem ryantrem enabled auto-merge (squash) June 2, 2025 23:28
@bjsplat
Copy link
Collaborator

bjsplat commented Jun 2, 2025

Please make sure to label your PR with "bug", "new feature" or "breaking change" label(s).
To prevent this PR from going to the changelog marked it with the "skip changelog" label.

@bjsplat
Copy link
Collaborator

bjsplat commented Jun 2, 2025

Reviewer - this PR has made changes to one or more package.json files.

@bjsplat
Copy link
Collaborator

bjsplat commented Jun 2, 2025

@bjsplat
Copy link
Collaborator

bjsplat commented Jun 2, 2025

@bjsplat
Copy link
Collaborator

bjsplat commented Jun 2, 2025

@ryantrem ryantrem added the viewer label Jun 3, 2025
@ryantrem ryantrem requested a review from deltakosh June 3, 2025 15:44
@ryantrem ryantrem merged commit 609b278 into BabylonJS:master Jun 3, 2025
18 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants