=== modified file 'data/shaders/light-advanced.frag'
@@ -4,6 +4,7 @@
uniform vec3 MaterialAmbient;
uniform vec3 MaterialDiffuse;
uniform vec3 MaterialSpecular;
+uniform vec3 MaterialColor;
varying vec3 Normal;
varying vec3 Light;
@@ -27,5 +28,5 @@
// Calculate the final color
gl_FragColor = vec4(ambient, 1.0) + vec4(specular, 1.0) +
- vec4(diffuse, 1.0) * vec4(0.0, 0.0, 1.0, 1.0);
+ vec4(diffuse, 1.0) * vec4(MaterialColor, 1.0);
}
=== modified file 'data/shaders/light-basic.vert'
@@ -5,8 +5,7 @@
uniform mat4 ModelViewProjectionMatrix;
uniform mat4 NormalMatrix;
uniform vec4 LightSourcePosition;
-uniform vec3 LightSourceDiffuse;
-uniform vec3 MaterialDiffuse;
+uniform vec3 MaterialColor;
varying vec4 Color;
@@ -21,7 +20,7 @@
// Multiply the diffuse value by the vertex color (which is fixed in this case)
// to get the actual color that we will use to draw this vertex with
float diffuse = max(dot(N, L), 0.0);
- Color = diffuse * vec4(0.0, 0.0, 1.0, 1.0);
+ Color = diffuse * vec4(MaterialColor, 1.0);
// Transform the position to clip coordinates
gl_Position = ModelViewProjectionMatrix * vec4(position, 1.0);
=== modified file 'scenebuild.cpp'
@@ -49,6 +49,7 @@
GLfloat lightAmbient[] = {0.0f, 0.0f, 0.0f, 1.0f};
GLfloat lightDiffuse[] = {0.8f, 0.8f, 0.8f, 1.0f};
GLfloat lightPosition[] = {20.0f, 20.0f, 10.0f, 1.0f};
+ GLfloat materialColor[] = {1.0f, 1.0f, 1.0f, 1.0f};
mShader.use();
@@ -58,6 +59,8 @@
glUniform3fv(mShader.mLocations.LightSourceAmbient, 1, lightAmbient);
glUniform3fv(mShader.mLocations.LightSourceDiffuse, 1, lightDiffuse);
+ glUniform3fv(mShader.mLocations.MaterialColor, 1, materialColor);
+
mCurrentFrame = 0;
mRunning = true;
mStartTime = SDL_GetTicks() / 1000.0;
=== modified file 'sceneshading.cpp'
@@ -54,9 +54,10 @@
GLfloat lightSpecular[] = {0.8f, 0.8f, 0.8f, 1.0f};
GLfloat lightPosition[] = {20.0f, 20.0f, 10.0f, 1.0f};
- float mat_ambient[] = {1.0f, 1.0f, 1.0f, 1.0f};
- float mat_diffuse[] = {1.0f, 1.0f, 1.0f, 1.0f};
- float mat_specular[] = {1.0f, 1.0f, 1.0f, 1.0f};
+ float materialAmbient[] = {1.0f, 1.0f, 1.0f, 1.0f};
+ float materialDiffuse[] = {1.0f, 1.0f, 1.0f, 1.0f};
+ float materialSpecular[] = {1.0f, 1.0f, 1.0f, 1.0f};
+ float materialColor[] = {0.0f, 0.0f, 1.0f, 1.0f};
switch(mCurrentPart)
{
@@ -77,9 +78,10 @@
glUniform3fv(mShader[mCurrentPart].mLocations.LightSourceDiffuse, 1, lightDiffuse);
glUniform3fv(mShader[mCurrentPart].mLocations.LightSourceSpecular, 1, lightSpecular);
- glUniform3fv(mShader[mCurrentPart].mLocations.MaterialAmbient, 1, mat_ambient);
- glUniform3fv(mShader[mCurrentPart].mLocations.MaterialDiffuse, 1, mat_diffuse);
- glUniform3fv(mShader[mCurrentPart].mLocations.MaterialSpecular, 1, mat_specular);
+ glUniform3fv(mShader[mCurrentPart].mLocations.MaterialAmbient, 1, materialAmbient);
+ glUniform3fv(mShader[mCurrentPart].mLocations.MaterialDiffuse, 1, materialDiffuse);
+ glUniform3fv(mShader[mCurrentPart].mLocations.MaterialSpecular, 1, materialSpecular);
+ glUniform3fv(mShader[mCurrentPart].mLocations.MaterialColor, 1, materialColor);
// Calculate and load the half vector
Vector3f halfVector = Vector3f(lightPosition[0], lightPosition[1], lightPosition[2]);
=== modified file 'shader.cpp'
@@ -95,9 +95,11 @@
"MaterialDiffuse");
mLocations.MaterialSpecular = glGetUniformLocation(mShaderProgram,
"MaterialSpecular");
+ mLocations.MaterialColor = glGetUniformLocation(mShaderProgram,
+ "MaterialColor");
#ifdef _DEBUG
- printf("Uniform Locations: %d %d %d %d %d %d %d %d\n",
+ printf("Uniform Locations: %d %d %d %d %d %d %d %d %d %d %d\n",
mLocations.ModelViewProjectionMatrix,
mLocations.NormalMatrix,
mLocations.LightSourcePosition,
@@ -107,7 +109,8 @@
mLocations.LightSourceSpecular,
mLocations.MaterialAmbient,
mLocations.MaterialDiffuse,
- mLocations.MaterialSpecular);
+ mLocations.MaterialSpecular,
+ mLocations.MaterialColor);
#endif
}
=== modified file 'shader.h'
@@ -28,6 +28,7 @@
GLint MaterialAmbient;
GLint MaterialDiffuse;
GLint MaterialSpecular;
+ GLint MaterialColor;
} mLocations;
enum {