Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

w3d properties internal rename, multiple material per mesh object support, alpha transparency support, empty data object error fix #261

Merged
merged 21 commits into from
Feb 1, 2024
Merged
Changes from 2 commits
Commits
Show all changes
21 commits
Select commit Hold shift + click to select a range
74a27a7
__init__.py: blend_mode fixed to blend_method
rizzntine Nov 25, 2023
71e4308
material_import.py: Alpha Clip blend method for working transparency
rizzntine Dec 3, 2023
c6c7e85
material_import.py: Added support for Multiple Materials per Mesh Object
rizzntine Dec 3, 2023
847c3a2
Update mesh_import.py: Multiple Material per Mesh Object support
rizzntine Dec 3, 2023
3f743b4
material_import.py: alpha clip blend mode for multiple material meshes
rizzntine Dec 3, 2023
20c44e4
Create an empty UV Map on early return
rizzntine Dec 5, 2023
789d785
Merge pull request #1 from OpenSAGE/master
rizzntine Jan 28, 2024
63bada3
material_import.py: Fixed material duplication, node_tree manipulation
rizzntine Jan 28, 2024
d123178
autopep8 action fixes
rizzntine Jan 28, 2024
f53d467
Merge pull request #2 from rizzntine/autopep8-patches
rizzntine Jan 28, 2024
eacbeca
Merge pull request #3 from OpenSAGE/master
rizzntine Jan 29, 2024
778c545
helpers.py : create_uvlayer, check if mesh exists
rizzntine Jan 29, 2024
b9e12eb
Update material_pass.py
rizzntine Jan 30, 2024
e2fb7a1
Update material_pass.py
rizzntine Jan 30, 2024
c50bed3
tests/material_pass.py get_texture_stage() : attempt at per face text…
rizzntine Jan 30, 2024
c2b702d
Update material_pass.py
rizzntine Jan 30, 2024
579b1b2
Update material_import.py
rizzntine Jan 30, 2024
58b0f30
Update material_import.py
rizzntine Jan 30, 2024
90d94bb
Update material_import.py
rizzntine Jan 30, 2024
461f0d9
autopep8 action fixes
rizzntine Jan 30, 2024
70efdd5
Merge pull request #4 from rizzntine/autopep8-patches
rizzntine Jan 30, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 7 additions & 6 deletions io_mesh_w3d/common/utils/material_import.py
Original file line number Diff line number Diff line change
@@ -15,7 +15,8 @@

def create_vertex_material(context, principleds, structure, mesh, b_mesh, name, triangles, mesh_ob):

if len(structure.material_passes) == 1 and len(structure.textures) > 1: # condition for multiple materials per single mesh object
if len(structure.material_passes) == 1 and len(
structure.textures) > 1: # condition for multiple materials per single mesh object
# Create the same amount of materials as textures used for this mesh
source_mat = structure.vert_materials[0]
for texture in structure.textures:
@@ -29,7 +30,7 @@ def create_vertex_material(context, principleds, structure, mesh, b_mesh, name,
# Load textures
for tex_id, texture in enumerate(structure.textures):
texture = structure.textures[tex_id]
tex = find_texture(context, texture.file, texture.id)
tex = find_texture(context, texture.file, texture.id)
node_tree = mesh.materials[tex_id].node_tree
bsdf_node = node_tree.nodes.get('Principled BSDF')
texture_node = node_tree.nodes.new('ShaderNodeTexImage')
@@ -40,12 +41,12 @@ def create_vertex_material(context, principleds, structure, mesh, b_mesh, name,
links.new(texture_node.outputs['Alpha'], bsdf_node.inputs['Alpha'])

# Assign material to appropriate object faces
bpy.ops.object.mode_set(mode = 'EDIT')
bpy.ops.object.mode_set(mode='EDIT')
bm = bmesh.from_edit_mesh(mesh_ob.data)
bm.faces.ensure_lookup_table()
for i, face in enumerate(bm.faces):
bm.faces[i].material_index = structure.material_passes[0].tx_stages[0].tx_ids[0][i]
bpy.ops.object.mode_set(mode = 'OBJECT')
bpy.ops.object.mode_set(mode='OBJECT')
else:
for vertMat in structure.vert_materials:
(material, principled) = create_material_from_vertex_material(name, vertMat)
@@ -69,8 +70,8 @@ def create_vertex_material(context, principleds, structure, mesh, b_mesh, name,
links = node_tree.links
links.new(texture_node.outputs['Color'], bsdf_node.inputs['Base Color'])
links.new(texture_node.outputs['Alpha'], bsdf_node.inputs['Alpha'])
#Iterate through all materials and set their blend mode to Alpha Clip for transparency

# Iterate through all materials and set their blend mode to Alpha Clip for transparency
for material in mesh.materials:
if material:
material.blend_method = 'CLIP'