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
e3b63b9a
Commit
e3b63b9a
authored
6 years ago
by
Kalle-Samuli Riihikoski
Browse files
Options
Downloads
Patches
Plain Diff
supports UVTiling texture workflow
parent
a0044523
No related branches found
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
io_coat3D/__init__.py
+37
-3
37 additions, 3 deletions
io_coat3D/__init__.py
io_coat3D/tex.py
+248
-213
248 additions, 213 deletions
io_coat3D/tex.py
with
285 additions
and
216 deletions
io_coat3D/__init__.py
+
37
−
3
View file @
e3b63b9a
...
...
@@ -439,10 +439,35 @@ class SCENE_OT_export(bpy.types.Operator):
objekti
.
name
=
name_boxs
[
0
]
objekti
.
data
.
name
=
name_boxs
[
0
]
objekti
.
coat3D
.
applink_name
=
objekti
.
data
.
name
mod_mat_list
=
{}
for
objekti
in
bpy
.
context
.
selected_objects
:
mod_mat_list
[
objekti
.
name
]
=
[]
objekti
.
coat3D
.
applink_scale
=
objekti
.
scale
'''
Checks what materials are linked into UV
'''
if
(
coat3D
.
type
==
'
ppp
'
):
final_material_indexs
=
[]
uvtiles_index
=
[]
for
poly
in
objekti
.
data
.
polygons
:
if
(
poly
.
material_index
not
in
final_material_indexs
):
final_material_indexs
.
append
(
poly
.
material_index
)
loop_index
=
poly
.
loop_indices
[
0
]
uvtiles_index
.
append
([
poly
.
material_index
,
objekti
.
data
.
uv_layers
.
active
.
data
[
loop_index
].
uv
[
0
]])
if
(
len
(
final_material_indexs
)
==
len
(
objekti
.
material_slots
)):
break
print
(
final_material_indexs
)
material_index
=
0
if
(
len
(
final_material_indexs
)
!=
len
(
objekti
.
material_slots
)):
for
material
in
objekti
.
material_slots
:
if
material_index
not
in
final_material_indexs
:
temp_mat
=
material
.
material
material
.
material
=
objekti
.
material_slots
[
0
].
material
mod_mat_list
[
objekti
.
name
].
append
([
material_index
,
temp_mat
])
material_index
=
material_index
+
1
print
(
'
uvtiles_index
'
,
uvtiles_index
)
bpy
.
ops
.
object
.
origin_set
(
type
=
'
ORIGIN_GEOMETRY
'
)
if
(
len
(
bpy
.
context
.
selected_objects
)
>
1
and
coat3D
.
type
!=
'
vox
'
):
bpy
.
ops
.
object
.
transforms_to_deltas
(
mode
=
'
ROT
'
)
...
...
@@ -467,10 +492,11 @@ class SCENE_OT_export(bpy.types.Operator):
objekti
.
coat3D
.
applink_onlyone
=
True
objekti
.
coat3D
.
type
=
coat3D
.
type
objekti
.
coat3D
.
applink_mesh
=
True
objekti
.
coat3D
.
applink_address
=
coa
.
applink_address
objekti
.
coat3D
.
obj_mat
=
''
objekti
.
coat3D
.
applink_firsttime
=
True
objekti
.
coat3D
.
objecttime
=
str
(
os
.
path
.
getmtime
(
objekti
.
coat3D
.
applink_address
))
if
(
coat3D
.
type
!=
'
autopo
'
):
objekti
.
coat3D
.
applink_address
=
coa
.
applink_address
objekti
.
coat3D
.
objecttime
=
str
(
os
.
path
.
getmtime
(
objekti
.
coat3D
.
applink_address
))
objekti
.
data
.
coat3D
.
name
=
'
3DC
'
if
(
coat3D
.
type
!=
'
vox
'
):
...
...
@@ -481,6 +507,14 @@ class SCENE_OT_export(bpy.types.Operator):
if
(
node
.
name
.
startswith
(
'
3DC_
'
)
==
True
):
material
.
material
.
node_tree
.
nodes
.
remove
(
node
)
print
(
'
halloo
'
,
mod_mat_list
)
for
ind
,
mat_list
in
enumerate
(
mod_mat_list
):
print
(
'
terve
'
,
mat_list
)
if
(
mat_list
==
objekti
.
name
):
for
ind
,
mat
in
enumerate
(
mod_mat_list
[
mat_list
]):
objekti
.
material_slots
[
mod_mat_list
[
mat_list
][
ind
][
0
]].
material
=
mod_mat_list
[
mat_list
][
ind
][
1
]
print
(
'
hipphhhuurrei
'
,
mod_mat_list
[
mat_list
][
ind
][
0
],
mod_mat_list
[
mat_list
][
ind
][
1
])
return
{
'
FINISHED
'
}
class
SCENE_OT_import
(
bpy
.
types
.
Operator
):
...
...
This diff is collapsed.
Click to expand it.
io_coat3D/tex.py
+
248
−
213
View file @
e3b63b9a
...
...
@@ -42,9 +42,43 @@ def RemoveFbxNodes(objekti):
Node_Tree
.
links
.
new
(
Prin_mat
.
outputs
[
0
],
output
.
inputs
[
0
])
def
UVTiling
(
objekti
,
texturelist
):
"""
Checks what materials are linked into UV
"""
objekti
.
coat3D
.
applink_scale
=
objekti
.
scale
final_material_indexs
=
[]
uvtiles_index
=
[]
for
poly
in
objekti
.
data
.
polygons
:
if
(
poly
.
material_index
not
in
final_material_indexs
):
final_material_indexs
.
append
(
poly
.
material_index
)
loop_index
=
poly
.
loop_indices
[
0
]
uvtiles_index
.
append
([
poly
.
material_index
,
objekti
.
data
.
uv_layers
.
active
.
data
[
loop_index
].
uv
[
0
]])
if
(
len
(
final_material_indexs
)
==
len
(
objekti
.
material_slots
)):
break
print
(
final_material_indexs
)
for
texture_info
in
texturelist
:
name
=
texture_info
[
0
]
final_name
=
name
[
1
:]
tiling_number
=
int
(
final_name
)
for
list_tiles
in
uvtiles_index
:
if
(
list_tiles
[
1
]
>=
(
tiling_number
-
1
)
and
list_tiles
[
1
]
<=
tiling_number
):
texture_info
[
0
]
=
objekti
.
material_slots
[
list_tiles
[
0
]].
material
.
name
print
(
'
uvtiles_index
'
,
uvtiles_index
)
return
texturelist
def
readtexturefolder
(
objekti
,
mat_list
,
texturelist
,
is_new
):
#read textures from texture file
create_nodes
=
False
if
texturelist
[
0
][
0
]
==
'
1001
'
:
print
(
'
This is UVTiling
'
)
texturelist
=
UVTiling
(
objekti
,
texturelist
)
print
(
'
texturelist:
'
,
texturelist
)
for
index_mat
in
objekti
.
material_slots
:
texcoat
=
{}
...
...
@@ -58,7 +92,7 @@ def readtexturefolder(objekti, mat_list, texturelist, is_new): #read textures fr
texcoat
[
'
emissive_power
'
]
=
[]
texcoat
[
'
displacement
'
]
=
[]
create_group_node
=
False
for
texture_info
in
texturelist
:
if
texture_info
[
0
]
==
index_mat
.
name
:
if
texture_info
[
2
]
==
'
color
'
or
texture_info
[
2
]
==
'
diffuse
'
:
...
...
@@ -70,7 +104,7 @@ def readtexturefolder(objekti, mat_list, texturelist, is_new): #read textures fr
if
texture_info
[
2
]
==
'
rough
'
or
texture_info
[
2
]
==
'
roughness
'
:
texcoat
[
'
rough
'
].
append
(
texture_info
[
3
])
create_nodes
=
True
if
texture_info
[
2
]
==
'
nmap
'
or
texture_info
[
2
]
==
'
normalmap
'
or
texture_info
[
2
]
==
'
normal_map
'
:
if
texture_info
[
2
]
==
'
nmap
'
or
texture_info
[
2
]
==
'
normalmap
'
or
texture_info
[
2
]
==
'
normal_map
'
or
texture_info
[
2
]
==
'
normal
'
:
texcoat
[
'
nmap
'
].
append
(
texture_info
[
3
])
create_nodes
=
True
if
texture_info
[
2
]
==
'
emissive
'
:
...
...
@@ -85,6 +119,7 @@ def readtexturefolder(objekti, mat_list, texturelist, is_new): #read textures fr
if
texture_info
[
2
].
startswith
(
'
displacement
'
):
texcoat
[
'
displacement
'
].
append
(
texture_info
[
3
])
create_nodes
=
True
create_group_node
=
True
if
(
create_nodes
):
coat3D
=
bpy
.
context
.
scene
.
coat3D
path3b_n
=
coat3D
.
exchangedir
...
...
@@ -96,7 +131,7 @@ def readtexturefolder(objekti, mat_list, texturelist, is_new): #read textures fr
objekti
.
coat3D
.
applink_3b_path
=
line
export_file
.
close
()
coat3D
.
remove_path
=
True
createnodes
(
index_mat
,
texcoat
)
createnodes
(
index_mat
,
texcoat
,
create_group_node
)
def
checkmaterial
(
mat_list
,
objekti
):
#check how many materials object has
mat_list
=
[]
...
...
@@ -105,7 +140,7 @@ def checkmaterial(mat_list, objekti): #check how many materials object has
if
(
obj_mate
.
material
.
use_nodes
==
False
):
obj_mate
.
material
.
use_nodes
=
True
def
createnodes
(
active_mat
,
texcoat
):
# Cretes new nodes and link textures into them
def
createnodes
(
active_mat
,
texcoat
,
create_group_node
):
# Cretes new nodes and link textures into them
bring_color
=
True
# Meaning of these is to check if we can only update textures or do we need to create new nodes
bring_metalness
=
True
bring_roughness
=
True
...
...
@@ -159,228 +194,228 @@ def createnodes(active_mat,texcoat): # Cretes new nodes and link textures into t
node
.
image
.
reload
()
#seuraavaksi lahdemme rakentamaan node tree. Lahdetaan Material Outputista rakentaa
if
(
applink_group_node
==
False
and
coat3D
.
creategroup
):
group_tree
=
bpy
.
data
.
node_groups
.
new
(
type
=
"
ShaderNodeTree
"
,
name
=
"
3DC_Applink
"
)
group_tree
.
outputs
.
new
(
"
NodeSocketColor
"
,
"
Color
"
)
group_tree
.
outputs
.
new
(
"
NodeSocketColor
"
,
"
Metallic
"
)
group_tree
.
outputs
.
new
(
"
NodeSocketColor
"
,
"
Roughness
"
)
group_tree
.
outputs
.
new
(
"
NodeSocketVector
"
,
"
Normal map
"
)
group_tree
.
outputs
.
new
(
"
NodeSocketColor
"
,
"
Displacement
"
)
group_tree
.
outputs
.
new
(
"
NodeSocketColor
"
,
"
Emissive
"
)
group_tree
.
outputs
.
new
(
"
NodeSocketColor
"
,
"
Emissive Power
"
)
group_tree
.
outputs
.
new
(
"
NodeSocketColor
"
,
"
AO
"
)
applink_tree
=
act_material
.
nodes
.
new
(
'
ShaderNodeGroup
'
)
applink_tree
.
name
=
'
3DC_Applink
'
applink_tree
.
node_tree
=
group_tree
applink_tree
.
location
=
-
400
,
300
act_material
=
group_tree
notegroup
=
act_material
.
nodes
.
new
(
'
NodeGroupOutput
'
)
notegroup
.
location
=
220
,
-
260
else
:
index
=
0
for
node
in
coatMat
.
node_tree
.
nodes
:
if
(
node
.
type
==
'
GROUP
'
and
node
.
name
==
'
3DC_Applink
'
):
for
in_node
in
node
.
node_tree
.
nodes
:
if
(
in_node
.
type
==
'
GROUP_OUTPUT
'
):
notegroup
=
in_node
index
=
1
break
if
(
index
==
1
):
break
if
(
out_mat
.
inputs
[
'
Surface
'
].
is_linked
==
True
):
main_mat
=
out_mat
.
inputs
[
'
Surface
'
].
links
[
0
].
from_node
if
(
main_mat
.
inputs
.
find
(
'
Base Color
'
)
==
-
1
):
input_color
=
main_mat
.
inputs
.
find
(
'
Color
'
)
if
(
create_group_node
):
if
(
applink_group_node
==
False
and
coat3D
.
creategroup
):
group_tree
=
bpy
.
data
.
node_groups
.
new
(
type
=
"
ShaderNodeTree
"
,
name
=
"
3DC_Applink
"
)
group_tree
.
outputs
.
new
(
"
NodeSocketColor
"
,
"
Color
"
)
group_tree
.
outputs
.
new
(
"
NodeSocketColor
"
,
"
Metallic
"
)
group_tree
.
outputs
.
new
(
"
NodeSocketColor
"
,
"
Roughness
"
)
group_tree
.
outputs
.
new
(
"
NodeSocketVector
"
,
"
Normal map
"
)
group_tree
.
outputs
.
new
(
"
NodeSocketColor
"
,
"
Displacement
"
)
group_tree
.
outputs
.
new
(
"
NodeSocketColor
"
,
"
Emissive
"
)
group_tree
.
outputs
.
new
(
"
NodeSocketColor
"
,
"
Emissive Power
"
)
group_tree
.
outputs
.
new
(
"
NodeSocketColor
"
,
"
AO
"
)
applink_tree
=
act_material
.
nodes
.
new
(
'
ShaderNodeGroup
'
)
applink_tree
.
name
=
'
3DC_Applink
'
applink_tree
.
node_tree
=
group_tree
applink_tree
.
location
=
-
400
,
300
act_material
=
group_tree
notegroup
=
act_material
.
nodes
.
new
(
'
NodeGroupOutput
'
)
notegroup
.
location
=
220
,
-
260
else
:
input_color
=
main_mat
.
inputs
.
find
(
'
Base Color
'
)
'''
COLOR
'''
if
(
bring_color
==
True
and
texcoat
[
'
color
'
]
!=
[]):
print
(
'
Color:
'
,
texcoat
[
'
color
'
][
0
])
node
=
act_material
.
nodes
.
new
(
'
ShaderNodeTexImage
'
)
node
.
name
=
'
3DC_color
'
node
.
label
=
'
Color
'
if
(
texcoat
[
'
color
'
]):
node
.
image
=
bpy
.
data
.
images
.
load
(
texcoat
[
'
color
'
][
0
])
if
(
coat3D
.
createnodes
):
curvenode
=
act_material
.
nodes
.
new
(
'
ShaderNodeRGBCurve
'
)
curvenode
.
name
=
'
3DC_RGBCurve
'
huenode
=
act_material
.
nodes
.
new
(
'
ShaderNodeHueSaturation
'
)
huenode
.
name
=
'
3DC_HueSaturation
'
act_material
.
links
.
new
(
curvenode
.
outputs
[
0
],
huenode
.
inputs
[
4
])
act_material
.
links
.
new
(
node
.
outputs
[
0
],
curvenode
.
inputs
[
1
])
if
(
coat3D
.
creategroup
):
act_material
.
links
.
new
(
huenode
.
outputs
[
0
],
notegroup
.
inputs
[
0
])
if
(
main_mat
.
type
!=
'
MIX_SHADER
'
):
main_material
.
links
.
new
(
applink_tree
.
outputs
[
0
],
main_mat
.
inputs
[
input_color
])
else
:
location
=
main_mat
.
location
applink_tree
.
location
=
main_mat
.
location
[
0
],
main_mat
.
location
[
1
]
+
200
else
:
act_material
.
links
.
new
(
huenode
.
outputs
[
0
],
main_mat
.
inputs
[
input_color
])
node
.
location
=
-
990
,
530
curvenode
.
location
=
-
660
,
480
huenode
.
location
=
-
337
,
335
index
=
0
for
node
in
coatMat
.
node_tree
.
nodes
:
if
(
node
.
type
==
'
GROUP
'
and
node
.
name
==
'
3DC_Applink
'
):
for
in_node
in
node
.
node_tree
.
nodes
:
if
(
in_node
.
type
==
'
GROUP_OUTPUT
'
):
notegroup
=
in_node
index
=
1
break
if
(
index
==
1
):
break
if
(
out_mat
.
inputs
[
'
Surface
'
].
is_linked
==
True
):
main_mat
=
out_mat
.
inputs
[
'
Surface
'
].
links
[
0
].
from_node
if
(
main_mat
.
inputs
.
find
(
'
Base Color
'
)
==
-
1
):
input_color
=
main_mat
.
inputs
.
find
(
'
Color
'
)
else
:
if
(
coat3D
.
creategroup
):
node
.
location
=
-
400
,
400
act_material
.
links
.
new
(
node
.
outputs
[
0
],
notegroup
.
inputs
[
len
(
notegroup
.
inputs
)
-
1
])
if
(
input_color
!=
-
1
):
main_material
.
links
.
new
(
applink_tree
.
outputs
[
len
(
applink_tree
.
outputs
)
-
1
],
main_mat
.
inputs
[
input_color
])
else
:
node
.
location
=
-
400
,
400
if
(
input_color
!=
-
1
):
act_material
.
links
.
new
(
node
.
outputs
[
0
],
main_mat
.
inputs
[
input_color
])
'''
METALNESS
'''
if
(
bring_metalness
==
True
and
texcoat
[
'
metalness
'
]
!=
[]):
node
=
act_material
.
nodes
.
new
(
'
ShaderNodeTexImage
'
)
node
.
name
=
'
3DC_metalness
'
node
.
label
=
'
Metalness
'
input_color
=
main_mat
.
inputs
.
find
(
'
Metallic
'
)
if
(
texcoat
[
'
metalness
'
]):
node
.
image
=
bpy
.
data
.
images
.
load
(
texcoat
[
'
metalness
'
][
0
])
node
.
color_space
=
'
NONE
'
if
(
coat3D
.
createnodes
):
curvenode
=
act_material
.
nodes
.
new
(
'
ShaderNodeRGBCurve
'
)
curvenode
.
name
=
'
3DC_RGBCurve
'
huenode
=
act_material
.
nodes
.
new
(
'
ShaderNodeHueSaturation
'
)
huenode
.
name
=
'
3DC_HueSaturation
'
act_material
.
links
.
new
(
curvenode
.
outputs
[
0
],
huenode
.
inputs
[
4
])
act_material
.
links
.
new
(
node
.
outputs
[
0
],
curvenode
.
inputs
[
1
])
if
(
coat3D
.
creategroup
):
act_material
.
links
.
new
(
huenode
.
outputs
[
0
],
notegroup
.
inputs
[
1
])
if
(
main_mat
.
type
==
'
BSDF_PRINCIPLED
'
):
main_material
.
links
.
new
(
applink_tree
.
outputs
[
1
],
main_mat
.
inputs
[
input_color
])
input_color
=
main_mat
.
inputs
.
find
(
'
Base Color
'
)
'''
COLOR
'''
if
(
bring_color
==
True
and
texcoat
[
'
color
'
]
!=
[]):
print
(
'
Color:
'
,
texcoat
[
'
color
'
][
0
])
node
=
act_material
.
nodes
.
new
(
'
ShaderNodeTexImage
'
)
node
.
name
=
'
3DC_color
'
node
.
label
=
'
Color
'
if
(
texcoat
[
'
color
'
]):
node
.
image
=
bpy
.
data
.
images
.
load
(
texcoat
[
'
color
'
][
0
])
if
(
coat3D
.
createnodes
):
curvenode
=
act_material
.
nodes
.
new
(
'
ShaderNodeRGBCurve
'
)
curvenode
.
name
=
'
3DC_RGBCurve
'
huenode
=
act_material
.
nodes
.
new
(
'
ShaderNodeHueSaturation
'
)
huenode
.
name
=
'
3DC_HueSaturation
'
act_material
.
links
.
new
(
curvenode
.
outputs
[
0
],
huenode
.
inputs
[
4
])
act_material
.
links
.
new
(
node
.
outputs
[
0
],
curvenode
.
inputs
[
1
])
if
(
coat3D
.
creategroup
):
act_material
.
links
.
new
(
huenode
.
outputs
[
0
],
notegroup
.
inputs
[
0
])
if
(
main_mat
.
type
!=
'
MIX_SHADER
'
):
main_material
.
links
.
new
(
applink_tree
.
outputs
[
0
],
main_mat
.
inputs
[
input_color
])
else
:
location
=
main_mat
.
location
applink_tree
.
location
=
main_mat
.
location
[
0
],
main_mat
.
location
[
1
]
+
200
else
:
act_material
.
links
.
new
(
huenode
.
outputs
[
0
],
main_mat
.
inputs
[
input_color
])
node
.
location
=
-
990
,
530
curvenode
.
location
=
-
660
,
480
huenode
.
location
=
-
337
,
335
else
:
act_material
.
links
.
new
(
huenode
.
outputs
[
0
],
main_mat
.
inputs
[
input_color
])
if
(
coat3D
.
creategroup
):
node
.
location
=
-
400
,
400
act_material
.
links
.
new
(
node
.
outputs
[
0
],
notegroup
.
inputs
[
len
(
notegroup
.
inputs
)
-
1
])
if
(
input_color
!=
-
1
):
main_material
.
links
.
new
(
applink_tree
.
outputs
[
len
(
applink_tree
.
outputs
)
-
1
],
main_mat
.
inputs
[
input_color
])
node
.
location
=
-
994
,
119
curvenode
.
location
=
-
668
,
113
huenode
.
location
=
-
345
,
118
else
:
node
.
location
=
-
400
,
400
if
(
input_color
!=
-
1
):
act_material
.
links
.
new
(
node
.
outputs
[
0
],
main_mat
.
inputs
[
input_color
])
'''
METALNESS
'''
if
(
bring_metalness
==
True
and
texcoat
[
'
metalness
'
]
!=
[]):
node
=
act_material
.
nodes
.
new
(
'
ShaderNodeTexImage
'
)
node
.
name
=
'
3DC_metalness
'
node
.
label
=
'
Metalness
'
input_color
=
main_mat
.
inputs
.
find
(
'
Metallic
'
)
if
(
texcoat
[
'
metalness
'
]):
node
.
image
=
bpy
.
data
.
images
.
load
(
texcoat
[
'
metalness
'
][
0
])
node
.
color_space
=
'
NONE
'
if
(
coat3D
.
createnodes
):
curvenode
=
act_material
.
nodes
.
new
(
'
ShaderNodeRGBCurve
'
)
curvenode
.
name
=
'
3DC_RGBCurve
'
huenode
=
act_material
.
nodes
.
new
(
'
ShaderNodeHueSaturation
'
)
huenode
.
name
=
'
3DC_HueSaturation
'
act_material
.
links
.
new
(
curvenode
.
outputs
[
0
],
huenode
.
inputs
[
4
])
act_material
.
links
.
new
(
node
.
outputs
[
0
],
curvenode
.
inputs
[
1
])
if
(
coat3D
.
creategroup
):
act_material
.
links
.
new
(
huenode
.
outputs
[
0
],
notegroup
.
inputs
[
1
])
if
(
main_mat
.
type
==
'
BSDF_PRINCIPLED
'
):
main_material
.
links
.
new
(
applink_tree
.
outputs
[
1
],
main_mat
.
inputs
[
input_color
])
else
:
act_material
.
links
.
new
(
huenode
.
outputs
[
0
],
main_mat
.
inputs
[
input_color
])
else
:
if
(
coat3D
.
creategroup
):
node
.
location
=
-
830
,
160
act_material
.
links
.
new
(
node
.
outputs
[
0
],
notegroup
.
inputs
[
len
(
notegroup
.
inputs
)
-
1
])
if
(
input_color
!=
-
1
):
main_material
.
links
.
new
(
applink_tree
.
outputs
[
len
(
applink_tree
.
outputs
)
-
1
],
main_mat
.
inputs
[
input_color
])
else
:
node
.
location
=
-
830
,
160
if
(
input_color
!=
-
1
):
act_material
.
links
.
new
(
node
.
outputs
[
0
],
main_mat
.
inputs
[
input_color
])
'''
ROUGHNESS
'''
if
(
bring_roughness
==
True
and
texcoat
[
'
rough
'
]
!=
[]):
node
=
act_material
.
nodes
.
new
(
'
ShaderNodeTexImage
'
)
node
.
name
=
'
3DC_roughness
'
node
.
label
=
'
Roughness
'
input_color
=
main_mat
.
inputs
.
find
(
'
Roughness
'
)
if
(
texcoat
[
'
rough
'
]):
node
.
image
=
bpy
.
data
.
images
.
load
(
texcoat
[
'
rough
'
][
0
])
node
.
color_space
=
'
NONE
'
if
(
coat3D
.
createnodes
):
curvenode
=
act_material
.
nodes
.
new
(
'
ShaderNodeRGBCurve
'
)
curvenode
.
name
=
'
3DC_RGBCurve
'
huenode
=
act_material
.
nodes
.
new
(
'
ShaderNodeHueSaturation
'
)
huenode
.
name
=
'
3DC_HueSaturation
'
act_material
.
links
.
new
(
curvenode
.
outputs
[
0
],
huenode
.
inputs
[
4
])
act_material
.
links
.
new
(
node
.
outputs
[
0
],
curvenode
.
inputs
[
1
])
node
.
location
=
-
994
,
119
curvenode
.
location
=
-
668
,
113
huenode
.
location
=
-
345
,
118
if
(
coat3D
.
creategroup
):
act_material
.
links
.
new
(
huenode
.
outputs
[
0
],
notegroup
.
inputs
[
2
])
if
(
main_mat
.
type
==
'
BSDF_PRINCIPLED
'
):
main_material
.
links
.
new
(
applink_tree
.
outputs
[
2
],
main_mat
.
inputs
[
input_color
])
else
:
act_material
.
links
.
new
(
huenode
.
outputs
[
0
],
main_mat
.
inputs
[
input_color
])
if
(
coat3D
.
creategroup
):
node
.
location
=
-
830
,
160
act_material
.
links
.
new
(
node
.
outputs
[
0
],
notegroup
.
inputs
[
len
(
notegroup
.
inputs
)
-
1
])
if
(
input_color
!=
-
1
):
main_material
.
links
.
new
(
applink_tree
.
outputs
[
len
(
applink_tree
.
outputs
)
-
1
],
main_mat
.
inputs
[
input_color
])
else
:
node
.
location
=
-
830
,
160
if
(
input_color
!=
-
1
):
act_material
.
links
.
new
(
node
.
outputs
[
0
],
main_mat
.
inputs
[
input_color
])
'''
ROUGHNESS
'''
if
(
bring_roughness
==
True
and
texcoat
[
'
rough
'
]
!=
[]):
node
=
act_material
.
nodes
.
new
(
'
ShaderNodeTexImage
'
)
node
.
name
=
'
3DC_roughness
'
node
.
label
=
'
Roughness
'
input_color
=
main_mat
.
inputs
.
find
(
'
Roughness
'
)
if
(
texcoat
[
'
rough
'
]):
node
.
image
=
bpy
.
data
.
images
.
load
(
texcoat
[
'
rough
'
][
0
])
node
.
color_space
=
'
NONE
'
if
(
coat3D
.
createnodes
):
curvenode
=
act_material
.
nodes
.
new
(
'
ShaderNodeRGBCurve
'
)
curvenode
.
name
=
'
3DC_RGBCurve
'
huenode
=
act_material
.
nodes
.
new
(
'
ShaderNodeHueSaturation
'
)
huenode
.
name
=
'
3DC_HueSaturation
'
act_material
.
links
.
new
(
curvenode
.
outputs
[
0
],
huenode
.
inputs
[
4
])
act_material
.
links
.
new
(
node
.
outputs
[
0
],
curvenode
.
inputs
[
1
])
if
(
coat3D
.
creategroup
):
act_material
.
links
.
new
(
huenode
.
outputs
[
0
],
notegroup
.
inputs
[
2
])
if
(
main_mat
.
type
==
'
BSDF_PRINCIPLED
'
):
main_material
.
links
.
new
(
applink_tree
.
outputs
[
2
],
main_mat
.
inputs
[
input_color
])
else
:
act_material
.
links
.
new
(
huenode
.
outputs
[
0
],
main_mat
.
inputs
[
input_color
])
node
.
location
=
-
1000
,
-
276
curvenode
.
location
=
-
670
,
-
245
huenode
.
location
=
-
340
,
-
100
else
:
if
(
coat3D
.
creategroup
):
node
.
location
=
-
550
,
0
act_material
.
links
.
new
(
node
.
outputs
[
0
],
notegroup
.
inputs
[
len
(
notegroup
.
inputs
)
-
1
])
if
(
input_color
!=
-
1
):
main_material
.
links
.
new
(
applink_tree
.
outputs
[
len
(
applink_tree
.
outputs
)
-
1
],
main_mat
.
inputs
[
input_color
])
node
.
location
=
-
1000
,
-
276
curvenode
.
location
=
-
670
,
-
245
huenode
.
location
=
-
340
,
-
100
else
:
node
.
location
=
-
550
,
0
if
(
input_color
!=
-
1
):
act_material
.
links
.
new
(
node
.
outputs
[
0
],
main_mat
.
inputs
[
input_color
])
'''
NORMAL MAP
'''
if
(
bring_normal
==
True
and
texcoat
[
'
nmap
'
]
!=
[]):
node
=
act_material
.
nodes
.
new
(
'
ShaderNodeTexImage
'
)
normal_node
=
act_material
.
nodes
.
new
(
'
ShaderNodeNormalMap
'
)
node
.
location
=
-
600
,
-
670
normal_node
.
location
=
-
300
,
-
300
node
.
name
=
'
3DC_normal
'
node
.
label
=
'
Normal Map
'
normal_node
.
name
=
'
3DC_normalnode
'
if
(
texcoat
[
'
nmap
'
]):
node
.
image
=
bpy
.
data
.
images
.
load
(
texcoat
[
'
nmap
'
][
0
])
node
.
color_space
=
'
NONE
'
input_color
=
main_mat
.
inputs
.
find
(
'
Normal
'
)
act_material
.
links
.
new
(
node
.
outputs
[
0
],
normal_node
.
inputs
[
1
])
act_material
.
links
.
new
(
normal_node
.
outputs
[
0
],
main_mat
.
inputs
[
input_color
])
if
(
coat3D
.
creategroup
):
act_material
.
links
.
new
(
normal_node
.
outputs
[
0
],
notegroup
.
inputs
[
3
])
if
(
main_mat
.
inputs
[
input_color
].
name
==
'
Normal
'
):
main_material
.
links
.
new
(
applink_tree
.
outputs
[
3
],
main_mat
.
inputs
[
input_color
])
'''
DISPLACEMENT
'''
if
(
bring_displacement
==
True
and
texcoat
[
'
displacement
'
]
!=
[]):
node
=
act_material
.
nodes
.
new
(
'
ShaderNodeTexImage
'
)
node
.
name
=
'
3DC_displacement
'
node
.
label
=
'
Displacement
'
# input_color = main_mat.inputs.find('Roughness') Blender 2.8 Does not support Displacement yet.
if
(
texcoat
[
'
displacement
'
]):
node
.
image
=
bpy
.
data
.
images
.
load
(
texcoat
[
'
displacement
'
][
0
])
node
.
color_space
=
'
NONE
'
if
(
coat3D
.
createnodes
):
'''
curvenode = act_material.nodes.new(
'
ShaderNodeRGBCurve
'
)
curvenode.name =
'
3DC_RGBCurve
'
huenode = act_material.nodes.new(
'
ShaderNodeHueSaturation
'
)
huenode.name =
'
3DC_HueSaturation
'
act_material.links.new(curvenode.outputs[0], huenode.inputs[4])
act_material.links.new(node.outputs[0], curvenode.inputs[1])
'''
if
(
coat3D
.
creategroup
):
node
.
location
=
-
550
,
0
act_material
.
links
.
new
(
node
.
outputs
[
0
],
notegroup
.
inputs
[
len
(
notegroup
.
inputs
)
-
1
])
if
(
input_color
!=
-
1
):
main_material
.
links
.
new
(
applink_tree
.
outputs
[
len
(
applink_tree
.
outputs
)
-
1
],
main_mat
.
inputs
[
input_color
])
else
:
node
.
location
=
-
550
,
0
if
(
input_color
!=
-
1
):
act_material
.
links
.
new
(
node
.
outputs
[
0
],
main_mat
.
inputs
[
input_color
])
'''
NORMAL MAP
'''
if
(
bring_normal
==
True
and
texcoat
[
'
nmap
'
]
!=
[]):
node
=
act_material
.
nodes
.
new
(
'
ShaderNodeTexImage
'
)
normal_node
=
act_material
.
nodes
.
new
(
'
ShaderNodeNormalMap
'
)
node
.
location
=
-
600
,
-
670
normal_node
.
location
=
-
300
,
-
300
node
.
name
=
'
3DC_normal
'
node
.
label
=
'
Normal Map
'
normal_node
.
name
=
'
3DC_normalnode
'
if
(
texcoat
[
'
nmap
'
]):
node
.
image
=
bpy
.
data
.
images
.
load
(
texcoat
[
'
nmap
'
][
0
])
node
.
color_space
=
'
NONE
'
input_color
=
main_mat
.
inputs
.
find
(
'
Normal
'
)
act_material
.
links
.
new
(
node
.
outputs
[
0
],
normal_node
.
inputs
[
1
])
act_material
.
links
.
new
(
normal_node
.
outputs
[
0
],
main_mat
.
inputs
[
input_color
])
if
(
coat3D
.
creategroup
):
act_material
.
links
.
new
(
node
.
outputs
[
0
],
notegroup
.
inputs
[
4
])
#if (main_mat.type == 'BSDF_PRINCIPLED'):
#main_material.links.new(applink_tree.outputs[2], main_mat.inputs[input_color])
#else:
#act_material.links.new(huenode.outputs[0], main_mat.inputs[input_color])
act_material
.
links
.
new
(
normal_node
.
outputs
[
0
],
notegroup
.
inputs
[
3
])
if
(
main_mat
.
inputs
[
input_color
].
name
==
'
Normal
'
):
main_material
.
links
.
new
(
applink_tree
.
outputs
[
3
],
main_mat
.
inputs
[
input_color
])
'''
DISPLACEMENT
'''
if
(
bring_displacement
==
True
and
texcoat
[
'
displacement
'
]
!=
[]):
node
=
act_material
.
nodes
.
new
(
'
ShaderNodeTexImage
'
)
node
.
name
=
'
3DC_displacement
'
node
.
label
=
'
Displacement
'
# input_color = main_mat.inputs.find('Roughness') Blender 2.8 Does not support Displacement yet.
if
(
texcoat
[
'
displacement
'
]):
node
.
image
=
bpy
.
data
.
images
.
load
(
texcoat
[
'
displacement
'
][
0
])
node
.
color_space
=
'
NONE
'
if
(
coat3D
.
createnodes
):
'''
curvenode = act_material.nodes.new(
'
ShaderNodeRGBCurve
'
)
curvenode.name =
'
3DC_RGBCurve
'
huenode = act_material.nodes.new(
'
ShaderNodeHueSaturation
'
)
huenode.name =
'
3DC_HueSaturation
'
act_material.links.new(curvenode.outputs[0], huenode.inputs[4])
act_material.links.new(node.outputs[0], curvenode.inputs[1])
'''
if
(
coat3D
.
creategroup
):
act_material
.
links
.
new
(
node
.
outputs
[
0
],
notegroup
.
inputs
[
4
])
#if (main_mat.type == 'BSDF_PRINCIPLED'):
#main_material.links.new(applink_tree.outputs[2], main_mat.inputs[input_color])
#else:
#act_material.links.new(huenode.outputs[0], main_mat.inputs[input_color])
node
.
location
=
-
276
,
-
579
node
.
location
=
-
276
,
-
579
else
:
if
(
coat3D
.
creategroup
):
node
.
location
=
-
550
,
0
act_material
.
links
.
new
(
node
.
outputs
[
0
],
notegroup
.
inputs
[
len
(
notegroup
.
inputs
)
-
1
])
else
:
if
(
coat3D
.
creategroup
):
node
.
location
=
-
550
,
0
act_material
.
links
.
new
(
node
.
outputs
[
0
],
notegroup
.
inputs
[
len
(
notegroup
.
inputs
)
-
1
])
...
...
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