I am trying to export our mesh as gltf from 3ds Max with double sided material applied on that. But, the exporter shows 0 vertices on selected node (our mesh) and nothing was exported.
But the same mesh, with single side material, its exporting fine. Also, when I just create a plane and apply double side material and export, that also works fine.
I am using 3ds Max 2018 version.
I am not able to attach files because of new user, once i got permission, then i will update the files. Meantime, does anybody has any idea what may be the issue?
Regards,
Gopinath.
@tagopinath, what is happening here is that you are trying to use a feature in 3ds Max that isn’t supported by glTF. When glTF speaks of double-sided materials it means that back face culling is disabled and the same material is rendered on both front faces and back faces. In practice it looks like this:
In essence, it is passing two different shaders, one for the front faces and one for the back faces. Unfortunately, glTF does not support this directly. The reason you are seeing nothing when you try to load your glTF into a Babylon.js scene is that the mesh does not know what to do with the material assign, and fails over to exporting an abstract mesh. You can see in the log below when I try to export your scene as is:
If I am to export the mesh with just a single physical material assigned to the mesh without the facing combination node, you can see that the mesh does indeed export:
You can achieve this, however, by using a node material in your Babylon.js scene. You will just need to load your back face texture into the scene either by including it in your glTF file on a temporary material, or load it directly as a new BABYLON.Texture. You will then create a new node material that contains your texture sets separated by facing and then use a Front facing node as the gradient of a lerp between the two texture sets. Here you can see a simple example of this setup using a different color for each facing. We have green on the front faces and red on the back faces:
I am getting issue when these kind of objects are getting exported as gltf (the max file which I sent). But, when I tried with single plane with same set of materials, then I am able to export.
@tagopinath, I tested your plane sample. Unfortunately, I don’t have Max 2018 installed, so tested it with the two versions I have installed. In Max 2023, I get the same result as in your original file in that the plane does not get exported when using the layered shader. Instead it gets exported only as a transform:
Our exporters will not be able to handle the double-sided node in Max’s slate material editor because that is creating a custom shader handling two physical materials based on front/back face. That doesn’t exist in the glTF specification so each of the exporter versions are handling it slightly differently. In the earlier version, the material is dropped and the mesh is exported. In the later version, because the material is invalid, the mesh is exported only as a transform.
Basically in every case, with every kind of mesh, the export will fail in some way due to the fact that the only valid materials for export are Physical Material, Arnold Standard Surface, and PBR Material (later versions of Max). Anything done in the slate material editor to combine, alter, or use procedural processes to manipulate the shader will fail as the specification for glTF is pretty narrow in what is defined as a viable material definition.
If you are using a custom node material like the sample I shared above, you control the rendering of the backfaces directly in the shader itself and the exporter does not control anything about how the material is rendered. This is because the node material is a new material you would apply to your mesh and would handle passing textures based on front/back face.
Its weird. Let me try to export the same scene (single plane) in max 2023 version and see what is happening.
Also, I can download the code from Git for this exporter. If i am able to write the gltf file with the format mentioned in that, for our objects (with double sided), will that work in gltf viewer? Is that very hard to read and understand and write the format?
@tagopinath, you are certainly welcome to download the exporter source and made additions to it as it is open source. You can also contribute back to the exporter project if you expand capabilities. Our team will review and comment on any PR, but you can certainly contribute as you like.
When it comes to expanding the exporter to handle a double-sided material as I understand you are trying to build, you limitation won’t be the exporter but the glTF format itself. If you want to pass different texture sets based on facing, this will need a custom shader in glTF which does not exist. You would need to also create an extension for glTF to include the custom shader and then your limitation would be support of that extension in the engines you want to render with.
The other way to handle this without any custom extensions would be to duplicate your mesh, and reverse the faces. This way you will see front faces for both inside and outside of the garment and then simply apply a second material with the desired textures to each mesh. This will work with the current exporters, and any renderer that uses glTF as a format.
If you want to keep draw calls down by limiting meshes and materials, then a Babylon node material would be your best bet. I hope all of this helps you in your explorations.
I am planning to move on to Max 2024. I am not able to see the libraries for Max 2024, it shows upto Max 2023.
Any approximate time when this can be released ?