Skip to content

Commit

Permalink
Fixed gamma on lighting
Browse files Browse the repository at this point in the history
  • Loading branch information
sauraen committed Jul 7, 2024
1 parent 1bc46ab commit f8afc22
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 13 deletions.
12 changes: 3 additions & 9 deletions fast64_internal/f3d/f3d_material.py
Original file line number Diff line number Diff line change
Expand Up @@ -1554,7 +1554,7 @@ def update_fog_nodes(material: Material, context: Context):
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 = f3dMat.fog_color
fogBlender.inputs["Fog Color"].default_value = gammaCorrectAlpha1Tuple(f3dMat.fog_color)
nodes["CalcFog"].inputs["FogNear"].default_value = f3dMat.fog_position[0]
nodes["CalcFog"].inputs["FogFar"].default_value = f3dMat.fog_position[1]

Expand Down Expand Up @@ -1661,13 +1661,7 @@ def update_light_colors(material, context):
def update_color_node(combiner_inputs, color: Color, prefix: str):
"""Function for updating either Prim or Env colors"""
# TODO: feature to toggle gamma correction
corrected_prim = gammaCorrect(color)
combiner_inputs[f"{prefix} Color"].default_value = (
corrected_prim[0],
corrected_prim[1],
corrected_prim[2],
1.0,
)
combiner_inputs[f"{prefix} Color"].default_value = gammaCorrectAlpha1Tuple(color)
combiner_inputs[f"{prefix} Alpha"].default_value = color[3]


Expand Down Expand Up @@ -4413,7 +4407,7 @@ def draw(self, context):
else:
numLightsNeeded = 1
if header.skyboxLighting == "Custom":
r2 = b.row()
r2 = b.row().split(factor=0.4)
r2.prop(renderSettings, "ootForceTimeOfDay")
if renderSettings.ootForceTimeOfDay:
r2.label(text="Light Index sets first of four lights.", icon="INFO")
Expand Down
Binary file modified fast64_internal/f3d/f3d_material_library.blend
Binary file not shown.
8 changes: 4 additions & 4 deletions fast64_internal/render_settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -100,20 +100,20 @@ def update_scene_props_from_render_settings(
renderSettings: "Fast64RenderSettings_Properties",
):
sceneOutputs.inputs["FogEnable"].default_value = int(renderSettings.enableFogPreview)
sceneOutputs.inputs["FogColor"].default_value = tuple(c for c in renderSettings.fogPreviewColor)
sceneOutputs.inputs["FogColor"].default_value = gammaCorrectAlpha1Tuple(renderSettings.fogPreviewColor)
sceneOutputs.inputs["F3D_NearClip"].default_value = float(renderSettings.clippingPlanes[0])
sceneOutputs.inputs["F3D_FarClip"].default_value = float(renderSettings.clippingPlanes[1])
sceneOutputs.inputs["Blender_Game_Scale"].default_value = float(get_blender_to_game_scale(context))
sceneOutputs.inputs["FogNear"].default_value = renderSettings.fogPreviewPosition[0]
sceneOutputs.inputs["FogFar"].default_value = renderSettings.fogPreviewPosition[1]

sceneOutputs.inputs["AmbientColor"].default_value = tuple(c for c in renderSettings.ambientColor)
sceneOutputs.inputs["Light0Color"].default_value = tuple(c for c in renderSettings.light0Color)
sceneOutputs.inputs["AmbientColor"].default_value = gammaCorrectAlpha1Tuple(renderSettings.ambientColor)
sceneOutputs.inputs["Light0Color"].default_value = gammaCorrectAlpha1Tuple(renderSettings.light0Color)
sceneOutputs.inputs["Light0Dir"].default_value = tuple(
d for d in (mathutils.Vector(renderSettings.light0Direction) @ transform_mtx_blender_to_n64())
)
sceneOutputs.inputs["Light0Size"].default_value = renderSettings.light0SpecSize
sceneOutputs.inputs["Light1Color"].default_value = tuple(c for c in renderSettings.light1Color)
sceneOutputs.inputs["Light1Color"].default_value = gammaCorrectAlpha1Tuple(renderSettings.light1Color)
sceneOutputs.inputs["Light1Dir"].default_value = tuple(
d for d in (mathutils.Vector(renderSettings.light1Direction) @ transform_mtx_blender_to_n64())
)
Expand Down

0 comments on commit f8afc22

Please sign in to comment.