Skip to content

Commit

Permalink
Misc stuff
Browse files Browse the repository at this point in the history
  • Loading branch information
General-101 committed Nov 23, 2024
1 parent f510c4c commit 9209459
Show file tree
Hide file tree
Showing 5 changed files with 157 additions and 41 deletions.
8 changes: 4 additions & 4 deletions io_scene_halo/file_tag/h2/file_scenario/build_asset.py
Original file line number Diff line number Diff line change
Expand Up @@ -177,10 +177,10 @@ def write_object(output_stream, scenery_element):

def write_color_change(output_stream, scenery_element):
output_stream.write(struct.pack('>I', scenery_element.active_change_colors))
output_stream.write(struct.pack('<bbbx', scenery_element.primary_color_BGRA[0], scenery_element.primary_color_BGRA[1], scenery_element.primary_color_BGRA[2]))
output_stream.write(struct.pack('<bbbx', scenery_element.secondary_color_BGRA[0], scenery_element.secondary_color_BGRA[1], scenery_element.secondary_color_BGRA[2]))
output_stream.write(struct.pack('<bbbx', scenery_element.tertiary_color_BGRA[0], scenery_element.tertiary_color_BGRA[1], scenery_element.tertiary_color_BGRA[2]))
output_stream.write(struct.pack('<bbbx', scenery_element.quaternary_color_BGRA[0], scenery_element.quaternary_color_BGRA[1], scenery_element.quaternary_color_BGRA[2]))
output_stream.write(struct.pack('<BBBx', scenery_element.primary_color_BGRA[0], scenery_element.primary_color_BGRA[1], scenery_element.primary_color_BGRA[2]))
output_stream.write(struct.pack('<BBBx', scenery_element.secondary_color_BGRA[0], scenery_element.secondary_color_BGRA[1], scenery_element.secondary_color_BGRA[2]))
output_stream.write(struct.pack('<BBBx', scenery_element.tertiary_color_BGRA[0], scenery_element.tertiary_color_BGRA[1], scenery_element.tertiary_color_BGRA[2]))
output_stream.write(struct.pack('<BBBx', scenery_element.quaternary_color_BGRA[0], scenery_element.quaternary_color_BGRA[1], scenery_element.quaternary_color_BGRA[2]))

def write_scenery(output_stream, SCENARIO, TAG):
if len(SCENARIO.scenery) > 0:
Expand Down
2 changes: 0 additions & 2 deletions io_scene_halo/global_functions/mesh_processing.py
Original file line number Diff line number Diff line change
Expand Up @@ -514,8 +514,6 @@ def generate_mesh_object_retail(asset, object_vertices, object_triangles, object
region_tris = []
vert_map = {}
region_verts = []
region_normals = []
used_vert_indices = []
for triangle in object_triangles:
if game_title == "halo1":
region_index = triangle.region
Expand Down
Binary file not shown.
118 changes: 118 additions & 0 deletions io_scene_halo/global_functions/shader_generation/shader_opaque.py
Original file line number Diff line number Diff line change
Expand Up @@ -325,6 +325,124 @@ def generate_shader_tex_bump(mat, shader, shader_template, report):
if not specular_glancing_parameter == None:
tex_bump_node.inputs["Specular Glancing Color"].default_value = specular_glancing_parameter.color

def generate_shader_tex_bump_illum(mat, shader, shader_template, report):
mat.use_nodes = True

parameter_keys = ["bump_map", "base_map", "detail_map", "self_illum_map", "self_illum_color", "emissive_power", "emissive_color", "specular_color", "specular_glancing_color"]
parameters = generate_parameters(shader, shader_template, parameter_keys)

bump_parameter = None
base_parameter = None
detail_parameter = None
self_illum_parameter = None
self_illum_color_parameter = None
emissive_color_parameter = None
emissive_power_parameter = None
specular_parameter = None
specular_glancing_parameter = None
for parameter in parameters:
if parameter.name == "bump_map":
bump_parameter = parameter
elif parameter.name == "base_map":
base_parameter = parameter
elif parameter.name == "detail_map":
detail_parameter = parameter
elif parameter.name == "self_illum_map":
self_illum_parameter = parameter
elif parameter.name == "self_illum_color":
self_illum_color_parameter = parameter
elif parameter.name == "emissive_color":
emissive_color_parameter = parameter
elif parameter.name == "emissive_power":
emissive_power_parameter = parameter
elif parameter.name == "specular_color":
specular_parameter = parameter
elif parameter.name == "specular_glancing_color":
specular_glancing_parameter = parameter

texture_root = bpy.context.preferences.addons["io_scene_halo"].preferences.halo_2_data_path
for node in mat.node_tree.nodes:
mat.node_tree.nodes.remove(node)

output_material_node = get_output_material_node(mat)
output_material_node.location = Vector((0.0, 0.0))

tex_bump_illum_node = get_shader_node(mat.node_tree, "tex_bump_illum")
tex_bump_illum_node.location = Vector((-450.0, -20.0))
tex_bump_illum_node.name = "Tex Bump Illum"
tex_bump_illum_node.width = 400.0
tex_bump_illum_node.height = 100.0

connect_inputs(mat.node_tree, tex_bump_illum_node, "Shader", output_material_node, "Surface")

if not bump_parameter == None:
bump_map, bump_map_name, bump_bitmap = get_h2_bitmap(bump_parameter.bitmap, texture_root, report)
bump_node = generate_image_node(mat, bump_map, bump_bitmap, bump_map_name)
bump_node.name = "Bump Map"
bump_node.location = Vector((-900, 525))
bump_node.interpolation = 'Cubic'
if not bump_node.image == None:
bump_node.image.colorspace_settings.name = 'Non-Color'
bump_node.image.alpha_mode = 'CHANNEL_PACKED'

connect_inputs(mat.node_tree, bump_node, "Color", tex_bump_illum_node, "Bump Map")
set_image_scale(mat, bump_node, bump_parameter.scale)
if bump_bitmap:
height_value = 0.0
if not bump_bitmap.bump_height == 0.0:
height_value = bump_bitmap.bump_height / 10

tex_bump_illum_node.inputs["Bump Map Repeat"].default_value = height_value

if not base_parameter == None:
base_map, base_map_name, base_bitmap = get_h2_bitmap(base_parameter.bitmap, texture_root, report)
base_node = generate_image_node(mat, base_map, base_bitmap, base_map_name)
base_node.name = "Base Map"
base_node.location = Vector((-900, -75))
if not base_node.image == None:
base_node.image.alpha_mode = 'CHANNEL_PACKED'

connect_inputs(mat.node_tree, base_node, "Color", tex_bump_illum_node, "Base Map")
connect_inputs(mat.node_tree, base_node, "Alpha", tex_bump_illum_node, "Base Map Alpha")
set_image_scale(mat, base_node, base_parameter.scale)

if not self_illum_parameter == None:
self_illum_map, self_illum_map_name, self_illum_bitmap = get_h2_bitmap(self_illum_parameter.bitmap, texture_root, report)
self_illum_node = generate_image_node(mat, self_illum_map, self_illum_bitmap, self_illum_map_name)
self_illum_node.name = "Self Illum Map"
self_illum_node.location = Vector((-900, -75))
if not self_illum_node.image == None:
self_illum_node.image.alpha_mode = 'CHANNEL_PACKED'

connect_inputs(mat.node_tree, self_illum_node, "Color", tex_bump_illum_node, "Self Illum Map")
set_image_scale(mat, self_illum_node, self_illum_parameter.scale)

if not self_illum_color_parameter == None:
tex_bump_illum_node.inputs["Self Illum Color"].default_value = self_illum_color_parameter.color

if not self_illum_color_parameter == None:
tex_bump_illum_node.inputs["Emissive Color"].default_value = emissive_color_parameter.color

if not self_illum_color_parameter == None:
tex_bump_illum_node.inputs["Emissive Power"].default_value = emissive_power_parameter.value * 100

if not detail_parameter == None:
detail_map, detail_map_name, detail_bitmap = get_h2_bitmap(detail_parameter.bitmap, texture_root, report)
detail_node = generate_image_node(mat, detail_map, detail_bitmap, detail_map_name)
detail_node.name = "Detail Map"
detail_node.location = Vector((-900, -375))
if not detail_node.image == None:
detail_node.image.colorspace_settings.name = 'Non-Color'
detail_node.image.alpha_mode = 'CHANNEL_PACKED'

connect_inputs(mat.node_tree, detail_node, "Color", tex_bump_illum_node, "Detail Map")
set_image_scale(mat, detail_node, detail_parameter.scale)

if not specular_parameter == None:
tex_bump_illum_node.inputs["Specular Color"].default_value = specular_parameter.color
if not specular_glancing_parameter == None:
tex_bump_illum_node.inputs["Specular Glancing Color"].default_value = specular_glancing_parameter.color

def generate_shader_tex_bump_detail_blend(mat, shader, shader_template, report):
mat.use_nodes = True

Expand Down
Loading

0 comments on commit 9209459

Please sign in to comment.