Wavefront OBJ exporter should export more precise illum value in MTL file #43487

Closed
opened 2015-01-30 15:05:06 +01:00 by Mike · 6 comments

Short description of error
When using transparency settings, the OBJ exporter still uses only the values 0,1 and 2 for the illum parameter. This may confuse other programs that rely on the correctness of this parameter.

Exact steps for others to reproduce the error
Create any kind of model and attach a material to it. Make sure to use transparency and export the object as Wavefront obj file (make sure to check "Write Materials").

Open the MTL file and verify the illum parameter.

Idea of a fix
Change the respective lines in scripts/addons/io_scene_obj/export.py:

            # 0 to disable lighting, 1 for ambient & diffuse only (specular color set to black), 2 for full lighting, 4 and 9 for transparency
            if mat.use_shadeless:
                fw('illum 0\n')  # ignore lighting
            elif mat.specular_intensity == 0:
                fw('illum 1\n')  # no specular.
            elif mat.use_transparency:
                if mat.transparency_method == 'RAYTRACE':
                    fw('illum 4\n')  # transparency with raytrace
                else:
                    fw('illum 9\n')  # transparency without raytrace
            else:
                fw('illum 2\n')  # light normaly

Important note

This does only cover transparency now, because I don't know blender good enough to provide a full fix.

Someone with more knowledge might want to cover all illum modes:

Plain: already covert
Italics: covered by my "fix"
Bold: not covered yet

0: Color on and Ambient off
1: Color on and Ambient on
2: Highlight on
3: Reflection on and Ray trace on
4: Transparency: Glass on, Reflection: Ray trace on
5: Reflection: Fresnel on and Ray trace on
6: Transparency: Refraction on, Reflection: Fresnel off and Ray trace on
7: Transparency: Refraction on, Reflection: Fresnel on and Ray trace on
8: Reflection on and Ray trace off

9: Transparency: Glass on, Reflection: Ray trace off
10: Casts shadows onto invisible surfaces

(List extracted from Wikipedia)

__**Short description of error**__ When using transparency settings, the OBJ exporter still uses only the values 0,1 and 2 for the illum parameter. This may confuse other programs that rely on the correctness of this parameter. __**Exact steps for others to reproduce the error**__ Create any kind of model and attach a material to it. Make sure to use transparency and export the object as Wavefront obj file (make sure to check "Write Materials"). Open the MTL file and verify the illum parameter. __**Idea of a fix**__ Change the respective lines in scripts/addons/io_scene_obj/export.py: ``` # 0 to disable lighting, 1 for ambient & diffuse only (specular color set to black), 2 for full lighting, 4 and 9 for transparency if mat.use_shadeless: fw('illum 0\n') # ignore lighting elif mat.specular_intensity == 0: fw('illum 1\n') # no specular. elif mat.use_transparency: if mat.transparency_method == 'RAYTRACE': fw('illum 4\n') # transparency with raytrace else: fw('illum 9\n') # transparency without raytrace else: fw('illum 2\n') # light normaly ``` __**Important note**__ This does only cover transparency now, because I don't know blender good enough to provide a *full* fix. Someone with more knowledge might want to cover all illum modes: Plain: already covert *Italics*: covered by my "fix" **Bold**: not covered yet 0: Color on and Ambient off 1: Color on and Ambient on 2: Highlight on **3: Reflection on and Ray trace on** *4: Transparency: Glass on, Reflection: Ray trace on* **5: Reflection: Fresnel on and Ray trace on 6: Transparency: Refraction on, Reflection: Fresnel off and Ray trace on 7: Transparency: Refraction on, Reflection: Fresnel on and Ray trace on 8: Reflection on and Ray trace off** *9: Transparency: Glass on, Reflection: Ray trace off* **10: Casts shadows onto invisible surfaces** (List extracted from Wikipedia)
Author

Changed status to: 'Open'

Changed status to: 'Open'
Author

Added subscriber: @iUniversEi

Added subscriber: @iUniversEi
Bastien Montagne self-assigned this 2015-01-30 15:41:02 +01:00

Will have a look at that… More a TODO than a bug though (and we should support that in importer as well).

Will have a look at that… More a TODO than a bug though (and we should support that in importer as well).

This issue was referenced by bd9fa80543

This issue was referenced by bd9fa8054318f513500bc93316b64421b0f0d3fc

Changed status from 'Open' to: 'Resolved'

Changed status from 'Open' to: 'Resolved'

Closed by commit bd9fa80543.

Closed by commit bd9fa80543.
Sign in to join this conversation.
No Milestone
No project
No Assignees
3 Participants
Notifications
Due Date
The due date is invalid or out of range. Please use the format 'yyyy-mm-dd'.

No due date set.

Dependencies

No dependencies set.

Reference: blender/blender-addons#43487
No description provided.