2014-10-20 15:31:26 +00:00
|
|
|
#version 150
|
|
|
|
|
|
|
|
in vec3 vNormal;
|
|
|
|
in vec2 vTexCoord;
|
|
|
|
|
|
|
|
out vec4 oColor;
|
|
|
|
|
|
|
|
uniform sampler2D uTexture;
|
2014-10-31 11:56:09 +00:00
|
|
|
uniform int lightCount;
|
2014-10-31 09:38:57 +00:00
|
|
|
uniform vec3 lightSources[128];
|
|
|
|
uniform vec3 ambientIntensity;
|
|
|
|
uniform float ambientFactor;
|
|
|
|
uniform vec3 diffuseIntensity;
|
|
|
|
uniform float diffuseFactor;
|
2014-10-20 15:31:26 +00:00
|
|
|
|
|
|
|
void main()
|
2014-10-31 09:38:57 +00:00
|
|
|
{
|
|
|
|
vec3 ambientColor = ambientFactor * ambientIntensity;
|
2014-10-31 11:56:09 +00:00
|
|
|
vec3 diffuseColor = vec3(0.0, 0.0, 0.0);
|
|
|
|
for(int i = 0; i<lightCount; i++) {
|
|
|
|
diffuseColor += dot(normalize(vNormal), normalize(lightSources[i]))*diffuseFactor*diffuseIntensity;
|
|
|
|
}
|
2014-10-31 09:38:57 +00:00
|
|
|
vec3 finalColor = diffuseColor + ambientColor;
|
2014-10-20 15:31:26 +00:00
|
|
|
|
2014-10-31 09:38:57 +00:00
|
|
|
vec3 texture = texture(uTexture, vTexCoord).rgb;
|
|
|
|
oColor = vec4(finalColor*texture, 1.0 );
|
2014-10-20 15:31:26 +00:00
|
|
|
}
|