/**
 *
 * Diplomova prace
 * Stinove techniky na dnesnim hardware a jejich porovnani
 *
 * Michal Toth
 *
 * Fakulta informacnich technologii
 * Vysoke uceni technicke v Brne
 *
 * 2013/2014
 *
 */

/*
 * Vertex shader pro stinove mapy s cubemapou
 */

/*
 * Nepouzito! Pouze testovaci/debugovaci/na zkousku
 */

#version 420

in vec3 pos;
in vec3 norm;
in vec2 tex;

uniform mat4 mvp;
uniform mat4 m;
uniform mat4 mNorm;

out vec2 tc;
out vec3 position;
out vec3 normal;

void main() {
    gl_Position = mvp * m * vec4(pos,1);

    tc=tex;
    position = (m * vec4(pos,1)).xyz;
    normal = (mNorm * vec4(norm,1)).xyz;

    if(absdir.x >= absdir.y){
	if(absdir.x >= absdir.z){
	    if(dir.x>=0){
		shadowMat=shadowMatXp;
		debugColor = vec3(1,0,0);
	    }else{
		shadowMat=shadowMatXn;
		debugColor = vec3(1,0,0);
	    }
	}else{
	    if(dir.z>=0){
		shadowMat=shadowMatZp;
		debugColor = vec3(0,1,0);
	    }else{
		shadowMat=shadowMatZn;
		debugColor = vec3(0,1,0);
	    }
	}
    }else{
	if(absdir.y >= absdir.z){
	    if(dir.y>=0){
		shadowMat=shadowMatYp;
		debugColor = vec3(0,0,1);
	    }else{
		shadowMat=shadowMatYn;
		debugColor = vec3(0,0,1);
	    }
	}else{
	    if(dir.z>=0){
		shadowMat=shadowMatZp;
		debugColor = vec3(0,1,0);
	    }else{
		shadowMat=shadowMatZn;
		debugColor = vec3(0,1,0);
	    }
	}
    }


    lightDepth=(shadowMat* m * vec4(pos,1.0)).z;
}
