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

Various improvements #145

Open
kopacabana opened this issue Nov 20, 2020 · 12 comments
Open

Various improvements #145

kopacabana opened this issue Nov 20, 2020 · 12 comments

Comments

@kopacabana
Copy link

I download and install your Maya GLTF plugin. It's really great, thanks a lot, it saves my time.
I've got few questions.
When I apply a pbr material to meshes, I can't play with TextCoords. When I change offset or rotation, nothing happens. Did I make a wrong manipulation ?
Is it possible to conserve name hierarchy in export (groups and mesh) ? Some elements have the suffix "PIV" during export, is it possible to remove with options.
Can you give an example on how to batch export in python in readme/documentation ? With options for export ? This will be great as I'll try to construct a pipeline for export.

During exports, sometimes, I've got wrong tangents or textcoords. On console, i saw you propose a small portion of code to identify them. But when I try to execute code, I've got errors.
Can you add a button in your panel to execute this script automatically ?

@ziriax
Copy link
Contributor

ziriax commented Nov 20, 2020

I download and install your Maya GLTF plugin. It's really great, thanks a lot, it saves my time.

Thanks for trying Maya2glTF, and your valuable feedback!

When I apply a pbr material to meshes, I can't play with TextCoords. When I change offset or rotation, nothing happens. Did I make a wrong manipulation ?

Do you mean that nothings happens in the Maya viewport, or that the UV coordinates are not correctly exported, or maybe both? Regarding export, I indeed don't do anything special here, I just call MFnMesh::getUVs, so I might need to do more work. I can see in our old Ogre exporter that we specially handle MFn::kPlace2dTexture, so I need to do the same. Of course glTF is limited here, it doesn't supporting animating these. The only solutions for now is to bake the UVs I'm afraid (I believe you have to copy the UV set and delete history, not sure, I'm not a technical artist 😉)

Is it possible to conserve name hierarchy in export (groups and mesh) ? Some elements have the suffix "PIV" during export, is it possible to remove with options.

Some extra nodes are created that are needed to reconstruct the way Maya positions objects in the world. For example PIV nodes are created to simulate Maya pivot points, and SSC nodes to simulate segment scale compensation. The matrices that Maya uses are much more complicated than the simple TRS (translation-rotation-scale) transformations of GLTF, so this is needed. If you make a rig that doesn't have pivot points and doesn't use segment scale compensation on the joints, then these nodes should not be created during export. If they still are, then that's a bug 😉 You can see check the log for has a pivot point, extra GLTF nodes will be added to handle this (but segment scale compensation is currently not reported, as it is the default setting in Maya, so would give a lot of messages). See e.g. this article

Can you give an example on how to batch export in python in readme/documentation ? With options for export ? This will be great as I'll try to construct a pipeline for export.

This repository contains a lot of experimental scripts for doing so, see the Maya/scripts folder, e.g. maya2glTF_exportAllScenes.mel. These haven't been used for a long time, so no guarantees here. Most of these are MEL, but should be easy to convert to Python. (giving support for this is beyond the scope of Maya2glTF, but you can almost contact me for commercial support if needed).

To know the options of the exporter, just open an empty scene, launch the exporter using the button in the GLTF shelf, and click export. You can also enter an invalid option in the extra flags text box, like -help. It will dump all options. Currently these are:

Usage:
-gfe  gltfFileExtension: string
-gbe  glbFileExtension: string
-of   outputFolder: string
-cof  cleanOutputFolder: flag
-sn   sceneName: string
-sf   scaleFactor: float
-glb  binary: flag
-sab  separateAccessorBuffers: flag
-sma  splitMeshAnimation: flag
-sbr  splitByReference: flag
-dgl  dumpGTLF: string
-dmy  dumpMaya: string
-dac  dumpAccessorComponents: flag
-ext  externalTextures: flag
-dm   defaultMaterial: flag
-cm   colorizeMaterials: flag
-ssm  skipStandardMaterials: flag
-smt  skipMaterialTextures: flag
-i32  force32bitIndices: flag
-dnn  disableNameAssignment: flag
-mts  mikkelsenTangentSpace: flag
-mta  mikkelsenTangentAngularThreshold: float
-dnv  debugNormalVectors: flag
-dtv  debugTangentVectors: flag
-dvl  debugVectorLength: float
-gof  globalOpacityFactor: float
-cpr  copyright: string
-afr  animationClipFrameRate: float+
-acn  animationClipName: string+
-ast  animationClipStartTime: time+
-aet  animationClipEndTime: time+
-ivt  initialValuesTime: time
-mpa  meshPrimitiveAttributes: string
-bpa  blendPrimitiveAttributes: string
-imd  ignoreMeshDeformers: string+
-ssc  skipSkinClusters: flag
-sbs  skipBlendShapes: flag
-rvp  redrawViewport: flag
-sno  selectedNodesOnly: flag
-vno  visibleNodesOnly: flag
-eut  excludeUnusedTexcoord: flag
-isc  ignoreSegmentScaleCompensation: flag
-ksn  keepShapeNodes: flag
-bsf  bakeScalingFactor: flag
-frn  forceRootNode: flag
-fac  forceAnimationChannels: flag
-fas  forceAnimationSampling: flag
-hbu  hashBufferUri: flag
-nbu  niceBufferNames: flag
-cui  convertUnsupportedImages: flag
-rsb  reportSkewedInverseBindMatrices: flag
-cow  clearOutputWindow: flag
-cam  cameras: string+
-ctt  constantTranslationThreshold: float
-crt  constantRotationThreshold: float
-cst  constantScalingThreshold: float
-cwt  constantWeightsThreshold: float
-kon  keepMayaNamespaces: flag

The documentation in the code explains these a bit, but I certainly need to update the readme, and check if all options still works 😉

During exports, sometimes, I've got wrong tangents or textcoords. On console, i saw you propose a small portion of code to identify them. But when I try to execute code, I've got errors.

Could you paste the error here? Also, if you can share the mesh that goes wrong, that would help (could be shared privately).

If you don't care about the Maya tangents, but want to use "industry standard mikktspace tangents" (http://www.mikktspace.com), you can try exporting with the -mts flag.

Can you add a button in your panel to execute this script automatically ?

So a button to analyse the mesh and report + select invalid vertices? That would be nice idea, a bit of work though.

PS: Please note that the whole idea of making a project open source is accepting external contributions, like those made from @fire and others. So feel free to hack around and submit pull requests 😄

@kopacabana
Copy link
Author

When I apply a pbr material to meshes, I can't play with TextCoords. When I change offset or rotation, nothing happens. Did I make a wrong manipulation ?

Do you mean that nothings happens in the Maya viewport, or that the UV coordinates are not correctly exported, or maybe both? Regarding export, I indeed don't do anything special here, I just call MFnMesh::getUVs, so I might need to do more work. I can see in our old Ogre exporter that we specially handle MFn::kPlace2dTexture, so I need to do the same. Of course glTF is limited here, it doesn't supporting animating these. The only solutions for now is to bake the UVs I'm afraid (I believe you have to copy the UV set and delete history, not sure, I'm not a technical artist 😉)

Nothing happens in the Maya viewport ! I don't test if TextCoords are exported correctly.

Is it possible to conserve name hierarchy in export (groups and mesh) ? Some elements have the suffix "PIV" during export, is it possible to remove with options.

Some extra nodes are created that are needed to reconstruct the way Maya positions objects in the world. For example PIV nodes are created to simulate Maya pivot points, and SSC nodes to simulate segment scale compensation. The matrices that Maya uses are much more complicated than the simple TRS (translation-rotation-scale) transformations of GLTF, so this is needed. If you make a rig that doesn't have pivot points and doesn't use segment scale compensation on the joints, then these nodes should not be created during export. If they still are, then that's a bug 😉 You can see check the log for has a pivot point, extra GLTF nodes will be added to handle this (but segment scale compensation is currently not reported, as it is the default setting in Maya, so would give a lot of messages). See e.g. this article

OK I made a parser in THREEJS, so i can change name of model and keep hierarchy.

Can you give an example on how to batch export in python in readme/documentation ? With options for export ? This will be great as I'll try to construct a pipeline for export.

This repository contains a lot of experimental scripts for doing so, see the Maya/scripts folder, e.g. maya2glTF_exportAllScenes.mel. These haven't been used for a long time, so no guarantees here. Most of these are MEL, but should be easy to convert to Python. (giving support for this is beyond the scope of Maya2glTF, but you can almost contact me for commercial support if needed).

Thanks I'm going to explore it.

To know the options of the exporter, just open an empty scene, launch the exporter using the button in the GLTF shelf, and click export. You can also enter an invalid option in the extra flags text box, like -help. It will dump all options.
The documentation in the code explains these a bit, but I certainly need to update the readme, and check if all options still works

This will be great !

During exports, sometimes, I've got wrong tangents or textcoords. On console, i saw you propose a small portion of code to identify them. But when I try to execute code, I've got errors.

Could you paste the error here? Also, if you can share the mesh that goes wrong, that would help (could be shared privately).

If you don't care about the Maya tangents, but want to use "industry standard mikktspace tangents" (http://www.mikktspace.com), you can try exporting with the -mts flag.

Here is a part of the error generated

// Error: line 1: Unsupported texture node 'kPluginDependNode' #456 // 
// Error: line 1: Mesh 'T_R_PEB2_B3Shape' has 96 invalid tangents!
Assign texture coordinates and/or cleanup your mesh and try again please.
Use the following command to visualize the tangents and select the first invalid face-vertices:

doMenuComponentSelectionExt("T_R_PEB2_B3Shape", "pvf", 0);
setAttr "T_R_PEB2_B3Shape.displayTangent" 1;
checkMeshDisplayNormals "T_R_PEB2_B3Shape";

Can you add a button in your panel to execute this script automatically ?

So a button to analyse the mesh and report + select invalid vertices? That would be nice idea, a bit of work though.

Yes a bit of work but great ! If I have time, i'll be interesting to participate but no time... And I don't think to have skills for helping. Sorry.

PS: Please note that the whole idea of making a project open source is accepting external contributions, like those made from @fire and others. So feel free to hack around and submit pull requests 😄

@ziriax
Copy link
Contributor

ziriax commented Nov 20, 2020

Nothing happens in the Maya viewport ! I don't test if TextCoords are exported correctly.

Okay, thanks for the info.

I tried to simulate this behavior, but I can't even connect a 2D placement texture node to the PBR GLSLShader in the Hypershade. How did you change the UV rotation and offsets? It's even mentioned explicitly in the manual that this is impossible, so I'm curious how you did this.

I see if I can reproduce the vertex errors bugs.

@ziriax
Copy link
Contributor

ziriax commented Nov 20, 2020

During exports, sometimes, I've got wrong tangents or textcoords. On console, i saw you propose a small portion of code to identify them. But when I try to execute code, I've got errors.

I tried executing the commands on the mesh I have, and I get no errors. It would be useful if you pasted the errors here, so I can examine what goes wrong.

@kopacabana
Copy link
Author

kopacabana commented Nov 20, 2020

I tried to simulate this behavior, but I can't even connect a 2D placement texture node to the PBR GLSLShader in the Hypershade. How did you change the UV rotation and offsets?

Maybe I'm wrong ! In the hypershade when I connect texture to baseColorMap, I've got place2DTexture node.
Here is a screenshot where I try to change repeat UV but nothing happens in the viewport.
gltf_01

@kopacabana
Copy link
Author

kopacabana commented Nov 20, 2020

I tried executing the commands on the mesh I have, and I get no errors. It would be useful if you pasted the errors here, so I can examine what goes wrong.

Here is a sample mesh where I've got error when I export and the error

// Error: line 1: Mesh 'T_PEB2_B3Shape' has 96 invalid tangents!
Assign texture coordinates and/or cleanup your mesh and try again please.
Use the following command to visualize the tangents and select the first invalid face-vertices:

doMenuComponentSelectionExt("T_PEB2_B3Shape", "pvf", 0);
setAttr "T_PEB2_B3Shape.displayTangent" 1;
checkMeshDisplayNormals "T_PEB2_B3Shape";

gltf_error.zip

@rdurnin
Copy link

rdurnin commented Dec 4, 2020

Adding UV repeat and rotation would require enabling the KHR_texture_transform described here, as well as support on the side of the importer for the extension. The current version of the plug-in also does not support aiImage texture nodes for export. If these are currently planned changes, please let me know, otherwise I will look into adding them as they are needed for my current workflow.

I would also add support for mesh instances to this list of features, and would like to be part of the discussion on how to best implement them.

@ziriax
Copy link
Contributor

ziriax commented Dec 4, 2020

I tried executing the commands on the mesh I have, and I get no errors. It would be useful if you pasted the errors here, so I can examine what goes wrong.

Here is a sample mesh where I've got error when I export and the error

// Error: line 1: Mesh 'T_PEB2_B3Shape' has 96 invalid tangents!
Assign texture coordinates and/or cleanup your mesh and try again please.
Use the following command to visualize the tangents and select the first invalid face-vertices:

doMenuComponentSelectionExt("T_PEB2_B3Shape", "pvf", 0);
setAttr "T_PEB2_B3Shape.displayTangent" 1;
checkMeshDisplayNormals "T_PEB2_B3Shape";

gltf_error.zip

Thanks, I'll look into it

@ziriax
Copy link
Contributor

ziriax commented Dec 4, 2020

I tried to simulate this behavior, but I can't even connect a 2D placement texture node to the PBR GLSLShader in the Hypershade. How did you change the UV rotation and offsets?

Maybe I'm wrong ! In the hypershade when I connect texture to baseColorMap, I've got place2DTexture node.

Aha, I see. I'll try to reproduce this. It seems Maya doesn't support this out-of-the-box in a hardware CG shader. I would have to add attributes that need to be connected to the 2D texture placement, as described in the manual:

Adding placement into CgFx shaders
Cgfx shaders do not automatically support texture placement which is found inside Maya (place2DTexture or place3DTexture node) because CgFx is a node which uses a programmable shading language. Using this language means that the texture transform cannot be set from outside. Instead, it needs to be explicitly coded into the shader. If such parameters are in the shader, then the automatic UI generation creates the UI elements. You should then connect the appropriate attributes from the texture placement node(s) to the attributes on the shader.

That would be a nice feature, although unlike OGRE3D or other engines, GLTF doesn't support this out-of-the-box either (surely an extension will exist for it)

@ziriax
Copy link
Contributor

ziriax commented Dec 4, 2020

Adding UV repeat and rotation would require enabling the KHR_texture_transform described here, as well as support on the side of the importer for the extension. The current version of the plug-in also does not support aiImage texture nodes for export. If these are currently planned changes, please let me know, otherwise I will look into adding them as they are needed for my current workflow.

I would also add support for mesh instances to this list of features, and would like to be part of the discussion on how to best implement them.

@rdurnin Thanks for the feedback! Very interesting

As this exporter is now a "hobby" project of mine, all contributions are welcome! (I'm no longer an employee at iimachines, although I do occasional freelance work for them).

Can you make 3 issues for these separate feature requests? Then we can discuss this further.

@ziriax
Copy link
Contributor

ziriax commented Dec 4, 2020

I tried executing the commands on the mesh I have, and I get no errors. It would be useful if you pasted the errors here, so I can examine what goes wrong.

Here is a sample mesh where I've got error when I export and the error

// Error: line 1: Mesh 'T_PEB2_B3Shape' has 96 invalid tangents!
Assign texture coordinates and/or cleanup your mesh and try again please.
Use the following command to visualize the tangents and select the first invalid face-vertices:

doMenuComponentSelectionExt("T_PEB2_B3Shape", "pvf", 0);
setAttr "T_PEB2_B3Shape.displayTangent" 1;
checkMeshDisplayNormals "T_PEB2_B3Shape";

It seems you must manually show the vertex-faces once, otherwise the script fails.
image

I need to figure how to pre-load this somehow.

Then it all works for me. Then in the 3D view I use show/isolate select to show the invalid vertex/normal/tangents

@kopacabana
Copy link
Author

Thanks Ziriax, I'll explore this way ! I'll give you feedback...

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

3 participants