Problem/difficulties with .obj texture import

Report crashes, strange behaviour, or apparent bugs
Post Reply
mfloyd
Posts: 21
Joined: 29 Oct 2014, 23:06

Problem/difficulties with .obj texture import

Post by mfloyd »

I've noticed a few inconsistencies and problems when applying color properties when importing a .obj. Whenever a texture is applied, the Ambient/diffuse components are not set. Since textures are applied as modulated (as they should be), then the base color should still be applied as well. Simple materials import the ambient/diffuse components correctly.

A few extra related things I've noticed is that any transparency parameters are ignored so I have to manually apply them in V-rep (to headlights, glass panels, windows, etc). For one of the transparent materials, the windows had a transparency texture map applied to indicate dirty places on the window. I understand why V-rep might not implement transparency texture import, but thought I'd at least mention it. I also noted that Ns might somehow corresponds to V-reps Shininess and should probably affect it, but again, it's not a problem.

I also noticed that If I manually apply textures, the imported texture coordinates are no longer available in the texture mapping mode options. This was a big problem when the .mtl file was missing because applying the textures manually afterwards wouldn't come close to the correct results. I got around it before I had the correct .mtl file by manually writing my own .mtl file that specified the correct textures for each material used in the .obj file, then re-importing the model. Textures should be able to be re-applied later if the texture is adjusted without re-importing the part. Unnecessary work has to be redone in that case especially if the part is modified using the shape edit mode that keeps the texture coordinates intact. Textures can't just be swapped after import.


Here's some extracts from the .mtl file where the colors are specified along with the properties found in the color dialogue in order to show specifics of what I state above. The values that should correspond are
Ka/Kd : Ambient/diffuse
Ks : Specular
Ke : Emissive
Ns : Shininess?
d/Tr/Tf : Opacity

Simple materials with no textures (acceptable):

newmtl metal
Ns 11.0000
Ni 1.5000
d 1.0000
Tr 0.0000
Tf 1.0000 1.0000 1.0000
illum 2
Ka 0.2706 0.2706 0.2706
Kd 0.2706 0.2706 0.2706
Ks 0.5040 0.5040 0.5040
Ke 0.0000 0.0000 0.0000

Vrep:
Ambient/diffuse: 0.27 each (good)
Specular: 0.5 each (good)
Emissive: 0.0 each(default good)
Shininess: 48 (not affected by Ns, but should be)
Opacity: Disabled (Good: d=1)

newmtl Orange_Lights
Ns 10.0000
Ni 1.5000
d 0.9000
Tr 0.1000
Tf 0.9000 0.9000 0.9000
illum 2
Ka 0.8157 0.4784 0.1765
Kd 0.8157 0.4784 0.1765
Ks 0.0000 0.0000 0.0000
Ke 0.0408 0.0239 0.0088

Vrep:
Ambient/diffuse: 0.82, 0.48, 0.18 (good)
Specular: 0.0, 0.0, 0.0 (good)
Emissive: 0.0, 0.0, 0.0 (Not applied correctly, should be 0.0408 0.0239 0.0088)
Shininess: 48 (not affected by Ns, but should be)
Opacity: Disabled (Should be enabled with value 0.9)

Some transparent materials where opacity was not applied:

newmtl Dial_Glass
Ns 12.0000
Ni 1.5000
d 0.2300
Tr 0.7700
Tf 0.2300 0.2300 0.2300
illum 2
Ka 1.0000 1.0000 1.0000
Kd 1.0000 1.0000 1.0000
Ks 0.2361 0.2361 0.2361
Ke 0.0400 0.0400 0.0400

Vrep:
Ambient/diffuse: 1.0, 1.0, 1.0 (good)
Specular: 0.24, 0.24, 0.24 (good)
Emissive: 0.0, 0.0, 0.0 (Not applied correctly, should each be 0.04)
Shininess: 48 (not affected by Ns, but should be)
Opacity: disabled (should be enabled with value 0.23)

newmtl Windows
Ns 4.0000
Ni 1.5000
d 1.0000
Tr 0.0000
Tf 1.0000 1.0000 1.0000
illum 2
Ka 0.8157 0.7765 0.6510
Kd 0.8157 0.7765 0.6510
Ks 0.2200 0.2200 0.2200
Ke 0.0000 0.0000 0.0000
map_Ka Windows.jpg
map_Kd Windows.jpg
map_d Windows_o.jpg

Vrep:
Ambient/diffuse: 0.5, 0.5, 0.5 (should be 0.8157 0.7765 0.6510)
Specular: 0.22, 0.22, 0.22 (good)
Emissive: 0.0, 0.0, 0.0 (Happened to be applied correctly because default?)
Shininess: 48 (not affected by Ns, but should be)
Opacity: disabled (From d should be 1.0, but map_d adds a texture that modulates the opacity near the 0.0 range for dirty places on the window...)). I understand why this might not be applied.
map_Ka/map_Kd apply the correct texture.

Some materials with texture maps and the Ambient/Diffuse property was not applied:

newmtl interior
Ns 10.0000
Ni 1.5000
d 1.0000
Tr 0.0000
Tf 1.0000 1.0000 1.0000
illum 2
Ka 0.5882 0.5882 0.5882
Kd 0.5882 0.5882 0.5882
Ks 0.0540 0.0540 0.0540
Ke 0.0000 0.0000 0.0000
map_Ka Interior.jpg
map_Kd Interior.jpg

Vrep:
Ambient/diffuse: 0.50 each (should be 0.59 each, 0.5 is the default)
Specular: 0.054 each (good)
Emissive: 0.0 each (good, default)
Shininess: 48 (should be affected by Ns?)
Opacity: disabled (good since d=1)
map_Ka/map_Kd properly imported Interior.jpg

newmtl Exterior
Ns 12.0000
Ni 1.5000
d 1.0000
Tr 0.0000
Tf 1.0000 1.0000 1.0000
illum 2
Ka 0.5880 0.5880 0.5880
Kd 0.5880 0.5880 0.5880
Ks 0.1620 0.1620 0.1620
Ke 0.0000 0.0000 0.0000
map_Ka Exterior.jpg
map_Kd Exterior.jpg
map_bump Exterior_B.jpg
bump Exterior_B.jpg

Vrep:
Ambient/diffuse: 0.50 each (should be 0.59 each, 0.5 is the default)
Specular: 0.16 each (good)
Emissive: 0.0 each (good, default)
Shininess: 48 (should be affected by Ns?)
Opacity: disabled (good since d=1)
map_Ka/map_Kd properly imported Exterior.jpg
map_bump/bump: I don't know if these textures were applied in v-rep. Not a big deal if they aren't.

coppelia
Site Admin
Posts: 10339
Joined: 14 Dec 2012, 00:25

Re: Problem/difficulties with .obj texture import

Post by coppelia »

Hello,

we have addressed most of your issues (for the next release). There are however often inconsistencies how various applications write the format, so we tried to keep things as visually appealing as possible. And we ignored the Ns values, since there too, no one seems to exactly know the real bounds of that values (sometimes 0-100, othertimes 0-200, and the specifications according to wikipedia says 0-1000). In any case, many of those vlues will directly depend on what type of rendering you have, and how you have implemented it.

Cheers

mfloyd
Posts: 21
Joined: 29 Oct 2014, 23:06

Re: Problem/difficulties with .obj texture import

Post by mfloyd »

Thanks!

Post Reply