diff --git a/Shader/phong.fsh b/Shader/phong.fsh index 8e2b5f5..61b8426 100644 --- a/Shader/phong.fsh +++ b/Shader/phong.fsh @@ -2,6 +2,7 @@ in vec3 vNormal; in vec2 vTexCoord; +in vec4 fragPosition; out vec4 oColor; @@ -11,13 +12,15 @@ uniform vec3 lightSources[128]; uniform vec3 ambientColor; uniform float ambientFactor; uniform vec3 lightColors[128]; -uniform float diffuseFactor; +uniform float lightIntensities[128]; void main() { vec3 ambientColor = ambientFactor * ambientColor; vec3 diffuseColor = vec3(0.0, 0.0, 0.0); for(int i = 0; isetUniform("ambientColor", level.getAmbientLight()); shader.getReference()->setUniform("ambientFactor", 1.0f); if (level.getLights().size() > 0) { - shader.getReference()->setUniform("diffuseFactor", 0.7f); shader.getReference()->setUniform("lightCount", (int) level.getLights().size()); // TODO look into doing this less often @@ -70,6 +69,13 @@ void draw( float runTime ) } glUniform3fv(shader.getReference()->getUniformLocation("lightColors"), sizeof(lightColours), (GLfloat*) lightColours); + // Build light attenuation array + float lightIntensities[level.getLights().size()]; + for(int i = 0; igetUniformLocation("lightIntensities"), + sizeof(lightIntensities), (GLfloat*) lightIntensities); } // render the level(currently only a bunny):