From patchwork Tue Aug 23 14:54:12 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jesse Barker X-Patchwork-Id: 3629 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 C748823F36 for ; Tue, 23 Aug 2011 14:54:15 +0000 (UTC) Received: from mail-bw0-f52.google.com (mail-bw0-f52.google.com [209.85.214.52]) by fiordland.canonical.com (Postfix) with ESMTP id B517FA18783 for ; Tue, 23 Aug 2011 14:54:15 +0000 (UTC) Received: by mail-bw0-f52.google.com with SMTP id zs2so235097bkb.11 for ; Tue, 23 Aug 2011 07:54:15 -0700 (PDT) Received: by 10.204.146.140 with SMTP id h12mr1539849bkv.226.1314111255496; Tue, 23 Aug 2011 07:54:15 -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.204.41.75 with SMTP id n11cs213996bke; Tue, 23 Aug 2011 07:54:15 -0700 (PDT) Received: by 10.227.32.74 with SMTP id b10mr369595wbd.33.1314111253325; Tue, 23 Aug 2011 07:54:13 -0700 (PDT) Received: from indium.canonical.com (indium.canonical.com [91.189.90.7]) by mx.google.com with ESMTPS id p14si122220wbh.70.2011.08.23.07.54.13 (version=TLSv1/SSLv3 cipher=OTHER); Tue, 23 Aug 2011 07:54:13 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of bounces@canonical.com designates 91.189.90.7 as permitted sender) client-ip=91.189.90.7; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of bounces@canonical.com designates 91.189.90.7 as permitted sender) smtp.mail=bounces@canonical.com Received: from ackee.canonical.com ([91.189.89.26]) by indium.canonical.com with esmtp (Exim 4.71 #1 (Debian)) id 1QvsMm-0005xw-Sd for ; Tue, 23 Aug 2011 14:54:12 +0000 Received: from ackee.canonical.com (localhost [127.0.0.1]) by ackee.canonical.com (Postfix) with ESMTP id CB6E7E0191 for ; Tue, 23 Aug 2011 14:54:12 +0000 (UTC) MIME-Version: 1.0 X-Launchpad-Project: glcompbench X-Launchpad-Branch: ~glcompbench-dev/glcompbench/trunk X-Launchpad-Message-Rationale: Subscriber X-Launchpad-Branch-Revision-Number: 55 X-Launchpad-Notification-Type: branch-revision To: Linaro Patch Tracker From: noreply@launchpad.net Subject: [Branch ~glcompbench-dev/glcompbench/trunk] Rev 55: Update the brick shaders to avoid conditionals and extra function calls. Message-Id: <20110823145412.567.73997.launchpad@ackee.canonical.com> Date: Tue, 23 Aug 2011 14:54:12 -0000 Reply-To: noreply@launchpad.net Sender: bounces@canonical.com Errors-To: bounces@canonical.com Precedence: bulk X-Generated-By: Launchpad (canonical.com); Revision="13714"; Instance="initZopeless config overlay" X-Launchpad-Hash: 047de62ff80df44180cc6e92bea68384bc36b19f ------------------------------------------------------------ revno: 55 committer: Jesse Barker branch nick: brick2 timestamp: Fri 2011-07-29 13:28:24 -0700 message: Update the brick shaders to avoid conditionals and extra function calls. modified: data/brick.frag data/brick.vert --- lp:glcompbench https://code.launchpad.net/~glcompbench-dev/glcompbench/trunk You are subscribed to branch lp:glcompbench. To unsubscribe from this branch go to https://code.launchpad.net/~glcompbench-dev/glcompbench/trunk/+edit-subscription === modified file 'data/brick.frag' --- data/brick.frag 2011-07-18 17:14:16 +0000 +++ data/brick.frag 2011-07-29 20:28:24 +0000 @@ -8,20 +8,8 @@ varying vec2 TextureCoord; varying vec4 vertex_position; -varying vec3 eye_direction; varying vec4 light_position; -vec3 unitvec(vec4 v1, vec4 v2) -{ - if (v1.w == 0.0 && v2.w == 0.0) - return vec3(v2 - v1); - if (v1.w == 0.0) - return vec3(-v1); - if (v2.w == 0.0) - return vec3(v2); - return v2.xyz/v2.w - v1.xyz/v1.w; -} - void main() { vec4 texel = texture2D(Texture0, TextureCoord); @@ -31,12 +19,9 @@ position.x += 0.5; } position = fract(position); - vec3 vertex_normal = vec3(0.0, 0.0, 1.0); vec2 one = vec2(1.0, 1.0); vec2 whereami = smoothstep(BrickPct, one, position); - bvec2 inmortar = bvec2(whereami); - - + vec3 vertex_normal = vec3(0.0, 0.0, 1.0); if (whereami.x > 0.0 && whereami.x < 0.5) vertex_normal.x = (2.0 * pow(whereami.x, 2.0)) + 0.1; else if (whereami.x > 0.0 && whereami.x < 1.0) @@ -51,8 +36,9 @@ vec4 matAmbient = vec4(0.1, 0.1, 0.1, 1.0); vec4 matDiffuse = vec4(texel.xyz, 0.5); vec4 matSpecular = vec4(1.0, 1.0, 1.0, 1.0); - float matShininess = 30.0; - vec3 light_direction = normalize(unitvec(vertex_position, light_position)); + float matShininess = 10.0; + vec3 eye_direction = normalize(-vertex_position.xyz); + vec3 light_direction = normalize(light_position.xyz); vec3 normalized_normal = normalize(vertex_normal); vec3 reflection = reflect(-light_direction, normalized_normal); float specularTerm = pow(max(0.0, dot(reflection, eye_direction)), matShininess); === modified file 'data/brick.vert' --- data/brick.vert 2011-07-18 17:14:16 +0000 +++ data/brick.vert 2011-07-29 20:28:24 +0000 @@ -9,21 +9,9 @@ attribute vec2 texcoord; varying vec4 vertex_position; -varying vec3 eye_direction; varying vec4 light_position; varying vec2 TextureCoord; -vec3 unitvec(vec4 v1, vec4 v2) -{ - if (v1.w == 0.0 && v2.w == 0.0) - return vec3(v2 - v1); - if (v1.w == 0.0) - return vec3(-v1); - if (v2.w == 0.0) - return vec3(v2); - return v2.xyz/v2.w - v1.xyz/v1.w; -} - void main() { vec4 curVertex = vec4(position.x, position.y, position.z, 1.0); @@ -31,5 +19,4 @@ TextureCoord = texcoord; light_position = modelview * LightPosition; vertex_position = modelview * curVertex; - eye_direction = normalize(unitvec(vertex_position, vec4(0.0, 0.0, 0.0, 1.0))); }