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

PBRCustomMaterial & CustomMaterial support MaterialPlugin #14593

Merged
merged 1 commit into from
Dec 8, 2023

Conversation

Starryi
Copy link
Contributor

@Starryi Starryi commented Dec 8, 2023

PBRCustomMaterial is a subclass of PBRMaterial, but does not support MaterialPlugin.

In the implementation of PBRCustomMaterial, the shader injection point is removed , causing material plugin to be unable to inject custom code.

CustomMaterial has the same problem.

This playground https://www.babylonjs-playground.com/#VNLCRN can reproduce the issue.
In the playground, PBRCustomMaterial using MeshDebugPluginMaterial, does not rendering wireframe.

The playgroud rendering result is as follows
截屏2023-12-08 23 33 18
red mesh use PBRCustomMaterial, green mesh use PBRMaterial
yellow mesh use CustomMaterial, blue mesh use StandardMaterial

I hope to fix the problem by this commit.
In the commit,

  1. reorganize the shader creation in PBRCustomMaterial and CustomMaterial
  2. replace the shader code only if the corresponding injected code is not empty
  3. retain injection points

After fixing this issue, the above plaground rendering result is as follows

截屏2023-12-08 23 38 49

@bjsplat
Copy link
Collaborator

bjsplat commented Dec 8, 2023

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 Dec 8, 2023

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 one comment and we are good to go!

packages/dev/materials/src/custom/customMaterial.ts Outdated Show resolved Hide resolved
@sebavan sebavan merged commit 2c3477b into BabylonJS:master Dec 8, 2023
10 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.

None yet

4 participants