/* Aurora Astral 1.0 - standard_uniforms.glsl
   Global standard OptiFine/Iris uniforms and version compatibility.
*/

#ifndef AURORA_ASTRAL_STANDARD_UNIFORMS_GLSL
#define AURORA_ASTRAL_STANDARD_UNIFORMS_GLSL

// View & Frame Dimensions (Centralized to prevent undefined variable errors)
uniform float viewWidth;
uniform float viewHeight;
uniform int frameCounter;
uniform float frameTime;
uniform float frameTimeCounter;
uniform int worldTime;
uniform int worldDay;

// Capture Iris' real running-time counter before the source-compatibility
// macro below redirects inherited Aurora animations to world ticks.
float astral_raw_runtime_animation_time() {
    return frameTimeCounter;
}

// Keep the End on Iris' continuous sub-second runtime. Combining integer OS
// seconds with the unrelated fractional runtime produces a one-second
// sawtooth and makes every celestial layer visibly loop. Iris' native counter
// is smooth and lasts an hour; the End's decorrelated clocks and advected
// domains make the complete visual recurrence vastly longer than any single
// local oscillation.
float astral_end_animation_time() {
    return astral_raw_runtime_animation_time();
}

// Iris resets frameTimeCounter whenever shaders are recompiled (F3 + R).
// Build the animation clock from persistent world ticks instead, preserving
// the original seconds unit expected by every existing animation. Limiting
// the day component keeps float precision high enough for subtle motion. The
// 256-day period is roughly 85 real-time hours of uninterrupted play.
float astral_persistent_animation_time() {
    return (mod(float(worldDay), 256.0) * 24000.0
        + float(worldTime)) * 0.05;
}

// Keep all inherited Aurora code source-compatible while making its motion
// phase survive shader reloads, settings changes and resource reloads.
#define frameTimeCounter astral_persistent_animation_time()

// Minecraft 1.19+ Darkness Effect Uniforms
#if MC_VERSION >= 11900
    uniform float darknessFactor;
    uniform float darknessLightFactor;
#else
    #define darknessFactor 0.0
    #define darknessLightFactor 0.0
#endif

// Screen size & render scale macros
#include "/lib/screen_size.glsl"

#endif // AURORA_ASTRAL_STANDARD_UNIFORMS_GLSL
