Saxum/Shader/phong.fsh

28 lines
700 B
Plaintext
Raw Normal View History

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;
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()
{
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;
}
vec3 finalColor = diffuseColor + ambientColor;
2014-10-20 15:31:26 +00:00
vec3 texture = texture(uTexture, vTexCoord).rgb;
oColor = vec4(finalColor*texture, 1.0 );
2014-10-20 15:31:26 +00:00
}