diff --git a/fast64_internal/f3d/f3d_material.py b/fast64_internal/f3d/f3d_material.py index 5a977276d..49b8bf80a 100644 --- a/fast64_internal/f3d/f3d_material.py +++ b/fast64_internal/f3d/f3d_material.py @@ -1585,34 +1585,30 @@ def update_node_combiner(material, combinerInputs, cycleIndex): def update_fog_nodes(material: Material, context: Context): nodes = material.node_tree.nodes f3dMat: "F3DMaterialProperty" = material.f3d_mat - shade_alpha_is_fog = material.f3d_mat.rdp_settings.g_fog fogBlender: ShaderNodeGroup = nodes["FogBlender"] # if NOT setting rendermode, it is more likely that the user is setting # rendermodes in code, so to be safe we'll enable fog. Plus we are checking # that fog is enabled in the geometry mode, so if so that's probably the intent. fogBlender.node_tree = bpy.data.node_groups[ - ( - "FogBlender_On" - if shade_alpha_is_fog and is_blender_doing_fog(material.f3d_mat.rdp_settings, True) - else "FogBlender_Off" - ) + ("FogBlender_On" if is_blender_doing_fog(material.f3d_mat.rdp_settings, True) else "FogBlender_Off") ] - if shade_alpha_is_fog: - inherit_fog = f3dMat.use_global_fog or not f3dMat.set_fog - if inherit_fog: - link_if_none_exist(material, nodes["SceneProperties"].outputs["FogColor"], nodes["FogColor"].inputs[0]) - link_if_none_exist(material, nodes["GlobalFogColor"].outputs[0], fogBlender.inputs["Fog Color"]) - link_if_none_exist( - material, nodes["SceneProperties"].outputs["FogNear"], nodes["CalcFog"].inputs["FogNear"] - ) - link_if_none_exist(material, nodes["SceneProperties"].outputs["FogFar"], nodes["CalcFog"].inputs["FogFar"]) - else: - remove_first_link_if_exists(material, nodes["FogBlender"].inputs["Fog Color"].links) - remove_first_link_if_exists(material, nodes["CalcFog"].inputs["FogNear"].links) - remove_first_link_if_exists(material, nodes["CalcFog"].inputs["FogFar"].links) - + remove_first_link_if_exists(material, fogBlender.inputs["FogAmount"].links) + if material.f3d_mat.rdp_settings.g_fog: + material.node_tree.links.new(nodes["CalcFog"].outputs["FogAmount"], fogBlender.inputs["FogAmount"]) + else: # If fog is not being calculated, pass in shade alpha + material.node_tree.links.new(nodes["Shade Color"].outputs["Alpha"], fogBlender.inputs["FogAmount"]) + + if f3dMat.use_global_fog or not f3dMat.set_fog: # Inherit fog + link_if_none_exist(material, nodes["SceneProperties"].outputs["FogColor"], nodes["FogColor"].inputs[0]) + link_if_none_exist(material, nodes["GlobalFogColor"].outputs[0], fogBlender.inputs["Fog Color"]) + link_if_none_exist(material, nodes["SceneProperties"].outputs["FogNear"], nodes["CalcFog"].inputs["FogNear"]) + link_if_none_exist(material, nodes["SceneProperties"].outputs["FogFar"], nodes["CalcFog"].inputs["FogFar"]) + else: + remove_first_link_if_exists(material, nodes["FogBlender"].inputs["Fog Color"].links) + remove_first_link_if_exists(material, nodes["CalcFog"].inputs["FogNear"].links) + remove_first_link_if_exists(material, nodes["CalcFog"].inputs["FogFar"].links) fogBlender.inputs["Fog Color"].default_value = s_rgb_alpha_1_tuple(f3dMat.fog_color) nodes["CalcFog"].inputs["FogNear"].default_value = f3dMat.fog_position[0] nodes["CalcFog"].inputs["FogFar"].default_value = f3dMat.fog_position[1]