2014-01-03 16:46:41 +00:00
|
|
|
#version 330
|
2014-01-02 02:35:38 +00:00
|
|
|
|
2014-01-03 02:01:54 +00:00
|
|
|
//constant projection matrix
|
2014-01-02 02:35:38 +00:00
|
|
|
uniform mat4 fg_ProjectionMatrix;
|
2014-01-05 18:09:01 +00:00
|
|
|
uniform mat4 fg_ViewMatrix;
|
|
|
|
uniform mat3 fg_NormalMatrix;
|
2014-01-02 02:35:38 +00:00
|
|
|
|
2014-01-03 02:01:54 +00:00
|
|
|
//vertex-data
|
2014-01-02 02:35:38 +00:00
|
|
|
in vec4 fg_Color;
|
2014-01-03 16:46:41 +00:00
|
|
|
in vec3 fg_VertexIn;
|
2014-01-04 15:55:59 +00:00
|
|
|
in vec3 fg_NormalIn;
|
2014-01-02 02:35:38 +00:00
|
|
|
|
2014-01-03 02:01:54 +00:00
|
|
|
//output-data for later stages
|
2014-01-05 18:13:27 +00:00
|
|
|
smooth out vec4 fg_SmoothColor;
|
2014-01-02 02:35:38 +00:00
|
|
|
|
|
|
|
void main()
|
|
|
|
{
|
2014-01-04 15:55:59 +00:00
|
|
|
vec3 fg_Normal = fg_NormalIn; //vec3(0,1,0);
|
2014-01-03 16:46:41 +00:00
|
|
|
//transform vec3 into vec4, setting w to 1
|
|
|
|
vec4 fg_Vertex = vec4(fg_VertexIn, 1.0);
|
2014-01-04 15:55:59 +00:00
|
|
|
vec4 light = vec4(1.0,1.0,1.0,1.0);
|
|
|
|
vec4 dark = vec4(0.0,0.0,0.0,1.0);
|
|
|
|
//direction to sun from origin
|
|
|
|
vec3 lightDir = normalize(vec3(5.0,5.0,1.0));
|
2014-01-05 18:09:01 +00:00
|
|
|
|
|
|
|
|
2014-01-04 15:55:59 +00:00
|
|
|
float costheta = dot(normalize(fg_Normal), lightDir);
|
|
|
|
float a = costheta * 0.5 + 0.5;
|
2014-01-05 18:09:01 +00:00
|
|
|
|
2014-01-04 15:55:59 +00:00
|
|
|
fg_SmoothColor = fg_Color * mix(dark, light, a);// + 0.001* fg_Normal.xyzx;
|
2014-01-05 18:09:01 +00:00
|
|
|
gl_Position = fg_ProjectionMatrix * fg_ViewMatrix * fg_Vertex;
|
2014-01-02 02:35:38 +00:00
|
|
|
}
|