Help Needed with Unity Skybox Blender Shader: Integrating Unity in Action Book & Weather Controller Script

Hello Unity Enthusiasts,

I hope you’re all having a great day. I’m currently working on a Unity project that involves implementing a custom Skybox shader to create a smooth transition between day and night cycles. The code for this shader is adapted from the book “Unity in Action,” and I’ve also incorporated a Weather Controller script to manage the transition.

The Challenge: Skybox Blender Shader
I’m currently facing a unique challenge with my Skybox Blender shader, which is designed to facilitate seamless transitions between day and night cycles. You can access the shader code Skybox Blended Shader However, despite my best efforts, I’m encountering an issue where a persistent red tint appears during the transition.

Weather Controller Script
To manage the transition, I’m using the Weather Controller script, which is part of the Unity in Action book’s code. Here’s the script:

using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class WeatherController : MonoBehaviour
{
    [SerializeField] Material sky;
    [SerializeField] Light sun;

    private float fullIntensity;
    private float cloudValue = 0f;

    void Start()
    {
        fullIntensity = sun.intensity;
    }

    void Update()
    {
        SetOvercast(cloudValue);
        cloudValue += .005f;
    }

    private void SetOvercast(float value)
    {
        sky.SetFloat("_Blend", value);
        sun.intensity = fullIntensity - (fullIntensity * value);
    }
}

The Dilemma
It’s worth noting that the day-night transition works flawlessly when I manually adjust the settings in the Unity Editor. However, when I run the scene, the persistent red tint issue appears, marring the intended visual experience.

I’m sharing my experience with the community in the hope that someone with expertise in Skybox shaders or Unity’s lighting system might have encountered a similar challenge or have insights into what might be causing the red tint issue during the day-night transition.

P.S if this sounds robotic i asked chatgpt to write this post bc i was too lazy