
// ------- ATTRIBUTES (VERTEX BUFFER DATA) -------
attribute vec4		a_vPosition0;
attribute vec2		a_vTexCoord0;
attribute vec3		a_vTexCoord1;

// ------- UNIFORMS (SHADER CONSTS) -------
uniform mat4		hu_mPMVMatrix;
uniform mat4		hu_mMVMatrix;
uniform mat4		hu_mMVIMatrix;
//uniform float		hu_fSin11; // debug
uniform vec2		u_vTextureUVScale;
uniform float		u_fWidth;
uniform vec4		u_fxWidthByDistance;
uniform vec4		u_fxWidthByAngle;

// ------- INTERPOLATORS (SHADER OUTPUTS) -------
varying vec2		v_vTex0UV;

void main(void)
{
	v_vTex0UV = a_vTexCoord0*u_vTextureUVScale;
	vec4 vPos = a_vPosition0;
	vec3 vShift = a_vTexCoord1;

	//if (hu_fSin11 > 0.0)
	//{
		// eye space
		vec4 vPosEye = hu_mMVMatrix*vPos;
		vec3 vShiftEye = normalize(vShift*mat3(hu_mMVIMatrix));
		
		vec3 vCam2Pos = normalize(vPosEye.xyz);
		float fAngle = abs(dot(vShiftEye, vCam2Pos));
		float fWidthByAngle = GetGrowingValue(u_fxWidthByAngle, fAngle);

		float fDistToCamera = length(vPosEye.xyz);
		float fWidthByDistance = GetGrowingValue(u_fxWidthByDistance, fDistToCamera);
		vPos.xyz += (fWidthByAngle*fWidthByDistance + u_fWidth)*vShift;
	//}
	//else
	//{	
	//	vPos.xyz += u_fWidth*vShift;
	//}
	
	gl_Position = hu_mPMVMatrix*vPos;
}
