// Developed by EminGT
// Modified by Haider


#ifndef INCLUDE_LIGHT_AND_AMBIENT_MULTIPLIERS
    #define INCLUDE_LIGHT_AND_AMBIENT_MULTIPLIERS

    vec3 GetLightColorMult() {
        vec3 lightColorMult;

        #ifdef OVERWORLD
            // Time-of-Day Light Temperature System
            vec3 morningLightMult = vec3(LIGHT_MORNING_R, LIGHT_MORNING_G, LIGHT_MORNING_B) * LIGHT_MORNING_I;
            vec3 noonLightMult = vec3(LIGHT_NOON_R, LIGHT_NOON_G, LIGHT_NOON_B) * LIGHT_NOON_I;
            vec3 nightLightMult = vec3(LIGHT_NIGHT_R, LIGHT_NIGHT_G, LIGHT_NIGHT_B) * LIGHT_NIGHT_I;
            vec3 rainLightMult = vec3(LIGHT_RAIN_R, LIGHT_RAIN_G, LIGHT_RAIN_B) * LIGHT_RAIN_I;

            // Smooth transitions between lighting periods
            lightColorMult = mix(noonLightMult, morningLightMult, invNoonFactor2);
            lightColorMult = mix(nightLightMult, lightColorMult, sunVisibility2);
            
            // Weather influence on light color temperature
            lightColorMult = mix(lightColorMult, dot(lightColorMult, vec3(0.33333)) * rainLightMult, rainFactor);
            
        #elif defined NETHER
            // Nether Environment: Consistent warm/hellish lighting
            vec3 netherLightMult = vec3(LIGHT_NETHER_R, LIGHT_NETHER_G, LIGHT_NETHER_B) * LIGHT_NETHER_I;
            lightColorMult = netherLightMult;
            
        #elif defined END
            // End Dimension: Ethereal purple-tinted lighting
            vec3 endLightMult = vec3(LIGHT_END_R, LIGHT_END_G, LIGHT_END_B) * LIGHT_END_I;
            lightColorMult = endLightMult;
        #endif

        return lightColorMult;
    }


    vec3 GetAtmColorMult() {
        vec3 atmColorMult;

        #ifdef OVERWORLD
            // Atmospheric Color Temperature System
            vec3 morningAtmMult = vec3(ATM_MORNING_R, ATM_MORNING_G, ATM_MORNING_B) * ATM_MORNING_I;
            vec3 noonAtmMult = vec3(ATM_NOON_R, ATM_NOON_G, ATM_NOON_B) * ATM_NOON_I;
            vec3 nightAtmMult = vec3(ATM_NIGHT_R, ATM_NIGHT_G, ATM_NIGHT_B) * ATM_NIGHT_I;
            vec3 rainAtmMult = vec3(ATM_RAIN_R, ATM_RAIN_G, ATM_RAIN_B) * ATM_RAIN_I;

            // Smooth atmospheric transitions
            atmColorMult = mix(noonAtmMult, morningAtmMult, invNoonFactor2);
            atmColorMult = mix(nightAtmMult, atmColorMult, sunVisibility2);
            
            // Weather influence on atmospheric color
            atmColorMult = mix(atmColorMult, dot(atmColorMult, vec3(0.33333)) * rainAtmMult, rainFactor);
            
        #elif defined NETHER
            // Nether Atmosphere: Dense, hellish ambiance
            vec3 netherAtmMult = vec3(ATM_NETHER_R, ATM_NETHER_G, ATM_NETHER_B) * ATM_NETHER_I;
            atmColorMult = netherAtmMult;
            
        #elif defined END
            // End Atmosphere: Void-like, mystical ambiance
            vec3 endAtmMult = vec3(ATM_END_R, ATM_END_G, ATM_END_B) * ATM_END_I;
            atmColorMult = endAtmMult;
        #endif

        return atmColorMult;
    }

    // Global Environmental Color Variables
    // Updated dynamically based on current environmental conditions
    vec3 lightColorMult;       // Primary light source color multiplier
    vec3 atmColorMult;         // Atmospheric/ambient color multiplier  
    vec3 sqrtAtmColorMult;     // Square root of atmospheric multiplier for special calculations

#endif //INCLUDE_LIGHT_AND_AMBIENT_MULTIPLIERS


#ifndef INCLUDE_MOON_PHASE_INF
    #define INCLUDE_MOON_PHASE_INF

    #ifdef OVERWORLD

        float moonPhaseInfluence = mix(
            1.0,  // Day time: No moon influence
            moonPhase == 0 ? MOON_PHASE_FULL :        // Full moon: Maximum brightness
            moonPhase != 4 ? MOON_PHASE_PARTIAL :     // Partial phases: Medium brightness
            MOON_PHASE_DARK,                          // New moon: Minimum brightness
            1.0 - sunVisibility2                      // Apply only during night
        );
    #else
        /**
         * Non-Overworld Dimensions: Static lighting
         * Nether and End dimensions maintain consistent lighting without lunar influence
         */
        const float moonPhaseInfluence = 1.0;
    #endif
    
#endif //INCLUDE_MOON_PHASE_INF

