Obj loading/saving brightness inconsistency #45316

Closed
opened 2015-07-05 05:40:50 +02:00 by ProPuke · 6 comments

System Information
Elementary OS Luna, Nvidia GTX 560Ti

Blender Version
Broken: 2.75

Short description of error
Loading and then resaving an obj file results in darker material ambient, diffuse and specular values.
Upon load the obj .mtl Ka and Kd values are loaded directly in as the material mirror_color (ambient) and diffuse_color.
However when saved they are also multiplied by world.ambient_color and diffuse_intensity.
The diffuse intensity is left at the default of 0.8, resulting in values loading and then saving as slightly darker each time, and world.ambient is (0,0,0) by default, removing any ambient color.
It seems that diffuse_intensity should probably be set to 1.0 on load, so the Kd value is properly honoured, and loading/saving is consistent. world.ambient_color is trickier. It could be ignored when saving to avoid this inconsistency, but it's unclear if this is the best course of action.

Lastly the specular hardness values are not honoured between load and save. There appears to be a typo loading the values. They are loaded as specular_hardness = int(value * 0.51), but saved as (specular_hardness - 1) * 1.9607843137254901. Resulting in their values decreasing slightly on save. It seems load should probably read specular_hardness = int(value * 0.51) + 1 but the +1 was missed out by mistake.

Exact steps for others to reproduce the error
Load an .obj model with ambient, diffuse material colours and/or specular hardness values
Re-save the model
All Kd values in the obj .mtl file will now be darker, all Ka values will be 0.0 0.0 0.0, and all Ns values will be lower.

**System Information** Elementary OS Luna, Nvidia GTX 560Ti **Blender Version** Broken: 2.75 **Short description of error** Loading and then resaving an obj file results in darker material ambient, diffuse and specular values. Upon load the obj .mtl Ka and Kd values are loaded directly in as the material `mirror_color` (ambient) and `diffuse_color`. However when saved they are also multiplied by `world.ambient_color` and `diffuse_intensity`. The diffuse intensity is left at the default of 0.8, resulting in values loading and then saving as slightly darker each time, and world.ambient is (0,0,0) by default, removing any ambient color. It seems that `diffuse_intensity` should probably be set to 1.0 on load, so the Kd value is properly honoured, and loading/saving is consistent. `world.ambient_color` is trickier. It could be ignored when saving to avoid this inconsistency, but it's unclear if this is the best course of action. Lastly the specular hardness values are not honoured between load and save. There appears to be a typo loading the values. They are loaded as `specular_hardness = int(value * 0.51)`, but saved as `(specular_hardness - 1) * 1.9607843137254901`. Resulting in their values decreasing slightly on save. It seems load should probably read `specular_hardness = int(value * 0.51) + 1` but the +1 was missed out by mistake. **Exact steps for others to reproduce the error** Load an .obj model with ambient, diffuse material colours and/or specular hardness values Re-save the model All `Kd` values in the obj .mtl file will now be darker, all `Ka` values will be 0.0 0.0 0.0, and all `Ns` values will be lower.
Author

Changed status to: 'Open'

Changed status to: 'Open'
Author

Added subscriber: @ProPuke

Added subscriber: @ProPuke
Bastien Montagne self-assigned this 2015-07-05 09:38:43 +02:00

Added subscriber: @mont29

Added subscriber: @mont29

This issue was referenced by 3430fbc701

This issue was referenced by 3430fbc7013d037e153160d5de9bfbd887cecb4f

Changed status from 'Open' to: 'Resolved'

Changed status from 'Open' to: 'Resolved'

Thanks for finding those and your suggested fixes, all sounds reasonable, committed them. :)

Thanks for finding those and your suggested fixes, all sounds reasonable, committed them. :)
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#45316
No description provided.