
#ifdef VERTEX

out vec2 VlightmapCoord;
out vec2 vTexcoord;
out vec4 Albedo;

out vec3 vpNormal;
out vec3 SSNormal;

void main() {
	gl_Position = ftransform();
	vTexcoord = (gl_TextureMatrix[0] * gl_MultiTexCoord0).xy;
	VlightmapCoord  = (gl_TextureMatrix[1] * gl_MultiTexCoord1).xy;
	Albedo = gl_Color;
	vpNormal = gl_Normal;
	SSNormal = gl_NormalMatrix * gl_Normal;

}

#endif

#ifdef FRAGMENT


/*
const int colortex0Format = RGBA16;
*/

uniform sampler2D lightmap;
uniform sampler2D gtexture;


//>>IN-OUT<<//
in vec2 VlightmapCoord;
in vec2 vTexcoord;
in vec4 Albedo;

in vec3 vpNormal;
in vec3 SSNormal;



//>>Matrice<<//
uniform mat4 gbufferModelViewInverse, gbufferProjectionInverse;

//>>UNIFORM VEC3<<//

uniform vec3 shadowLightPosition;
uniform vec3 cameraPosition;

uniform int worldTime;
uniform float rainStrength;

uniform float viewHeight;
uniform float viewWidth;

//>>Include<<//
#include "/lib/Conf/Lighting_conf.glsl"
#include "/lib/Lighting/DiffuseLighting.glsl"


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


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

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

#include "/lib/Lighting/Gooch.glsl"



void main() {
	vec4 VColor= texture2D(gtexture, vTexcoord) * Albedo;
	VColor *= texture2D(lightmap, VlightmapCoord);
	
	#ifdef OVERWORLD
	#ifdef Diffuse_Light
	vec4 phases = GetAtmospherePhases();
	VColor.rgb *=VPGoochLighting(phases);
	#endif	
	#endif

	
	
	


/* DRAWBUFFERS:01*/
	gl_FragData[0] = VColor; //gcolor
	gl_FragData[1] = vec4(SSNormal,1.);
}
#endif