-
Notifications
You must be signed in to change notification settings - Fork 319
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
Make sure "babylonTransparencyMode" attribute is correctly initialised #897
Make sure "babylonTransparencyMode" attribute is correctly initialised #897
Conversation
@dkyteasSG thanks for this work. What is the context/use case of this PR, which is the solved issue? |
Issue: Transparent material is exported with alpha=1.0. To reproduce this issue you need to export the model more than once. Any subsequent exports will use the attribute to determine transparency but it will have the wrong value because it is being initialised incorrectly, so the material will be exported as Opaque. I also noticed that Babylon modifies the maya scene by adding several babylonStandardMaterialNode nodes (the type of node that has the babylonTransparencyMode attribute) which remain there after the end of export. |
Ok so this is related to #865. |
adding @Drigax
And if correct we MUST extends this behaviors to others attributes otherwise, the bug will appear again with backface culling and others. But I continue to beleive that the right solution is to clear the attributes at the end of the export. |
I'll make the change. I agree that the newly created babylonAttributesDependencyNode instances should be deleted at the end |
Looks like "babylonTransparencyMode" is set separately in each babylonMaterialNode class (babylonAiStandardSurfaceMaterialNode, babylonStandardMaterialNode, babylonStingrayPBSMaterialNode) I need to understand exactly what's going on with these nodes or this issue will keep popping up. |
At the end of the day, the purpose seems to let user update Babylon specifics value throught Maya UI (available after the first export - this is the same strategy applied on Max). On my opinion, it's introducing some new node into the DAG, and then modify the scene - so we may tell the user to do it explicitely if he/she want to persist his/her change into the scene - Also using MxNode for the purpose is kind of hack while the goal of these class is to write some "compute"code to process dependencies. Anyway, i do not know the history and motivation for this, but i'm sure it was for a good reason. We can therefore make sure that the code behaves identically, whether the nodes are present or not. |
…iStandardSurfaceMaterialNode and babylonStingrayPBSMaterialNode
…bylonMaxSimultaneousLights" attributes for all 3 babylon material nodes
I've pushed a couple of changes to ensure all attributes in the material nodes are initialised. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I wonder why you treated BackFaceCulling any differently? by setting it to 1 just after its creation.
Remove default "setattr" for "babylonBackfaceCulling"
That's the original code. I think these changes have exposed a bug. |
This UI was added due to #537 The problem we intended to solve is that Maya Arnold Materials don't have all the parameters that one may want to control when exporting to glTF, so we created that custom material node to contain the rest. One restriction was that we were not able to hook into Maya material creation to initialize the node at edit time, so instead we initalized the nodes at export time, which is causing all this UX madness with nodes appearing out of the blue to the end user. The current issue this PR is addressing appears to be that the initialized supplemental nodes aren't properly configured, the current fix seems sufficient to change that behavior. Deleting the nodes after export may not be the best idea either, the workflow for setting up the nodes isn't particularly intuitive given our multiple node types, I don't really like this solution, but I definitely don't like the idea of all this occuring completely opaque to the user. at the very least here, we're leaving a record of what we're adding to the material. This ties back to our conversation last week @pandaGaume regarding how difficult it can be to augment the DCC tool with additional functionality, the currently implemented solution is pretty bad, to be honest. I think a better, less disruptive workflow is to use Maya material custom attributes in, instead of MxNode graph objects. but that's more of a "burn this monstrosity down" long term solution. In the meantime, this seems alright as a fix. |
Thanks for the information @Drigax. |
could you send me a scene that reproduce the issue ? |
Here's a simple scene that can be used to reproduce the issue. |
Some additional info. It came back with: The other attributes don't have this issue |
Turns out that babylonTransparencyMode for PBS materials was explicitly locked after its creation. |
I beleive the lock issue is wider, because once created, any of the attribute could be locked by the user (when lock the material itself). This mean we maybe put a logic in place for our own attribute to ensure there are not lock before set, and put them back to the previous status after the set. |
If that's the case, the lock status must also be taken into account in the Init() function of the babylon material nodes, as it calls "setAttr" for multiple attributes. |
Handle locked attributes.
I've pushed a change with a setter function. |
As far i know there is no restriction about having common super-class, nor an extension. We should introduce a common class such
|
I added 2 abstract classes: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maya/Exporter/PluginNodes/babylonMPxNode .cs
remove white space before extension please.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the improvements, we greatly appreciate the discussion and contributions :)
BabylonJS#897) * Make sure "babylonTransparencyMode" attribute is correctly initialised * Refactor attribute initialisation fix * Correctly initialise "babylonTransparencyMode" attribute for babylonAiStandardSurfaceMaterialNode and babylonStingrayPBSMaterialNode * Correctly initialize "babylonBackfaceCulling", "babylonUnlit" and "babylonMaxSimultaneousLights" attributes for all 3 babylon material nodes * Fix "setattr" command for bool attributes of babylon material nodes. Remove default "setattr" for "babylonBackfaceCulling" * Do not lock babylonTransparencyMode attribute for StingrayPBS materials. * Set attributes for babylon materials through a setter function. Handle locked attributes. * Add babylonMPxNode and babylonMaterialNodeBase * Remove whitespace
…itialised (BabylonJS#897)" This reverts commit ffb43c8.
…itialised (BabylonJS#897)" This reverts commit ffb43c8.
fix #865