diff mbox

[Branch,~glmark2-dev/glmark2/trunk] Rev 28: Add MaterialColor uniform to shaders.

Message ID 20110721123631.17019.98686.launchpad@loganberry.canonical.com
State Accepted
Headers show

Commit Message

Alexandros Frantzis July 21, 2011, 12:36 p.m. UTC
------------------------------------------------------------
revno: 28
committer: Alexandros Frantzis <alf82@freemail.gr>
timestamp: Fri 2010-07-09 13:28:57 +0300
message:
  Add MaterialColor uniform to shaders.
modified:
  data/shaders/light-advanced.frag
  data/shaders/light-basic.vert
  scenebuild.cpp
  sceneshading.cpp
  shader.cpp
  shader.h


--
lp:glmark2
https://code.launchpad.net/~glmark2-dev/glmark2/trunk

You are subscribed to branch lp:glmark2.
To unsubscribe from this branch go to https://code.launchpad.net/~glmark2-dev/glmark2/trunk/+edit-subscription
diff mbox

Patch

=== modified file 'data/shaders/light-advanced.frag'
--- data/shaders/light-advanced.frag	2010-07-09 09:48:40 +0000
+++ data/shaders/light-advanced.frag	2010-07-09 10:28:57 +0000
@@ -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'
--- data/shaders/light-basic.vert	2010-07-08 15:48:22 +0000
+++ data/shaders/light-basic.vert	2010-07-09 10:28:57 +0000
@@ -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'
--- scenebuild.cpp	2010-07-09 10:16:27 +0000
+++ scenebuild.cpp	2010-07-09 10:28:57 +0000
@@ -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'
--- sceneshading.cpp	2010-07-09 09:48:40 +0000
+++ sceneshading.cpp	2010-07-09 10:28:57 +0000
@@ -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'
--- shader.cpp	2010-07-09 09:43:26 +0000
+++ shader.cpp	2010-07-09 10:28:57 +0000
@@ -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'
--- shader.h	2010-07-09 09:43:26 +0000
+++ shader.h	2010-07-09 10:28:57 +0000
@@ -28,6 +28,7 @@ 
         GLint MaterialAmbient;
         GLint MaterialDiffuse;
         GLint MaterialSpecular;
+        GLint MaterialColor;
     } mLocations;
 
     enum {