#version 130 out vec4 outpix; uniform vec3 campos; uniform vec3 lightpos; uniform sampler2D tex; uniform sampler2D elev; //varing blends them it is transformed to world space varying vec4 fragpos; varying vec4 fragnormal; varying vec2 fragtexcoord; void main() { vec4 elevpix = texture(elev, fragtexcoord); vec3 lightnormal = normalize((lightpos - vec3(fragpos.x, fragpos.y, fragpos.z))); float diffuse = dot(lightnormal, vec3(fragnormal.x, fragnormal.y, fragnormal.z)); if (diffuse < 0.0) { diffuse = 0.0; } vec3 camnormal = normalize(campos - vec3(fragpos.x, fragpos.y, fragpos.z)); float reflect = dot(camnormal, fragnormal.xyz); diffuse = pow(diffuse, 2.0); reflect = pow(reflect, 2.0); float light = .4 * reflect + .6 * diffuse; vec4 texpix = texture(tex, fragtexcoord); //this should be the vertex in camera space without the w value //outpix = gl_FragCoord; outpix = texpix; //outpix = vec4(light * 1.0,light * 1.0,light * 1.0, 1.0); //outpix = vec4(fragpos.x ,fragpos.y ,fragpos.z, 0.5); //outpix = vec4(fragnormal.x, fragnormal.y, fragnormal.z, 0.5); }