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

Use shader material written in wgsl as shadow depth wrapper #14755

Merged
merged 6 commits into from Feb 1, 2024

Conversation

shen-lin
Copy link
Contributor

@shen-lin shen-lin commented Jan 31, 2024

Allow ShaderMaterial written in WGSL to be used as shadow depth wrapper.

Original issue discussion

Changes involved

  • Avoids GLSL specific shader includes to be called when using WGSL for shadow depth wrapper.
  • This PR does not implement shadow map specific shader includes in WGSL. When option doNotInjectCode=false, BJS will log error in dev tool console about missing shader includes by default. The reason is BJS does not yet have full support for StandardMaterial or PBRMaterial implemented in WGSL. It is a lot of work to setup WGSL shader from scratch with transparent shadows, self shadow, etc to test the missing shader includes for shadow map. The idea is: for now, if a developer has implement a complete WGSL shader that require these shader includes, this developer can create these shader includes in WGSL, and include them in ShaderStore.IncludesShadersStoreWGSL. This example has been tested with some dumm WGSL code included into final runtime WGSL shader. If I later on need these shader includes and I have a test case, I will implement them and add to BJS WGSL shader include.

The shader includes that could be added in the future (WGSL version) mentioned above refers to:

  • shadowMapVertexExtraDeclaration
  • shadowMapVertexNormalBias
  • shadowMapVertexMetric
  • shadowMapFragmentSoftTransparentShadow
  • shadowMapFragment

Example outcome

See dev branch for test scenario setup in dev host.

Screenshot of local test result as shown below. A WGSL vertex shader is applied to animate both sphere and shadow vertex displacement.

Screenshot 2024-01-30 at 4 26 19 PM

@bjsplat
Copy link
Collaborator

bjsplat commented Jan 31, 2024

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.

@shen-lin shen-lin changed the title use shader material written in wgsl as shadow depth wrapper new feature: use shader material written in wgsl as shadow depth wrapper Jan 31, 2024
@shen-lin shen-lin marked this pull request as draft January 31, 2024 05:32
@bjsplat
Copy link
Collaborator

bjsplat commented Jan 31, 2024

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 Jan 31, 2024

@shen-lin shen-lin marked this pull request as ready for review January 31, 2024 06:14
@RaananW RaananW requested a review from Popov72 January 31, 2024 10:01
Copy link
Contributor

@Popov72 Popov72 left a comment

Choose a reason for hiding this comment

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

Only a small change!

packages/dev/core/src/Materials/shadowDepthWrapper.ts Outdated Show resolved Hide resolved
packages/dev/core/src/Materials/shadowDepthWrapper.ts Outdated Show resolved Hide resolved
@RaananW RaananW changed the title new feature: use shader material written in wgsl as shadow depth wrapper Use shader material written in wgsl as shadow depth wrapper Jan 31, 2024
Copy link
Contributor

@Popov72 Popov72 left a comment

Choose a reason for hiding this comment

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

Just missing a doc and we are ready to merge!

packages/dev/core/src/Materials/effect.ts Outdated Show resolved Hide resolved
@RaananW RaananW merged commit 2f10ef0 into BabylonJS:master Feb 1, 2024
11 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants