added shading, reduced debug-output

This commit is contained in:
Stefan Dresselhaus
2014-08-24 23:47:17 +02:00
parent c21863c03a
commit 581cb142bb
6 changed files with 28 additions and 15 deletions

View File

@ -5,6 +5,17 @@ in vec3 vNormal;
out vec4 fgColor;
uniform mat4 ViewMatrix;
void main () {
fgColor = vec4(1.0,0.0,1.0,0.5);
//heliospheric lighting
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(ViewMatrix * vec4(5.0,5.0,1.0,0.0)).xyz;
float costheta = dot(vNormal, lightDir);
float a = costheta * 0.5 + 0.5;
fgColor = vec4(0.5,0.5,0.5,1)*mix(dark,light,a);
}

View File

@ -6,7 +6,7 @@ layout(location=2) in vec2 TexCoord;
uniform mat4 ProjectionMatrix;
uniform mat4 ViewMatrix;
uniform mat3 NormalMatrix;
uniform vec3 PositionOffset = vec3(5,5,5);
uniform vec3 PositionOffset = vec3(5,2,5);
uniform float TessLevelInner = 1.0; // controlled by keyboard buttons
uniform float TessLevelOuter = 1.0; // controlled by keyboard buttons
@ -15,6 +15,7 @@ out vec3 vNormal;
void main () {
vPosition = Position;
gl_Position = vec4(Position,1);//ProjectionMatrix * ViewMatrix * vec4(PositionOffset + Position, 1);
//gl_Position = vec4(Position,1);
gl_Position = ProjectionMatrix * ViewMatrix * vec4(PositionOffset + Position, 1);
vNormal = Normal;
}