From patchwork Thu Jul 21 12:36:31 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alexandros Frantzis X-Patchwork-Id: 2957 Return-Path: X-Original-To: patchwork@peony.canonical.com Delivered-To: patchwork@peony.canonical.com Received: from fiordland.canonical.com (fiordland.canonical.com [91.189.94.145]) by peony.canonical.com (Postfix) with ESMTP id 1634823F4D for ; Thu, 21 Jul 2011 12:42:55 +0000 (UTC) Received: from mail-qw0-f52.google.com (mail-qw0-f52.google.com [209.85.216.52]) by fiordland.canonical.com (Postfix) with ESMTP id D8DE1A184F2 for ; Thu, 21 Jul 2011 12:42:54 +0000 (UTC) Received: by mail-qw0-f52.google.com with SMTP id 8so853237qwb.11 for ; Thu, 21 Jul 2011 05:42:54 -0700 (PDT) Received: by 10.224.96.6 with SMTP id f6mr188745qan.12.1311252174231; Thu, 21 Jul 2011 05:42:54 -0700 (PDT) X-Forwarded-To: linaro-patchwork@canonical.com X-Forwarded-For: patch@linaro.org linaro-patchwork@canonical.com Delivered-To: patches@linaro.org Received: by 10.229.217.78 with SMTP id hl14cs139517qcb; Thu, 21 Jul 2011 05:42:54 -0700 (PDT) Received: by 10.216.137.92 with SMTP id x70mr726596wei.62.1311251795744; Thu, 21 Jul 2011 05:36:35 -0700 (PDT) Received: from adelie.canonical.com (adelie.canonical.com [91.189.90.139]) by mx.google.com with ESMTP id l18si2388363wed.64.2011.07.21.05.36.35; Thu, 21 Jul 2011 05:36:35 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of bounces@canonical.com designates 91.189.90.139 as permitted sender) client-ip=91.189.90.139; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of bounces@canonical.com designates 91.189.90.139 as permitted sender) smtp.mail=bounces@canonical.com Received: from loganberry.canonical.com ([91.189.90.37]) by adelie.canonical.com with esmtp (Exim 4.71 #1 (Debian)) id 1QjsUT-0000Cf-FS for ; Thu, 21 Jul 2011 12:36:33 +0000 Received: from loganberry.canonical.com (localhost [127.0.0.1]) by loganberry.canonical.com (Postfix) with ESMTP id E61ED2E889C for ; Thu, 21 Jul 2011 12:36:31 +0000 (UTC) MIME-Version: 1.0 X-Launchpad-Project: glmark2 X-Launchpad-Branch: ~glmark2-dev/glmark2/trunk X-Launchpad-Message-Rationale: Subscriber X-Launchpad-Branch-Revision-Number: 28 X-Launchpad-Notification-Type: branch-revision To: Linaro Patch Tracker From: noreply@launchpad.net Subject: [Branch ~glmark2-dev/glmark2/trunk] Rev 28: Add MaterialColor uniform to shaders. Message-Id: <20110721123631.17019.98686.launchpad@loganberry.canonical.com> Date: Thu, 21 Jul 2011 12:36:31 -0000 Reply-To: noreply@launchpad.net Sender: bounces@canonical.com Errors-To: bounces@canonical.com Precedence: bulk X-Generated-By: Launchpad (canonical.com); Revision="13475"; Instance="initZopeless config overlay" X-Launchpad-Hash: 95cb6e7e3d36a1d80509771a3b3f3702dc8d90be ------------------------------------------------------------ revno: 28 committer: Alexandros Frantzis 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 === 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 {