float AdjustLightmapTorch(float torch)
{
    torch = pow(torch, TORCH_CURVE);

    // Curva en S
    torch = torch * (2.0 - torch);

    return torch * TORCH_STRENGTH;
}

float AdjustLightmapSky(float sky)
{
    return pow(sky, 4.0);
}


vec3 SkyLightingColor(vec4 phases){
	vec3 Sunrise = SKY_SUNRISE_MIDDLE* phases.x;
	vec3 Noon = vec3(1) * phases.y;
	vec3 Sunset = SKY_SUNSET_MIDDLE * phases.z;
	vec3 night = SKY_MIDNIGHT_MIDDLE * phases.w;

	return Sunrise+Noon+Sunset+night;
}

vec3 GetLightmapColor(vec2 lm, vec4 phases)
{
    float torch = AdjustLightmapTorch(lm.x);
    float sky   = AdjustLightmapSky(lm.y);

    vec3 torchLighting =vec3(Torch_r, Torch_g, Torch_b) * torch;
    vec3 skyLighting   =SkyLightingColor(phases) * sky;

	vec3 Ambient = vec3(0.25);

    return Ambient+torchLighting + skyLighting;
}
