Jump to content

Meshes From 3ds Max To Babylon Have Strange See-through Effects


Recommended Posts

Hello everyone,

I have been struggling with a strange problem exporting scene from 3ds Max to Babylon.

Some of the meshes end up having strange see-through effects in babylon, like this (you can see the wall and floor in the other room):

scrs03.thumb.jpg.9dd8545a696fbeecd7e5afd7d2e73baa.jpg

Experimenting with the materials, I found that:

Without albedo / basecolor map, the effect is gone (check out the slates on the ground, they are looking normal):

scrs01.thumb.jpg.db0df258b9eeca4b166e505aa788f3d6.jpg

With albedo / basecolor map, strange see-through effect happens (you can see the hidden faces of the slates, giving the illusion of steps):

scrs02.thumb.jpg.83b5fa83b2ffe369eeb8da70d5c090b6.jpg

Related information:

1. 3ds max 2017

2. Max2Babylon 1.3.0

3. Metallic/Roughness PBR workflow. All materials in max are physical materials

4. Meshes have 2 uv channels with occlusionTexture (AO) on channel 2

5. Meshes both with and without multi-material might have this problem (as far as I can see, this effect is pretty random)

6. In the see-through, only the surfaces with alebedo / basecolor maps can be seen, surfaces defined by color properties cannot be seen

7. The see-through happens after a certain glaring angle, meaning if looking straight / perpendicular at the surface there is no see-throught, however as the line of sight gets more parallel to the surface to a certain degree, see-through happens.

Has anyone had similar problems?

Hope someone can point me to the right direction.

Thanks a lot!

[Edit] -  Further discovery: converting the problematic albedo / basecolor maps from .jpg to .png in photoshop solved the problem. There must be something wrong with the .jpg file or some compatibility issue somewhere in the pipeline. I have attached the .jpg files, maybe they are overly compressed?

slate_albedo.jpg

tile_dark_albedo.jpg

Edited by hcmetal
Link to comment
Share on other sites

@hcmetal thank you for attaching the jpg files. Would you be able to post a Max file and your output file (Babylon or glTF) so that we can diagnose the whole chain to determine what is happening? If you have a playground with the issue appearing, that would also help repro the issue. I appreciate the help and we will get back to you asap on a solution. 

Link to comment
Share on other sites

@PatrickRyan, thanks for your reply. I have good news and bad news.

Good news is as I tried to use the old .jpg albedo maps today, the see-through doesn't happen in babylon any more.

Bad news is I cannot even reproduce the problem myself:D. Maybe this is one of those legendary "3ds-max mythical weirdnesses".

Anyway I have attached the max and the babylon file. Sorry I cannot provide all the textures because of copy-right issues, but we are free to experiment with the max scene and the .jpg files attached earlier.

Hope this will help with the diagnosis. Even if we cannot catch it this time, I will be on the look out and report future occurrences.

Please let me know if you find anything interesting.

Cheers!

handson01_opt_multimat_diagnose.zip

hotel.babylon

Link to comment
Share on other sites

Here is a new PG with problematic mesh faces on the bamboo model, they are inverted and penetrating each other:

https://playground.babylonjs.com/#RXQXIY#1

bamboo.jpg.d4ee4e99434dd75c5b3fec7d59875c25.jpg

This might be caused by the fact that the albedo map has alpha information to make the leaves transparent.

Because the leaves are single faced, I set mesh.material.backFaceCulling = false;

If culling is set to true, the invertion is gone but the z-order of the faces are still wrong.

This might lead to a new problem with transparent albedo maps...

I have also attached the max files and related textures for anyone who is interested in having a look.

bamboo_diagnose.zip

Link to comment
Share on other sites

In the 3dsMax exporter, have you the choice of material shader conversion? Because issue is gone when using a PBRMaterial :

https://playground.babylonjs.com/#RXQXIY#2

Can't going further, my max version is too old here :)

[edit] A quick-and-dirty fix on your playground could be to set transparencyMode to alpha_test, but, not really satisfaying https://playground.babylonjs.com/#RXQXIY#3 [/edit]

Edited by V!nc3r
Link to comment
Share on other sites

@V!nc3r, thanks for your help!

Re-assigning the material in babylon does solve the problem.

However, as I try to understand the docs: https://doc.babylonjs.com/resources/3dsmax_to_gltf#pbr-materials

Phyiscal materials (or any exporter supported shader types) in max are converted to PBRMaterials in babylon, and there doesn't seem to be an option of material conversion in the exporter.

So my understanding is that materials should be converted to (and only to) PBR through the exporter automatically.

Maybe something goes wrong during the export and re-assigning the PBR clears the problem.

This provides a partial but nevertheless practical solution to the problem: Even if the export is sometimes problematic and unpredictable, I can always wirte some batch-material-re-assigning code to "refresh" them.

Thanks again!

Link to comment
Share on other sites

If I'm not wrong, by seeing the inspector in your playground

dCVQSI6.png

it seems that the 3dsMax exporter use PBRMetallicRoughnessMaterial and not PBRMaterial, maybe it's a lead to follow? Test on the playground get the bug too: https://playground.babylonjs.com/#RXQXIY#4

So it seems that you may spotted a bug on the PBRMetallicRoughnessMaterial shader :)

[edit] you may try with the gltf format instead of babylon? [/edit]

Edited by V!nc3r
Link to comment
Share on other sites

Thanks, it looks like a bug in the exporter cause the transparency mode is always set to Blend to deal with transparency whereas in your case where you want a simple mask it should be set to alpha test:

https://github.com/BabylonJS/Exporters/blob/5b711de23a41f26206559dc32bad73eeeb9c77e0/3ds Max/Max2Babylon/Exporter/BabylonExporter.Material.cs#L383

@kcoley Could you create a fix based on what the standard is checking to deal with Alpha Test ?

I created the issue on the github repo for follow up https://github.com/BabylonJS/Exporters/issues/335

 

Link to comment
Share on other sites

After reading the docs: https://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered and experimenting with the bamboo, I realized there might be a dilemma here:

1. Transparency mode set to "alpha test" will result in bad anti-aliasing around the transparency borders (which is very obvious from afar), but have no z-sorting or normal-inversion problems;

2. Transparency mode set to "alpha blend" will result in good anti-aliasing around the transparency borders, but have z-sorting and normal-inversion problems, because the model is intersecting with itself and backfaceculling is disabled;

Even if I enable backfaceculling and double the faces of leaves with inverted normals (which might cost some performance?), the z-sorting is still problematic.

So I am wondering what is the best way to deal with this kind of plant models in Babylon...

Is there a better way to break up the model somehow and set proper material types so that the idea combo of "good anti-aliasing" + "correct z-sorting" + "no inverted normals"?

Or maybe the alpha channel in the .png albedo map should be somehow premultiplied (or not) to achieve better anti-aliasing?

This might be leading to a different issue than the original topic of the post, but I think this is a very important topic nevertheless because plants and vegetation are common in both game and arch-viz.

Hope we can work together on this issue and eventually make the bamboo look good:)

Cheers everyone!

 

Link to comment
Share on other sites

Hi @hcmetal.  I originally tried to author a custom attribute on the textures so you can specify which uses alpha mask or alpha blend, but unfortunately, 3ds Max would not allow me to do this.  So we are going to try to create a custom Babylon.js node that can be used in junction with material in the scene to give you the option to set these properties if it works.

Link to comment
Share on other sites

@hcmetal turns out I was able to add a custom attribute to the materials to allow toggling AlphaTest during export.  I just pushed an update to the 3ds Max exporter which supports this.  Feel free to give it a try.

To enable the alpha test toggle, you will have to set a "babylonAlphaTest" boolean custom attribute on your materials.  Setting this to true will enable alpha test mode.  You can use this script for reference:

https://github.com/BabylonJS/Exporters/blob/master/3ds%20Max/MaxScripts/BabylonMaterialAttributes.ms

 

Let me know if you have questions on this.

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...