abhivaidya Posted July 5, 2018 Share Posted July 5, 2018 I am loading an OBJ file but generally it appears a bit dark. However, if I turn off the Ambient texture or the Diffuse texture channel from the inspector, it seems to be "lit" enough. Any idea why this happens and if through code I need to turn off the channels how can I do it? Quote Link to comment Share on other sites More sharing options...
RaananW Posted July 5, 2018 Share Posted July 5, 2018 You can check what textures are be4ing loaded in the .mtl file and manipulate them correctly after the .obj is loaded. Maybe it is a matter of lighting? Want to share images, or better yet - a scene? Quote Link to comment Share on other sites More sharing options...
dbawel Posted July 5, 2018 Share Posted July 5, 2018 @abhivaidya As @RaananW advises, I almost always edit my .mtl files when importing textures with my .obj; as material attributes don't necessarily represent your exported mesh attributes in your 3D application. I often simply remove the .mtl file (also must edit and remove the .mtl reference in the .obj file) and let the importer set default materials on the mesh. Then assign what you like within the babylon.js framework. DB RaananW 1 Quote Link to comment Share on other sites More sharing options...
brianzinn Posted July 6, 2018 Share Posted July 6, 2018 If you are using blender when you export to OBJ you can also deselect "Write Materials", which will use the default material as dbawel has suggested. edit: Which editor are you using for the 3D model? I think you need to share an example. cheers. Quote Link to comment Share on other sites More sharing options...
abhivaidya Posted July 6, 2018 Author Share Posted July 6, 2018 Thanks for the replies guys! @RaananW Here are the images..... The first is a capture with all channels on by default in the inspector The second is a capture with Ambient channel turned off in the inspector (the result is the same if you turn off the diffuse channel as well) @dbawel Not very sure about editing the obj. Your suggestion does make sense but since I am only learning and evaluating BJS for an internal project, I was trying to keep it simple. If nothing works, I will surely look into the editing bit. @brianzinnWe are using 3DS max. Sadly dont have access to a Blender expert inhouse and they are used to working with Unity :(. I am just trying to make a case for BJS! Quote Link to comment Share on other sites More sharing options...
Guest Posted July 6, 2018 Share Posted July 6, 2018 Why not exporting .Babylon file if you are in 3dsmax? You should get a better support of all bjs features directly If you need to stick with obj, you should check inside the generated file if the diffuse channel or ambient channel are not too dark (this could come from your obj exporter) Quote Link to comment Share on other sites More sharing options...
dbawel Posted July 7, 2018 Share Posted July 7, 2018 @abhivaidya OBJ files are simply text files. If you edit these, there are no consequences other than what you edit. If you haven't look at an OBJ file in a text editor, here's what the first 13 lines look like: Quote #### # # --- # GeneratorVersion: 1.0.A.0.49 # CoordSystemRUF: [+X,-Y,+Z] # Vertices: 8223 # Faces: 15096 # SphinxScanType: 257 # ... #### mtllib mesh.mtl o mesh #### Simply remove line 11 and the OBJ will not reference the MTL file and automatically revert to default materials. Then you can (and often should generally) set your own material values within the babylon framework. However, if you want to go further, you can keep the reference to the MTL file in your OBJ file and edit the MTL file. Here's an example of one of my production MTL files in a text editor: Quote #### # # #### newmtl mesh Ns 100 Ka 0.000000 0.000000 0.000000 Kd 1.000000 1.000000 1.000000 Ks 0.500000 0.500000 0.500000 Ni 1.000000 d 1.000000 illum 0 map_Kd mesh.jpeg They are self explanatory. However, If you want to know how extensive these can get, then take a look at the online explaination I found below: http://paulbourke.net/dataformats/mtl/ I generally stick to the basics as you see in my example, however, all of the work can be accomplished within the format if you don't want to work within the babylon framework. And again, there's very few edits that will cause errors; even removing lines. However, as you get into more extensive edits and/or additions to the file, that's when you will get errors upon loading. But these files are simple to understand and edit, and extremely powerful. I hope this helps others as well who are restricted by believing they must use a .babylon converter to export geometry and all of it's material and texture attributes relying upon the existing exporters. We've been relying upon OBJ and MTL files for decades without issues. Just a few minutes of playing around, and you can be an expert. This is NOT to say that I don't use the existing exporters as they are AWESOME. The Devs writing the exporters are working extremely hard to make it much simpler for everyone to export their scenes into the Babylon framework. However, it's always good practice to have a reliable fallback when you aren't able to export your geometry as you foresee, and using the OBJ format is always reliable. At least it has been for me for over 20 years. DB Quote Link to comment Share on other sites More sharing options...
abhivaidya Posted July 9, 2018 Author Share Posted July 9, 2018 On 7/6/2018 at 8:26 PM, Deltakosh said: Why not exporting .Babylon file if you are in 3dsmax? You should get a better support of all bjs features directly If you need to stick with obj, you should check inside the generated file if the diffuse channel or ambient channel are not too dark (this could come from your obj exporter) Hey @Deltakosh!!! Well we did try the babylon file. However the normals were inverted for some surfaces strangely. We are actually facing this issue with our character models as well. However, when we used the OBJ format, it worked fine. Hence we stuck to using this format. On 7/7/2018 at 12:04 PM, dbawel said: @abhivaidya OBJ files are simply text files. If you edit these, there are no consequences other than what you edit. If you haven't look at an OBJ file in a text editor, here's what the first 13 lines look like: Simply remove line 11 and the OBJ will not reference the MTL file and automatically revert to default materials. Then you can (and often should generally) set your own material values within the babylon framework. However, if you want to go further, you can keep the reference to the MTL file in your OBJ file and edit the MTL file. Here's an example of one of my production MTL files in a text editor: They are self explanatory. However, If you want to know how extensive these can get, then take a look at the online explaination I found below: http://paulbourke.net/dataformats/mtl/ I generally stick to the basics as you see in my example, however, all of the work can be accomplished within the format if you don't want to work within the babylon framework. And again, there's very few edits that will cause errors; even removing lines. However, as you get into more extensive edits and/or additions to the file, that's when you will get errors upon loading. But these files are simple to understand and edit, and extremely powerful. I hope this helps others as well who are restricted by believing they must use a .babylon converter to export geometry and all of it's material and texture attributes relying upon the existing exporters. We've been relying upon OBJ and MTL files for decades without issues. Just a few minutes of playing around, and you can be an expert. This is NOT to say that I don't use the existing exporters as they are AWESOME. The Devs writing the exporters are working extremely hard to make it much simpler for everyone to export their scenes into the Babylon framework. However, it's always good practice to have a reliable fallback when you aren't able to export your geometry as you foresee, and using the OBJ format is always reliable. At least it has been for me for over 20 years. DB Thanks for the lovely explanation @dbawel! I am going to try this today and let you know how it works. BTW I immediately did try editing the MTL and OBJ when you suggested, and it was simple enough. However, the output was kinda same. However, let me try and do that again and I will let you know what I come up with. dbawel 1 Quote Link to comment Share on other sites More sharing options...
dbawel Posted July 9, 2018 Share Posted July 9, 2018 @abhivaidya Please pay close attention to the link to the docs I included. There's very little you can't do with materials and textures using (modifying/deleting/adding) these attributes. However, my preference is always to import my OBJ into the babylon framework, and then I can modify my materials and textures with much simpler control and more specific and dynamically. DB Quote Link to comment Share on other sites More sharing options...
Guest Posted July 9, 2018 Share Posted July 9, 2018 @abhivaidya: If you found a bug with the Babylon exporter for 3dsmax, please provide a repro and create an issue here:https://github.com/BabylonJS/Exporters We will fix it in less than a week dbawel 1 Quote Link to comment Share on other sites More sharing options...
Recommended Posts
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.