OBJ Import Alpha Map Problem
Closed, ResolvedPublic


Intel Pentium Core 4 I5 2500K
Intel HD 3000
Windows 7 Ultimate 64-bit
Blender 2.63a and 2.64 RC1

When import an OBJ model in Blender, if Texture has an Alpha Channel, this channel is skipped.

I opened "import_obj.py" script file and checked.

if image:
texture.image = image
has_data = image.has_data

In this code, "image.has_data" always return "False" value. If change this code:

if image:
texture.image = image
has_data = True

Fix this problem.

And use "map_d" in MTL file, and load "Alpha Map", then this texture slot must up on the Diffuse Texture, otherwise not work properly and user be obliged to change this order manual.

map_d Texture_ALPHA.png
map_Kd Texture.png

This order work.

map_Kd Texture.png
map_d Texture_ALPHA.png

This order is not work. Import script must fix order automaticly, but not do.



Campbell, can you please check on that? Not a stopper, can be fixed after release though.

This makes sense, if textures are not assigned to alpha textrue channels we dont have to set the alpha values.

Having the image data available isn''t a given so probably we better jabe it check for map_d or map_tr

note that map_tr stands for "Translucency" and map_d for "transparency"

Order problem fixed on 2.64a.

Some programs not write "map_d", if image has an alpha channel, only write "map_Kd". Example XFrog export from "DEEP Exploration" program.

Some programs cannot read space characters in path. Path value get inside double quotes. So all programs will able to read OBJ files export from Blender (example DAZ Studio).

In Blender, alpha masked materials should "Alpha = 0" and when export OBJ file, write "d 0.000000". But most programs cannot reads this value correctly, because in this programs use "d 1.000000" value (example 3ds Max, DAZ Studio). And on this programs surface appear completely transparent (invisible).

the problem is that blender interpretes "tr" values as transparency while all others follow the obj documentation and use it as translucency which has inverted values to alpha.
i already tried to explain this in irc but seems its really hard to understand that d!=tr / transparency != TRANSLUCENCY and need to be handled seperately.
this is why it fails.

Hi, looking into this report, since its opened some of the issues with material setting import/export have been resolved.

Hikmet Koyuncu: You say...
In Blender, alpha masked materials should "Alpha = 0" and when export OBJ file, write "d 0.000000". ...

This should be reported as a separate bug, with example of expected output and blend file which produces incorrect output.

Could you include an OBJ that doesnt import correctly?

I can see how the code might not work but Id like to verify the changes fix this bug.

fixed r4028. now has_data works as it used to.