#ifdef VERTEX

out vec4 starData;

void main() {
	gl_Position = ftransform();
	starData = vec4(gl_Color.rgb, float(gl_Color.r == gl_Color.g && gl_Color.g == gl_Color.b && gl_Color.r > 0.0));
}
#endif




#ifdef FRAGMENT
uniform float viewHeight;
uniform float viewWidth;
uniform mat4 gbufferModelView;
uniform mat4 gbufferProjectionInverse,gbufferProjection;
uniform mat4 gbufferModelViewInverse;
uniform vec3 sunPosition,moonPosition;

uniform vec3 fogColor;
uniform vec3 skyColor;
uniform vec3 cameraPosition;

uniform float sunAngle;

uniform int worldTime;
uniform float rainStrength;
uniform float frameTimeCounter;

uniform sampler2D colortex10;
uniform sampler2D colortex13;
uniform sampler2D colortex12;
uniform sampler2D colortex11;


in vec4 starData; //rgb = star color, a = flag for weather or not this pixel is a star.

#include "/lib/Conf/Sky_conf.glsl"
#include "/lib/util/time.glsl"
#include "/lib/sky/Sky_Palet.glsl"
#include "/lib/sky/Phases.glsl"
#include "/lib/sky/SunLight.glsl"

#include "/lib/util/transformations.glsl"

#include "/lib/Color/Luminance.glsl"
#include "/lib/sky/Sky_Saturation.glsl"

#include "/lib/util/cave.glsl"

#include "/lib/util/rainVisibility.glsl"
#include "/lib/sky/SUN_MOON_UV.glsl"
#include "/lib/sky/VelpixSun.glsl"
#include "/lib/sky/RenderSky.glsl"



void main() {
	
		vec3 viewDir = GetWorldDirection();

		float rainFactor = rain_time();

		float h = clamp(viewDir.y * 0.5 + 0.5, 0.0, 1.0);

		vec4 phases = GetAtmospherePhases();

		vec3 sunDir  = GetSunDirection();
    	vec3 moonDir = GetMoonDirection();

	
		vec3 sky = vpRenderSky(viewDir);

		sky+=RenderSunMoon(viewDir);
		



		

/* DRAWBUFFERS:0 */
	gl_FragData[0] = vec4(sky,1.); //gcolor

}	

#endif