Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
B
blender-addons
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container registry
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
blender
blender-addons
Commits
db2c65d9
Commit
db2c65d9
authored
5 years ago
by
Bastien Montagne
Browse files
Options
Downloads
Patches
Plain Diff
Fix T70666: OBJ IO: Add support for new Emission option of Principled BSDF.
parent
c4f78f14
Branches
Branches containing commit
Tags
Tags containing commit
No related merge requests found
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
io_scene_obj/__init__.py
+1
-1
1 addition, 1 deletion
io_scene_obj/__init__.py
io_scene_obj/export_obj.py
+2
-3
2 additions, 3 deletions
io_scene_obj/export_obj.py
io_scene_obj/import_obj.py
+7
-18
7 additions, 18 deletions
io_scene_obj/import_obj.py
with
10 additions
and
22 deletions
io_scene_obj/__init__.py
+
1
−
1
View file @
db2c65d9
...
...
@@ -21,7 +21,7 @@
bl_info
=
{
"
name
"
:
"
Wavefront OBJ format
"
,
"
author
"
:
"
Campbell Barton, Bastien Montagne
"
,
"
version
"
:
(
3
,
6
,
0
),
"
version
"
:
(
3
,
7
,
0
),
"
blender
"
:
(
2
,
81
,
6
),
"
location
"
:
"
File > Import-Export
"
,
"
description
"
:
"
Import-Export OBJ, Import OBJ mesh, UV
'
s, materials and textures
"
,
...
...
This diff is collapsed.
Click to expand it.
io_scene_obj/export_obj.py
+
2
−
3
View file @
db2c65d9
...
...
@@ -91,8 +91,7 @@ def write_mtl(scene, filepath, path_mode, copy_set, mtl_dict):
# XXX TODO Find a way to handle tint and diffuse color, in a consistent way with import...
fw
(
'
Ks %.6f %.6f %.6f
\n
'
%
(
mat_wrap
.
specular
,
mat_wrap
.
specular
,
mat_wrap
.
specular
))
# Specular
# Emission, not in original MTL standard but seems pretty common, see T45766.
# XXX Not supported by current Principled-based shader.
fw
(
'
Ke 0.0 0.0 0.0
\n
'
)
fw
(
'
Ke %.6f %.6f %.6f
\n
'
%
mat_wrap
.
emission_color
[:
3
])
fw
(
'
Ni %.6f
\n
'
%
mat_wrap
.
ior
)
# Refraction index
fw
(
'
d %.6f
\n
'
%
mat_wrap
.
alpha
)
# Alpha (obj uses 'd' for dissolve)
...
...
@@ -121,7 +120,7 @@ def write_mtl(scene, filepath, path_mode, copy_set, mtl_dict):
"
map_Bump
"
:
"
normalmap_texture
"
,
"
disp
"
:
None
,
# displacement...
"
refl
"
:
"
metallic_texture
"
,
"
map_Ke
"
:
None
# emission...
"
map_Ke
"
:
"
emission_color_texture
"
,
}
for
key
,
mat_wrap_key
in
sorted
(
image_map
.
items
()):
...
...
This diff is collapsed.
Click to expand it.
io_scene_obj/import_obj.py
+
7
−
18
View file @
db2c65d9
...
...
@@ -187,8 +187,7 @@ def create_materials(filepath, relpath,
_generic_tex_set
(
mat_wrap
.
specular_texture
,
image
,
'
UV
'
,
map_offset
,
map_scale
)
elif
type
==
'
Ke
'
:
# XXX Not supported?
print
(
"
WARNING, currently unsupported emit texture, skipped.
"
)
_generic_tex_set
(
mat_wrap
.
emission_color_texture
,
image
,
'
UV
'
,
map_offset
,
map_scale
)
elif
type
==
'
Bump
'
:
bump_mult
=
map_options
.
get
(
b
'
-bm
'
)
...
...
@@ -218,7 +217,7 @@ def create_materials(filepath, relpath,
else
:
raise
Exception
(
"
invalid type %r
"
%
type
)
def
finalize_material
(
context_material
,
context_material_vars
,
spec_colors
,
emit_colors
,
def
finalize_material
(
context_material
,
context_material_vars
,
spec_colors
,
do_highlight
,
do_reflection
,
do_transparency
,
do_glass
):
# Finalize previous mat, if any.
if
context_material
:
...
...
@@ -237,14 +236,6 @@ def create_materials(filepath, relpath,
if
"
roughness
"
not
in
context_material_vars
:
context_mat_wrap
.
roughness
=
0.0
emit_value
=
sum
(
emit_colors
)
/
3.0
if
emit_value
>
1e-6
:
print
(
"
WARNING, emit value unsupported by Principled BSDF shader, skipped.
"
)
# We have to adapt it to diffuse color too...
emit_value
/=
sum
(
tuple
(
context_material
.
diffuse_color
)[:
3
])
/
3.0
# ~ context_material.emit = emit_value
# FIXME, how else to use this?
if
do_highlight
:
if
"
specular
"
not
in
context_material_vars
:
...
...
@@ -303,7 +294,6 @@ def create_materials(filepath, relpath,
do_transparency
=
False
do_glass
=
False
spec_colors
=
[
0.0
,
0.0
,
0.0
]
emit_colors
=
[
0.0
,
0.0
,
0.0
]
# print('\t\tloading mtl: %e' % mtlpath)
context_material
=
None
...
...
@@ -319,7 +309,7 @@ def create_materials(filepath, relpath,
if
line_id
==
b
'
newmtl
'
:
# Finalize previous mat, if any.
finalize_material
(
context_material
,
context_material_vars
,
spec_colors
,
emit_colors
,
finalize_material
(
context_material
,
context_material_vars
,
spec_colors
,
do_highlight
,
do_reflection
,
do_transparency
,
do_glass
)
context_material_name
=
line_value
(
line_split
)
...
...
@@ -328,8 +318,7 @@ def create_materials(filepath, relpath,
context_mat_wrap
=
nodal_material_wrap_map
[
context_material
]
context_material_vars
.
clear
()
spec_colors
=
[
0.0
,
0.0
,
0.0
]
emit_colors
[:]
=
[
0.0
,
0.0
,
0.0
]
spec_colors
[:]
=
[
0.0
,
0.0
,
0.0
]
do_highlight
=
False
do_reflection
=
False
do_transparency
=
False
...
...
@@ -352,8 +341,8 @@ def create_materials(filepath, relpath,
elif
line_id
==
b
'
ke
'
:
# We cannot set context_material.emit right now, we need final diffuse color as well for this.
# XXX Unsupported currently
emit_colors
[:]
=
[
float_func
(
line_split
[
1
]),
float_func
(
line_split
[
2
]),
float_func
(
line_split
[
3
])]
col
=
(
float_func
(
line_split
[
1
]),
float_func
(
line_split
[
2
]),
float_func
(
line_split
[
3
]))
context_mat_wrap
.
emission_color
=
col
elif
line_id
==
b
'
ns
'
:
# XXX Totally empirical conversion, trying to adapt it
# (from 0.0 - 900.0 OBJ specular exponent range to 1.0 - 0.0 Principled BSDF range)...
...
...
@@ -469,7 +458,7 @@ def create_materials(filepath, relpath,
print
(
"
WARNING: %r:%r (ignored)
"
%
(
filepath
,
line
))
# Finalize last mat, if any.
finalize_material
(
context_material
,
context_material_vars
,
spec_colors
,
emit_colors
,
finalize_material
(
context_material
,
context_material_vars
,
spec_colors
,
do_highlight
,
do_reflection
,
do_transparency
,
do_glass
)
mtl
.
close
()
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment