color.rgb *= 0.78;

#ifdef NETHER
    vec3 worldPos = playerPos + cameraPosition;
    vec2 lavaPos = (floor(worldPos.xz * 16.0) + worldPos.y * 32.0) * 0.000666;
    
    // v9.0: Multi-frequency lava animation for more realistic molten rock
    vec2 wind1 = vec2(frameTimeCounter * 0.012, 0.0); // Primary flow
    vec2 wind2 = vec2(frameTimeCounter * 0.008, frameTimeCounter * 0.005); // Secondary turbulence
    vec2 wind3 = vec2(sin(frameTimeCounter * 0.2) * 0.01, cos(frameTimeCounter * 0.15) * 0.01); // Slow undulation
    
    float noiseSample1 = texture2DLod(noisetex, lavaPos + wind1, 0.0).g;
    float noiseSample2 = texture2DLod(noisetex, lavaPos * 2.0 + wind2, 0.0).r;
    float noiseSample3 = texture2DLod(noisetex, lavaPos * 0.5 + wind3, 0.0).b;
    
    // Combine multiple frequencies for complex lava pattern
    float combinedNoise = noiseSample1 * 0.6 + noiseSample2 * 0.3 + noiseSample3 * 0.1;
    combinedNoise = combinedNoise - 0.5;
    combinedNoise *= 0.12;
    
    color.rgb = pow(color.rgb, vec3(1.0 + combinedNoise));
    
    // v9.0: Color pulsation - slight orange/red shift over time
    float colorPulse = sin(frameTimeCounter * 0.5) * 0.03;
    color.rgb += vec3(colorPulse, colorPulse * 0.5, 0.0);
#endif

noDirectionalShading = true;
lmCoordM = vec2(0.0);
emission = GetLuminance(color.rgb) * 4.5 + 0.15;

#ifdef LAVA_GLOW_PULSE
    // v9.0: Multi-frequency emission pulse for realistic lava glow
    float pulse1 = sin(frameTimeCounter * 0.7) * 0.05;
    float pulse2 = sin(frameTimeCounter * 1.3) * 0.02;
    float pulse3 = sin(frameTimeCounter * 2.1) * 0.01;
    emission *= 0.92 + pulse1 + pulse2 + pulse3;
#endif

maRecolor = vec3(clamp(pow2(pow2(pow2(smoothstep1(emission * 0.28)))), 0.12, 0.4) * 1.3) * vec3(0.25, vec2(0.175));

#if RAIN_PUDDLES >= 1
    noPuddles = 1.0;
#endif
