From patchwork Mon Sep 5 14:20:13 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: alexandros.frantzis@linaro.org X-Patchwork-Id: 3866 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 5962523EF5 for ; Mon, 5 Sep 2011 14:20:15 +0000 (UTC) Received: from mail-fx0-f52.google.com (mail-fx0-f52.google.com [209.85.161.52]) by fiordland.canonical.com (Postfix) with ESMTP id 4E1AFA1840F for ; Mon, 5 Sep 2011 14:20:15 +0000 (UTC) Received: by mail-fx0-f52.google.com with SMTP id 18so5166240fxd.11 for ; Mon, 05 Sep 2011 07:20:15 -0700 (PDT) Received: by 10.223.22.16 with SMTP id l16mr1371268fab.62.1315232415198; Mon, 05 Sep 2011 07:20: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.152.11.8 with SMTP id m8cs64739lab; Mon, 5 Sep 2011 07:20:14 -0700 (PDT) Received: by 10.227.209.21 with SMTP id ge21mr4047479wbb.42.1315232413701; Mon, 05 Sep 2011 07:20:13 -0700 (PDT) Received: from indium.canonical.com (indium.canonical.com [91.189.90.7]) by mx.google.com with ESMTPS id ev1si6111310wbb.127.2011.09.05.07.20.13 (version=TLSv1/SSLv3 cipher=OTHER); Mon, 05 Sep 2011 07:20: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 1R0a21-0002Ub-5x for ; Mon, 05 Sep 2011 14:20:13 +0000 Received: from ackee.canonical.com (localhost [127.0.0.1]) by ackee.canonical.com (Postfix) with ESMTP id 1FFBBE003F for ; Mon, 5 Sep 2011 14:20:13 +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: 59 X-Launchpad-Notification-Type: branch-revision To: Linaro Patch Tracker From: noreply@launchpad.net Subject: [Branch ~glcompbench-dev/glcompbench/trunk] Rev 59: Update the brick shaders to avoid conditionals and extra function calls. Message-Id: <20110905142013.21285.32586.launchpad@ackee.canonical.com> Date: Mon, 05 Sep 2011 14:20:13 -0000 Reply-To: noreply@launchpad.net Sender: bounces@canonical.com Errors-To: bounces@canonical.com Precedence: bulk X-Generated-By: Launchpad (canonical.com); Revision="13830"; Instance="initZopeless config overlay" X-Launchpad-Hash: 454e51cddc5cb3b40a0bced8577456639f48b5d8 ------------------------------------------------------------ revno: 59 author: Jesse Barker committer: Alexandros Frantzis 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))); }