Skip to content

Commit

Permalink
Random stuff I had
Browse files Browse the repository at this point in the history
Set up normals for lightmaps when imported scenarios. Prob why some things looked weird

Fix H2 a bug  in the scenario reader

Always generate simple shaders for H3. We're never doing full
  • Loading branch information
General-101 committed Dec 3, 2024
1 parent abf051b commit 066e556
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 6 deletions.
2 changes: 2 additions & 0 deletions io_scene_halo/file_tag/build_scene/build_lightmap.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ def process_mesh(SBSP_ASSET, random_color_gen, tag_block, poop_name, material_co
for render_data in tag_block.cache_data:
triangles = []
vertices = [raw_vertex.position * 100 for raw_vertex in render_data.raw_vertices]
normals = [raw_vertex.normal for raw_vertex in render_data.raw_vertices]

triangle_length = int(len(render_data.strip_indices) / 3)
for idx in range(triangle_length):
Expand All @@ -52,6 +53,7 @@ def process_mesh(SBSP_ASSET, random_color_gen, tag_block, poop_name, material_co
for poly in mesh.polygons:
poly.use_smooth = True

mesh.normals_split_custom_set_from_vertices(normals)
uv_name_render = 'UVMap_Render'
uv_name_lightmap = 'UVMap_Lightmap'
render_layer_uv = mesh.uv_layers.get(uv_name_render)
Expand Down
4 changes: 2 additions & 2 deletions io_scene_halo/file_tag/h2/file_scenario/format.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
from enum import Flag, Enum, auto
from mathutils import Vector, Euler

from ....file_tag.h2.file_functions.format import Function
from ....file_tag.h2.file_functions.format import Function as ShaderFunction

SALT_SIZE = 32

Expand Down Expand Up @@ -2542,7 +2542,7 @@ def __init__(self, map_id=0, bitmap=None, path="", sort_order=0, flags=0, max_te
self.max_teams_14_stub = max_teams_14_stub
self.max_teams_15_stub = max_teams_15_stub

class Interpolator(Function):
class Interpolator(ShaderFunction):
def __init__(self, name="", name_length=0, accelerator_name="", accelerator_name_length=0, multiplier_name="", multiplier_name_length=0):
super().__init__()
self.name = name
Expand Down
1 change: 1 addition & 0 deletions io_scene_halo/file_tag/h2/file_scenario/process_file.py
Original file line number Diff line number Diff line change
Expand Up @@ -4544,6 +4544,7 @@ def read_interpolators(SCENARIO, TAG, input_stream, tag_node, XML_OUTPUT):
if multiplier_name_length > 0:
interpolator.multiplier_name = TAG.read_variable_string_no_terminator(input_stream, multiplier_name_length, TAG, tag_format.XMLData(interpolator_element_node, "multiplier name"))

interpolator.SCFN_header = TAG.TagBlockHeader().read(input_stream, TAG)
read_function(TAG, input_stream, interpolator_element_node, interpolator)

def read_shared_references(SCENARIO, TAG, input_stream, tag_node, XML_OUTPUT):
Expand Down
9 changes: 5 additions & 4 deletions io_scene_halo/global_functions/shader_processing.py
Original file line number Diff line number Diff line change
Expand Up @@ -1046,10 +1046,11 @@ def generate_h3_shader(mat, shader_path, report):
# 2 = Full Shader generation
if not int(bpy.context.preferences.addons["io_scene_halo"].preferences.shader_gen) == 0:
if not shader_path == None:
if int(bpy.context.preferences.addons["io_scene_halo"].preferences.shader_gen) == 1:
generate_h3_shader_simple(mat, shader_path, report)
else:
print("Skipping shader")
generate_h3_shader_simple(mat, shader_path, report)
#if int(bpy.context.preferences.addons["io_scene_halo"].preferences.shader_gen) == 1:
#generate_h3_shader_simple(mat, shader_path, report)
#else:
#print("Skipping shader")
#generate_shader_environment(mat, shader, report)

else:
Expand Down

0 comments on commit 066e556

Please sign in to comment.