Skip to content

Commit

Permalink
Texture flag correction
Browse files Browse the repository at this point in the history
Thanks to Kyuuhachi
  • Loading branch information
eArmada8 committed Apr 21, 2024
1 parent 71cd0b5 commit c46c154
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 6 deletions.
2 changes: 1 addition & 1 deletion ys8_it3_export_assets.py
Original file line number Diff line number Diff line change
Expand Up @@ -350,7 +350,7 @@ def parse_mat6_block (f):
parameters.append(list(struct.unpack("<4f", block.read(16))))
textures_flags = []
for j in range(count_textures):
textures_flags.append(list(struct.unpack("<7H", block.read(14))))
textures_flags.append(list(struct.unpack("<4I", block.read(16))))
unk2 = []
remaining_distance = part_size - block.tell()
if remaining_distance > 0:
Expand Down
2 changes: 1 addition & 1 deletion ys8_it3_import_assets.py
Original file line number Diff line number Diff line change
Expand Up @@ -215,7 +215,7 @@ def create_mat6 (materials):
part1 = struct.pack("<7I", *materials[i]['unk0']) \
+ struct.pack("<3I", len(materials[i]['parameters']), materials[i]['unk1'], len(materials[i]['textures'])) \
+ b''.join([struct.pack("<4f", *x) for x in materials[i]['parameters']]) \
+ b''.join([struct.pack("<7H", *x['flags']) for x in materials[i]['textures']]) \
+ b''.join([struct.pack("<4I", *x['flags']) for x in materials[i]['textures']]) \
+ struct.pack("<{}H".format(len(materials[i]['unk2'])), *materials[i]['unk2'])
part2 = struct.pack("<I", 64) + materials[i]['material_name'].encode().ljust(64, b'\x00') \
+ struct.pack("<I", 32) + b''.join([x['name'].encode().ljust(32, b'\x00') for x in materials[i]['textures']])
Expand Down
8 changes: 4 additions & 4 deletions ys8_it3_to_basic_gltf.py
Original file line number Diff line number Diff line change
Expand Up @@ -159,14 +159,14 @@ def generate_materials(gltf_data, it3_contents):
if it3_contents[mat_blocks[i]]['type'] == 'MAT6':
for k in range(len(it3_contents[mat_blocks[i]]['data'][j]['textures'])):
add_texture = False
sampler = { 'wrapS': {0:10497,1:33071,2:33648}[it3_contents[mat_blocks[i]]['data'][j]['textures'][k]['flags'][4]],\
'wrapT': {0:10497,1:33071,2:33648}[it3_contents[mat_blocks[i]]['data'][j]['textures'][k]['flags'][6]] } # This is probably wrong
sampler = { 'wrapS': {0:10497,1:33071,2:33648}[it3_contents[mat_blocks[i]]['data'][j]['textures'][k]['flags'][2]],\
'wrapT': {0:10497,1:33071,2:33648}[it3_contents[mat_blocks[i]]['data'][j]['textures'][k]['flags'][3]] }
texture = { 'source': images.index(it3_contents[mat_blocks[i]]['data'][j]['textures'][k]['name']), 'sampler': len(gltf_data['samplers']) }
if it3_contents[mat_blocks[i]]['data'][j]['textures'][k]['flags'][0:3] == [1,0,0]:
if k == 0:
material['pbrMetallicRoughness']= { 'baseColorTexture' : { 'index' : len(gltf_data['textures']), 'texCoord': 0 },\
'metallicFactor' : 0.0, 'roughnessFactor' : 1.0 }
add_texture = True
elif it3_contents[mat_blocks[i]]['data'][j]['textures'][k]['flags'][0:2] == [2,0]:
elif it3_contents[mat_blocks[i]]['data'][j]['textures'][k]['name'] == it3_contents[mat_blocks[i]]['data'][j]['textures'][0]['name']+'n':
material['normalTexture'] = { 'index' : len(gltf_data['textures']), 'texCoord': 0 }
add_texture = True
if add_texture == True:
Expand Down

0 comments on commit c46c154

Please sign in to comment.