Object Importer Error #67889

Closed
opened 2019-07-29 18:22:43 +02:00 by Brad Hawkins · 11 comments

System Information
Operating system: Windows-10-10.0.17134 64 Bits
Graphics card: Intel(R) HD Graphics 620 Intel 4.5.0 - Build 23.20.16.4973

Blender Version
Broken: version: 2.80 (sub 75), branch: master, commit date: 2019-07-24 14:22, hash: blender/blender@507ffee6e1
Worked: (optional)

Short description of error
Certain Obj files will not import and throws an error
Traceback (most recent call last):

File "C:\Users\bh630\Downloads\blender-2.80rc3-windows64\blender-2.80rc3-windows64\2.80\scripts\addons\io_scene_obj\__init__.py", line 145, in execute
  return import_obj.load(context, **keywords)
File "C:\Users\bh630\Downloads\blender-2.80rc3-windows64\blender-2.80rc3-windows64\2.80\scripts\addons\io_scene_obj\import_obj.py", line 1215, in load
  use_image_search, float_func)
File "C:\Users\bh630\Downloads\blender-2.80rc3-windows64\blender-2.80rc3-windows64\2.80\scripts\addons\io_scene_obj\import_obj.py", line 338, in create_materials
  context_mat_wrap.roughness = 1.0 - (sqrt(float_func(line_split[1])) / 30)

ValueError: math domain error

location: :-1

Exact steps for others to reproduce the error
Use Release candidate 3 and just use the Object:
3DS - The Legend of Zelda Ocarina of Time 3D - Gerudo Mask.zip

**System Information** Operating system: Windows-10-10.0.17134 64 Bits Graphics card: Intel(R) HD Graphics 620 Intel 4.5.0 - Build 23.20.16.4973 **Blender Version** Broken: version: 2.80 (sub 75), branch: master, commit date: 2019-07-24 14:22, hash: `blender/blender@507ffee6e1` Worked: (optional) **Short description of error** Certain Obj files will not import and throws an error Traceback (most recent call last): ``` File "C:\Users\bh630\Downloads\blender-2.80rc3-windows64\blender-2.80rc3-windows64\2.80\scripts\addons\io_scene_obj\__init__.py", line 145, in execute return import_obj.load(context, **keywords) File "C:\Users\bh630\Downloads\blender-2.80rc3-windows64\blender-2.80rc3-windows64\2.80\scripts\addons\io_scene_obj\import_obj.py", line 1215, in load use_image_search, float_func) File "C:\Users\bh630\Downloads\blender-2.80rc3-windows64\blender-2.80rc3-windows64\2.80\scripts\addons\io_scene_obj\import_obj.py", line 338, in create_materials context_mat_wrap.roughness = 1.0 - (sqrt(float_func(line_split[1])) / 30) ``` ValueError: math domain error location: <unknown location>:-1 **Exact steps for others to reproduce the error** Use Release candidate 3 and just use the Object: [3DS - The Legend of Zelda Ocarina of Time 3D - Gerudo Mask.zip](https://archive.blender.org/developer/F7635968/3DS_-_The_Legend_of_Zelda_Ocarina_of_Time_3D_-_Gerudo_Mask.zip)
Author

Added subscriber: @ConsUme

Added subscriber: @ConsUme
Member

Added subscriber: @lichtwerk

Added subscriber: @lichtwerk
Member

Confirmed, checking...

Confirmed, checking...
Member

Added subscriber: @mont29

Added subscriber: @mont29
Member

Looks like the material file specifies a negative specular exponent... [this should not be allowed imho]

- Blender MTL File: 'None'
- Material Count: 1

newmtl material-01029822
Ns -3.921569

I guess we should just clamp this to min 0.0, but will check with others...

Also: seeing this has actually been exported from blender: checked, and we actually allow negative specular exponent [if roughness is above 1.0 -- which we seem to allow as well...] to be exported [should not be allowed I guess, see above...]

- XXX Totally empirical conversion, trying to adapt it
- (from 1.0 - 0.0 Principled BSDF range to 0.0 - 900.0 OBJ specular exponent range)...
spec = (1.0 - mat_wrap.roughness) * 30
spec *= spec
fw('Ns %.6f\n' % spec)

Not sure if this could/should be clamped in our material (node) system, or on export, will check with others as well...

CC @mont29

Looks like the material file specifies a negative specular exponent... [this should not be allowed imho] ``` - Blender MTL File: 'None' - Material Count: 1 newmtl material-01029822 Ns -3.921569 ``` I guess we should just clamp this to min 0.0, but will check with others... Also: seeing this has actually been exported from blender: checked, and we actually allow negative specular exponent [if roughness is above 1.0 -- which we seem to allow as well...] to be exported [should not be allowed I guess, see above...] ``` - XXX Totally empirical conversion, trying to adapt it - (from 1.0 - 0.0 Principled BSDF range to 0.0 - 900.0 OBJ specular exponent range)... spec = (1.0 - mat_wrap.roughness) * 30 spec *= spec fw('Ns %.6f\n' % spec) ``` Not sure if this could/should be clamped in our material (node) system, or on export, will check with others as well... CC @mont29

Added subscriber: @dr.sybren

Added subscriber: @dr.sybren

In #67889#739236, @lichtwerk wrote:

spec = (1.0 - mat_wrap.roughness) * 30
spec *= spec
fw('Ns %.6f\n' % spec)

This code can only produce negative specularity if the roughness is a complex number. Squaring the number using spec *= spec makes it absolute, hence nonnegative.

IMO we should handle out-of-range values gracefully, either rejecting the material altogether or clamping the values.

> In #67889#739236, @lichtwerk wrote: > ``` > spec = (1.0 - mat_wrap.roughness) * 30 > spec *= spec > fw('Ns %.6f\n' % spec) > ``` This code can only produce negative specularity if the roughness is a complex number. Squaring the number using `spec *= spec` makes it absolute, hence nonnegative. IMO we should handle out-of-range values gracefully, either rejecting the material altogether or clamping the values.
Member

In #67889#739274, @dr.sybren wrote:

In #67889#739236, @lichtwerk wrote:

spec = (1.0 - mat_wrap.roughness) * 30
spec *= spec
fw('Ns %.6f\n' % spec)

This code can only produce negative specularity if the roughness is a complex number. Squaring the number using spec *= spec makes it absolute, hence nonnegative.

IMO we should handle out-of-range values gracefully, either rejecting the material altogether or clamping the values.

oops, true, wasnt paying attention that it gets squared... I wonder how this got exported from blender then (I mean how it got negative)?

> In #67889#739274, @dr.sybren wrote: >> In #67889#739236, @lichtwerk wrote: >> ``` >> spec = (1.0 - mat_wrap.roughness) * 30 >> spec *= spec >> fw('Ns %.6f\n' % spec) >> ``` > > This code can only produce negative specularity if the roughness is a complex number. Squaring the number using `spec *= spec` makes it absolute, hence nonnegative. > > IMO we should handle out-of-range values gracefully, either rejecting the material altogether or clamping the values. oops, true, wasnt paying attention that it gets squared... I wonder how this got exported from blender then (I mean how it got negative)?
Bastien Montagne self-assigned this 2019-07-30 10:38:58 +02:00

Exported from Blender 2.75.... That's an old geezer, who knows what it was doing at that time? ;)

Seriously, yes, we should clamp those values on import to a valid range, just safer. Probably even in the material wrapper thingy, such that all IO scripts could benefit from it.

Exported from Blender 2.75.... That's an old geezer, who knows what it was doing at that time? ;) Seriously, yes, we should clamp those values on import to a valid range, just safer. Probably even in the material wrapper thingy, such that all IO scripts could benefit from it.

This issue was referenced by 27381001d7

This issue was referenced by 27381001d7b9332eb669f1023f14b40d1f15f962

Changed status from 'Open' to: 'Resolved'

Changed status from 'Open' to: 'Resolved'
Sign in to join this conversation.
No Milestone
No project
No Assignees
5 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#67889
No description provided.