Sign in to follow this  
abhivaidya

Loaded OBJ file is dark

Recommended Posts

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?

Share this post


Link to post
Share on other sites

@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

Share this post


Link to post
Share on other sites

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.

Share this post


Link to post
Share on other sites

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)

 

With.jpg

Without.jpg

 

@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!

 

 

Share this post


Link to post
Share on other sites

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)

Share this post


Link to post
Share on other sites

@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

Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites

@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

Share this post


Link to post
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...
Sign in to follow this  

  • Recently Browsing   0 members

    No registered users viewing this page.