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

advancedDynamicTexture using PBR Material #282

Open
Chargeuk opened this issue Apr 1, 2023 · 4 comments
Open

advancedDynamicTexture using PBR Material #282

Chargeuk opened this issue Apr 1, 2023 · 4 comments

Comments

@Chargeuk
Copy link

Chargeuk commented Apr 1, 2023

Hi I was attempting to create an Advanced Dynamic texture for GUI elements that uses a PBR rather than standard material. Unfortunately, nesting the advancedDynamicTexture within the pbrMaterial node does not seem to work:

Is this possible? If so, how should it be created?
Thanks

@brianzinn
Copy link
Owner

brianzinn commented Apr 2, 2023

Can you share how that is done imperatively?

@Chargeuk
Copy link
Author

Chargeuk commented Apr 8, 2023

Can you share how that is done imperatively?

Sorry for the late reply, was on holiday.

I have create 2 playgrounds to show how I would create the materials in raw Babylon code.

Option 1, provide the materialSetupCallback function to BABYLON.GUI.AdvancedDynamicTexture.CreateForMesh: https://playground.babylonjs.com/#NVAEWD#94 - note that the materialSetupCallbackPbr supports onlyAlphaTesting = true or false appropriately.

Option 2, create the AdvancedDynamicTexture directly and manually apply the material. Note this code path is the same as onlyAlphaTesting = false: https://playground.babylonjs.com/#NVAEWD#95

Hope this helps to illustrate what I mean.

Edit - now that I have come to think about it, exposing a materialSetupCallback on the current AdvancedDynamicTexture component within react-babylon that returns the material to use would also work for me, though I'm not sure it would fit in with the structure you have created...

@brianzinn
Copy link
Owner

Sorry - was AFK all long weekend. I feel like there are declarative solutions to both. Also, assignTo looks like it should allow an array of strings. The only thing about the callback is I don't even have the original createForMesh - I did add a createForParentMesh property. The thing about putting materialSetupCallback is that it would only need to be called with createForMesh and I think I copied the code from that static method. I certainly could call that though - I'm not necessarily against people "newing up" instances, but I think I would encourage a declarative option - that allows the reconciler to track the object and is eligible to prop updates. Even your 'onlyAlphaTesting' can be used to change what is "rendered"...

@brianzinn
Copy link
Owner

i'm trying to clear out some outstanding issues. sorry this didn't get looked at properly before. do you have a preferred option to go ahead?

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

No branches or pull requests

2 participants