From patchwork Tue Oct 11 09:58:12 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: alexandros.frantzis@linaro.org X-Patchwork-Id: 4615 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 8BB6723EF7 for ; Tue, 11 Oct 2011 09:58:18 +0000 (UTC) Received: from mail-wy0-f180.google.com (mail-wy0-f180.google.com [74.125.82.180]) by fiordland.canonical.com (Postfix) with ESMTP id 8046BA18301 for ; Tue, 11 Oct 2011 09:58:18 +0000 (UTC) Received: by mail-wy0-f180.google.com with SMTP id 11so9589200wyh.11 for ; Tue, 11 Oct 2011 02:58:18 -0700 (PDT) Received: by 10.223.85.139 with SMTP id o11mr38615112fal.0.1318327098336; Tue, 11 Oct 2011 02:58:18 -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.24.41 with SMTP id r9cs152057laf; Tue, 11 Oct 2011 02:58:17 -0700 (PDT) Received: by 10.227.134.145 with SMTP id j17mr6222640wbt.79.1318327093374; Tue, 11 Oct 2011 02:58:13 -0700 (PDT) Received: from indium.canonical.com (indium.canonical.com. [91.189.90.7]) by mx.google.com with ESMTPS id 13si15717123wbw.138.2011.10.11.02.58.13 (version=TLSv1/SSLv3 cipher=OTHER); Tue, 11 Oct 2011 02:58: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 1RDZ6C-0008GI-R0 for ; Tue, 11 Oct 2011 09:58:12 +0000 Received: from ackee.canonical.com (localhost [127.0.0.1]) by ackee.canonical.com (Postfix) with ESMTP id C0FAFE01FB for ; Tue, 11 Oct 2011 09:58:12 +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: 151 X-Launchpad-Notification-Type: branch-revision To: Linaro Patch Tracker From: noreply@launchpad.net Subject: [Branch ~glmark2-dev/glmark2/trunk] Rev 151: Shaders: Convert all shader files to unix file format (LF line endings). Message-Id: <20111011095812.12535.76056.launchpad@ackee.canonical.com> Date: Tue, 11 Oct 2011 09:58: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="14124"; Instance="launchpad-lazr.conf" X-Launchpad-Hash: 77a4a5ce04cdfff051eb9bf99bf634e3db0ebd24 ------------------------------------------------------------ revno: 151 committer: Alexandros Frantzis branch nick: trunk timestamp: Tue 2011-10-11 12:51:17 +0300 message: Shaders: Convert all shader files to unix file format (LF line endings). modified: data/shaders/buffer-wireframe.frag data/shaders/buffer-wireframe.vert data/shaders/bump-normals.frag data/shaders/bump-normals.vert data/shaders/bump-poly.frag data/shaders/bump-poly.vert data/shaders/desktop.vert data/shaders/effect-2d.vert data/shaders/light-advanced.frag data/shaders/light-advanced.vert data/shaders/light-basic.frag data/shaders/light-basic.vert data/shaders/light-phong.frag data/shaders/light-phong.vert data/shaders/pulsar-light.vert data/shaders/pulsar.vert --- 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/buffer-wireframe.frag' --- data/shaders/buffer-wireframe.frag 2011-10-08 12:31:31 +0000 +++ data/shaders/buffer-wireframe.frag 2011-10-11 09:51:17 +0000 @@ -1,17 +1,17 @@ -varying vec4 dist; - -const vec4 LINE_COLOR = vec4(1.0); -const vec4 TRIANGLE_COLOR = vec4(0.0, 0.5, 0.8, 0.8); - -void main(void) -{ - // Get the minimum distance of this fragment from a triangle edge. - // We need to multiply with dist.w to undo the workaround we had - // to perform to get linear interpolation (instead of perspective correct). - float d = min(dist.x * dist.w, min(dist.y * dist.w, dist.z * dist.w)); - - // Get the intensity of the wireframe line - float I = exp2(-2.0 * d * d); - - gl_FragColor = mix(TRIANGLE_COLOR, LINE_COLOR, I); -} +varying vec4 dist; + +const vec4 LINE_COLOR = vec4(1.0); +const vec4 TRIANGLE_COLOR = vec4(0.0, 0.5, 0.8, 0.8); + +void main(void) +{ + // Get the minimum distance of this fragment from a triangle edge. + // We need to multiply with dist.w to undo the workaround we had + // to perform to get linear interpolation (instead of perspective correct). + float d = min(dist.x * dist.w, min(dist.y * dist.w, dist.z * dist.w)); + + // Get the intensity of the wireframe line + float I = exp2(-2.0 * d * d); + + gl_FragColor = mix(TRIANGLE_COLOR, LINE_COLOR, I); +} === modified file 'data/shaders/buffer-wireframe.vert' --- data/shaders/buffer-wireframe.vert 2011-10-05 16:42:33 +0000 +++ data/shaders/buffer-wireframe.vert 2011-10-11 09:51:17 +0000 @@ -1,57 +1,57 @@ -// Wireframe shader based on: -// J. A. Bærentzen, S. Munk-Lund, M. Gjøl, and B. D. Larsen, -// “Two methods for antialiased wireframe drawing with hidden -// line removal,” in Proceedings of the Spring Conference in -// Computer Graphics, 2008. -// -// We are not using geometry shaders, though, as they are not -// available in GLES 2.0. - -attribute vec3 position; -// Coordinates of the triangle vertices this vertex belongs to -attribute vec3 tvertex0; -attribute vec3 tvertex1; -attribute vec3 tvertex2; - -uniform vec2 Viewport; -uniform mat4 ModelViewProjectionMatrix; - -varying vec4 dist; - -void main(void) -{ - // Get the clip coordinates of all vertices - vec4 pos = ModelViewProjectionMatrix * vec4(position, 1.0); - vec4 pos0 = ModelViewProjectionMatrix * vec4(tvertex0, 1.0); - vec4 pos1 = ModelViewProjectionMatrix * vec4(tvertex1, 1.0); - vec4 pos2 = ModelViewProjectionMatrix * vec4(tvertex2, 1.0); - - // Get the screen coordinates of all vertices - vec3 p = vec3(0.5 * Viewport * (pos.xy / pos.w), 0.0); - vec3 p0 = vec3(0.5 * Viewport * (pos0.xy / pos0.w), 0.0); - vec3 p1 = vec3(0.5 * Viewport * (pos1.xy / pos1.w), 0.0); - vec3 p2 = vec3(0.5 * Viewport * (pos2.xy / pos2.w), 0.0); - - // Get the vectors representing the edges of the current - // triangle primitive. 'vN' is the edge opposite vertex N. - vec3 v0 = p2 - p1; - vec3 v1 = p2 - p0; - vec3 v2 = p1 - p0; - - // Calculate the distance of the current vertex from all - // the triangle edges. The distance of point p from line - // v is length(cross(p - p1, v)) / length(v), where - // p1 is any of the two edge points of v. - float d0 = length(cross(p - p1, v0)) / length(v0); - float d1 = length(cross(p - p2, v1)) / length(v1); - float d2 = length(cross(p - p0, v2)) / length(v2); - - // OpenGL(ES) performs perspective-correct interpolation - // (it divides by .w) but we want linear interpolation. To - // work around this, we premultiply by pos.w here and then - // multiple with the inverse (stored in dist.w) in the fragment - // shader to undo this operation. - dist = vec4(pos.w * d0, pos.w * d1, pos.w * d2, 1.0 / pos.w); - - gl_Position = pos; -} +// Wireframe shader based on: +// J. A. Bærentzen, S. Munk-Lund, M. Gjøl, and B. D. Larsen, +// “Two methods for antialiased wireframe drawing with hidden +// line removal,” in Proceedings of the Spring Conference in +// Computer Graphics, 2008. +// +// We are not using geometry shaders, though, as they are not +// available in GLES 2.0. + +attribute vec3 position; +// Coordinates of the triangle vertices this vertex belongs to +attribute vec3 tvertex0; +attribute vec3 tvertex1; +attribute vec3 tvertex2; + +uniform vec2 Viewport; +uniform mat4 ModelViewProjectionMatrix; + +varying vec4 dist; + +void main(void) +{ + // Get the clip coordinates of all vertices + vec4 pos = ModelViewProjectionMatrix * vec4(position, 1.0); + vec4 pos0 = ModelViewProjectionMatrix * vec4(tvertex0, 1.0); + vec4 pos1 = ModelViewProjectionMatrix * vec4(tvertex1, 1.0); + vec4 pos2 = ModelViewProjectionMatrix * vec4(tvertex2, 1.0); + + // Get the screen coordinates of all vertices + vec3 p = vec3(0.5 * Viewport * (pos.xy / pos.w), 0.0); + vec3 p0 = vec3(0.5 * Viewport * (pos0.xy / pos0.w), 0.0); + vec3 p1 = vec3(0.5 * Viewport * (pos1.xy / pos1.w), 0.0); + vec3 p2 = vec3(0.5 * Viewport * (pos2.xy / pos2.w), 0.0); + + // Get the vectors representing the edges of the current + // triangle primitive. 'vN' is the edge opposite vertex N. + vec3 v0 = p2 - p1; + vec3 v1 = p2 - p0; + vec3 v2 = p1 - p0; + + // Calculate the distance of the current vertex from all + // the triangle edges. The distance of point p from line + // v is length(cross(p - p1, v)) / length(v), where + // p1 is any of the two edge points of v. + float d0 = length(cross(p - p1, v0)) / length(v0); + float d1 = length(cross(p - p2, v1)) / length(v1); + float d2 = length(cross(p - p0, v2)) / length(v2); + + // OpenGL(ES) performs perspective-correct interpolation + // (it divides by .w) but we want linear interpolation. To + // work around this, we premultiply by pos.w here and then + // multiple with the inverse (stored in dist.w) in the fragment + // shader to undo this operation. + dist = vec4(pos.w * d0, pos.w * d1, pos.w * d2, 1.0 / pos.w); + + gl_Position = pos; +} === modified file 'data/shaders/bump-normals.frag' --- data/shaders/bump-normals.frag 2011-09-14 16:53:37 +0000 +++ data/shaders/bump-normals.frag 2011-10-11 09:51:17 +0000 @@ -1,44 +1,44 @@ -uniform sampler2D NormalMap; -uniform mat4 NormalMatrix; - -varying vec2 TextureCoord; - -void main(void) -{ - const vec4 LightSourceAmbient = vec4(0.1, 0.1, 0.1, 1.0); - const vec4 LightSourceDiffuse = vec4(0.8, 0.8, 0.8, 1.0); - const vec4 LightSourceSpecular = vec4(0.8, 0.8, 0.8, 1.0); - const vec4 MaterialAmbient = vec4(1.0, 1.0, 1.0, 1.0); - const vec4 MaterialDiffuse = vec4(1.0, 1.0, 1.0, 1.0); - const vec4 MaterialSpecular = vec4(0.2, 0.2, 0.2, 1.0); - const float MaterialShininess = 100.0; - - // Get the raw normal XYZ data from the normal map - vec3 normal_raw = texture2D(NormalMap, TextureCoord).xyz; - // Map "color" range [0, 1.0] to normal range [-1.0, 1.0] - vec3 normal_scaled = normal_raw * 2.0 - 1.0; - - // Convert the normal to eye coordinates. Note that the normal map - // we are using is using object coordinates (not tangent!) for the - // normals, so we can multiply by the NormalMatrix as usual. - vec3 N = normalize(vec3(NormalMatrix * vec4(normal_scaled, 1.0))); - - // In the lighting model we are using here (Blinn-Phong with light at - // infinity, viewer at infinity), the light position/direction and the - // half vector is constant for the all the fragments. - vec3 L = normalize(LightSourcePosition.xyz); - vec3 H = normalize(LightSourceHalfVector); - - // Calculate the diffuse color according to Lambertian reflectance - vec4 diffuse = MaterialDiffuse * LightSourceDiffuse * max(dot(N, L), 0.0); - - // Calculate the ambient color - vec4 ambient = MaterialAmbient * LightSourceAmbient; - - // Calculate the specular color according to the Blinn-Phong model - vec4 specular = MaterialSpecular * LightSourceSpecular * - pow(max(dot(N,H), 0.0), MaterialShininess); - - // Calculate the final color - gl_FragColor = ambient + specular + diffuse; -} +uniform sampler2D NormalMap; +uniform mat4 NormalMatrix; + +varying vec2 TextureCoord; + +void main(void) +{ + const vec4 LightSourceAmbient = vec4(0.1, 0.1, 0.1, 1.0); + const vec4 LightSourceDiffuse = vec4(0.8, 0.8, 0.8, 1.0); + const vec4 LightSourceSpecular = vec4(0.8, 0.8, 0.8, 1.0); + const vec4 MaterialAmbient = vec4(1.0, 1.0, 1.0, 1.0); + const vec4 MaterialDiffuse = vec4(1.0, 1.0, 1.0, 1.0); + const vec4 MaterialSpecular = vec4(0.2, 0.2, 0.2, 1.0); + const float MaterialShininess = 100.0; + + // Get the raw normal XYZ data from the normal map + vec3 normal_raw = texture2D(NormalMap, TextureCoord).xyz; + // Map "color" range [0, 1.0] to normal range [-1.0, 1.0] + vec3 normal_scaled = normal_raw * 2.0 - 1.0; + + // Convert the normal to eye coordinates. Note that the normal map + // we are using is using object coordinates (not tangent!) for the + // normals, so we can multiply by the NormalMatrix as usual. + vec3 N = normalize(vec3(NormalMatrix * vec4(normal_scaled, 1.0))); + + // In the lighting model we are using here (Blinn-Phong with light at + // infinity, viewer at infinity), the light position/direction and the + // half vector is constant for the all the fragments. + vec3 L = normalize(LightSourcePosition.xyz); + vec3 H = normalize(LightSourceHalfVector); + + // Calculate the diffuse color according to Lambertian reflectance + vec4 diffuse = MaterialDiffuse * LightSourceDiffuse * max(dot(N, L), 0.0); + + // Calculate the ambient color + vec4 ambient = MaterialAmbient * LightSourceAmbient; + + // Calculate the specular color according to the Blinn-Phong model + vec4 specular = MaterialSpecular * LightSourceSpecular * + pow(max(dot(N,H), 0.0), MaterialShininess); + + // Calculate the final color + gl_FragColor = ambient + specular + diffuse; +} === modified file 'data/shaders/bump-normals.vert' --- data/shaders/bump-normals.vert 2011-07-19 10:09:30 +0000 +++ data/shaders/bump-normals.vert 2011-10-11 09:51:17 +0000 @@ -1,14 +1,14 @@ -attribute vec3 position; -attribute vec2 texcoord; - -uniform mat4 ModelViewProjectionMatrix; - -varying vec2 TextureCoord; - -void main(void) -{ - TextureCoord = texcoord; - - // Transform the position to clip coordinates - gl_Position = ModelViewProjectionMatrix * vec4(position, 1.0); -} +attribute vec3 position; +attribute vec2 texcoord; + +uniform mat4 ModelViewProjectionMatrix; + +varying vec2 TextureCoord; + +void main(void) +{ + TextureCoord = texcoord; + + // Transform the position to clip coordinates + gl_Position = ModelViewProjectionMatrix * vec4(position, 1.0); +} === modified file 'data/shaders/bump-poly.frag' --- data/shaders/bump-poly.frag 2011-09-14 16:53:37 +0000 +++ data/shaders/bump-poly.frag 2011-10-11 09:51:17 +0000 @@ -1,33 +1,33 @@ -varying vec3 Normal; - -void main(void) -{ - const vec4 LightSourceAmbient = vec4(0.1, 0.1, 0.1, 1.0); - const vec4 LightSourceDiffuse = vec4(0.8, 0.8, 0.8, 1.0); - const vec4 LightSourceSpecular = vec4(0.8, 0.8, 0.8, 1.0); - const vec4 MaterialAmbient = vec4(1.0, 1.0, 1.0, 1.0); - const vec4 MaterialDiffuse = vec4(1.0, 1.0, 1.0, 1.0); - const vec4 MaterialSpecular = vec4(0.2, 0.2, 0.2, 1.0); - const float MaterialShininess = 100.0; - - vec3 N = normalize(Normal); - - // In the lighting model we are using here (Blinn-Phong with light at - // infinity, viewer at infinity), the light position/direction and the - // half vector is constant for the all the fragments. - vec3 L = normalize(LightSourcePosition.xyz); - vec3 H = normalize(LightSourceHalfVector); - - // Calculate the diffuse color according to Lambertian reflectance - vec4 diffuse = MaterialDiffuse * LightSourceDiffuse * max(dot(N, L), 0.0); - - // Calculate the ambient color - vec4 ambient = MaterialAmbient * LightSourceAmbient; - - // Calculate the specular color according to the Blinn-Phong model - vec4 specular = MaterialSpecular * LightSourceSpecular * - pow(max(dot(N,H), 0.0), MaterialShininess); - - // Calculate the final color - gl_FragColor = ambient + specular + diffuse; -} +varying vec3 Normal; + +void main(void) +{ + const vec4 LightSourceAmbient = vec4(0.1, 0.1, 0.1, 1.0); + const vec4 LightSourceDiffuse = vec4(0.8, 0.8, 0.8, 1.0); + const vec4 LightSourceSpecular = vec4(0.8, 0.8, 0.8, 1.0); + const vec4 MaterialAmbient = vec4(1.0, 1.0, 1.0, 1.0); + const vec4 MaterialDiffuse = vec4(1.0, 1.0, 1.0, 1.0); + const vec4 MaterialSpecular = vec4(0.2, 0.2, 0.2, 1.0); + const float MaterialShininess = 100.0; + + vec3 N = normalize(Normal); + + // In the lighting model we are using here (Blinn-Phong with light at + // infinity, viewer at infinity), the light position/direction and the + // half vector is constant for the all the fragments. + vec3 L = normalize(LightSourcePosition.xyz); + vec3 H = normalize(LightSourceHalfVector); + + // Calculate the diffuse color according to Lambertian reflectance + vec4 diffuse = MaterialDiffuse * LightSourceDiffuse * max(dot(N, L), 0.0); + + // Calculate the ambient color + vec4 ambient = MaterialAmbient * LightSourceAmbient; + + // Calculate the specular color according to the Blinn-Phong model + vec4 specular = MaterialSpecular * LightSourceSpecular * + pow(max(dot(N,H), 0.0), MaterialShininess); + + // Calculate the final color + gl_FragColor = ambient + specular + diffuse; +} === modified file 'data/shaders/bump-poly.vert' --- data/shaders/bump-poly.vert 2011-07-19 10:09:30 +0000 +++ data/shaders/bump-poly.vert 2011-10-11 09:51:17 +0000 @@ -1,16 +1,16 @@ -attribute vec3 position; -attribute vec3 normal; - -uniform mat4 ModelViewProjectionMatrix; -uniform mat4 NormalMatrix; - -varying vec3 Normal; - -void main(void) -{ - // Transform the normal to eye coordinates - Normal = normalize(vec3(NormalMatrix * vec4(normal, 1.0))); - - // Transform the position to clip coordinates - gl_Position = ModelViewProjectionMatrix * vec4(position, 1.0); -} +attribute vec3 position; +attribute vec3 normal; + +uniform mat4 ModelViewProjectionMatrix; +uniform mat4 NormalMatrix; + +varying vec3 Normal; + +void main(void) +{ + // Transform the normal to eye coordinates + Normal = normalize(vec3(NormalMatrix * vec4(normal, 1.0))); + + // Transform the position to clip coordinates + gl_Position = ModelViewProjectionMatrix * vec4(position, 1.0); +} === modified file 'data/shaders/desktop.vert' --- data/shaders/desktop.vert 2011-09-09 13:57:53 +0000 +++ data/shaders/desktop.vert 2011-10-11 09:51:17 +0000 @@ -1,11 +1,11 @@ -attribute vec2 position; -attribute vec2 texcoord; - -varying vec2 TextureCoord; - -void main(void) -{ - gl_Position = vec4(position, 0.0, 1.0); - - TextureCoord = texcoord; -} +attribute vec2 position; +attribute vec2 texcoord; + +varying vec2 TextureCoord; + +void main(void) +{ + gl_Position = vec4(position, 0.0, 1.0); + + TextureCoord = texcoord; +} === modified file 'data/shaders/effect-2d.vert' --- data/shaders/effect-2d.vert 2011-07-28 14:06:56 +0000 +++ data/shaders/effect-2d.vert 2011-10-11 09:51:17 +0000 @@ -1,10 +1,10 @@ -attribute vec3 position; - -varying vec2 TextureCoord; - -void main(void) -{ - gl_Position = vec4(position, 1.0); - - TextureCoord = position.xy * 0.5 + 0.5; -} +attribute vec3 position; + +varying vec2 TextureCoord; + +void main(void) +{ + gl_Position = vec4(position, 1.0); + + TextureCoord = position.xy * 0.5 + 0.5; +} === modified file 'data/shaders/light-advanced.frag' --- data/shaders/light-advanced.frag 2011-09-14 16:53:37 +0000 +++ data/shaders/light-advanced.frag 2011-10-11 09:51:17 +0000 @@ -1,33 +1,33 @@ -varying vec3 Normal; - -void main(void) -{ - const vec4 LightSourceAmbient = vec4(0.1, 0.1, 0.1, 1.0); - const vec4 LightSourceDiffuse = vec4(0.8, 0.8, 0.8, 1.0); - const vec4 LightSourceSpecular = vec4(0.8, 0.8, 0.8, 1.0); - const vec4 MaterialAmbient = vec4(1.0, 1.0, 1.0, 1.0); - const vec4 MaterialDiffuse = vec4(0.0, 0.0, 1.0, 1.0); - const vec4 MaterialSpecular = vec4(1.0, 1.0, 1.0, 1.0); - const float MaterialShininess = 100.0; - - vec3 N = normalize(Normal); - - // In the lighting model we are using here (Blinn-Phong with light at - // infinity, viewer at infinity), the light position/direction and the - // half vector is constant for the all the fragments. - vec3 L = normalize(LightSourcePosition.xyz); - vec3 H = normalize(LightSourceHalfVector); - - // Calculate the diffuse color according to Lambertian reflectance - vec4 diffuse = MaterialDiffuse * LightSourceDiffuse * max(dot(N, L), 0.0); - - // Calculate the ambient color - vec4 ambient = MaterialAmbient * LightSourceAmbient; - - // Calculate the specular color according to the Blinn-Phong model - vec4 specular = MaterialSpecular * LightSourceSpecular * - pow(max(dot(N,H), 0.0), MaterialShininess); - - // Calculate the final color - gl_FragColor = ambient + specular + diffuse; -} +varying vec3 Normal; + +void main(void) +{ + const vec4 LightSourceAmbient = vec4(0.1, 0.1, 0.1, 1.0); + const vec4 LightSourceDiffuse = vec4(0.8, 0.8, 0.8, 1.0); + const vec4 LightSourceSpecular = vec4(0.8, 0.8, 0.8, 1.0); + const vec4 MaterialAmbient = vec4(1.0, 1.0, 1.0, 1.0); + const vec4 MaterialDiffuse = vec4(0.0, 0.0, 1.0, 1.0); + const vec4 MaterialSpecular = vec4(1.0, 1.0, 1.0, 1.0); + const float MaterialShininess = 100.0; + + vec3 N = normalize(Normal); + + // In the lighting model we are using here (Blinn-Phong with light at + // infinity, viewer at infinity), the light position/direction and the + // half vector is constant for the all the fragments. + vec3 L = normalize(LightSourcePosition.xyz); + vec3 H = normalize(LightSourceHalfVector); + + // Calculate the diffuse color according to Lambertian reflectance + vec4 diffuse = MaterialDiffuse * LightSourceDiffuse * max(dot(N, L), 0.0); + + // Calculate the ambient color + vec4 ambient = MaterialAmbient * LightSourceAmbient; + + // Calculate the specular color according to the Blinn-Phong model + vec4 specular = MaterialSpecular * LightSourceSpecular * + pow(max(dot(N,H), 0.0), MaterialShininess); + + // Calculate the final color + gl_FragColor = ambient + specular + diffuse; +} === modified file 'data/shaders/light-advanced.vert' --- data/shaders/light-advanced.vert 2011-09-13 15:41:27 +0000 +++ data/shaders/light-advanced.vert 2011-10-11 09:51:17 +0000 @@ -1,16 +1,16 @@ -attribute vec3 position; -attribute vec3 normal; - -uniform mat4 ModelViewProjectionMatrix; -uniform mat4 NormalMatrix; - -varying vec3 Normal; - -void main(void) -{ - // Transform the normal to eye coordinates - Normal = normalize(vec3(NormalMatrix * vec4(normal, 1.0))); - - // Transform the position to clip coordinates - gl_Position = ModelViewProjectionMatrix * vec4(position, 1.0); -} +attribute vec3 position; +attribute vec3 normal; + +uniform mat4 ModelViewProjectionMatrix; +uniform mat4 NormalMatrix; + +varying vec3 Normal; + +void main(void) +{ + // Transform the normal to eye coordinates + Normal = normalize(vec3(NormalMatrix * vec4(normal, 1.0))); + + // Transform the position to clip coordinates + gl_Position = ModelViewProjectionMatrix * vec4(position, 1.0); +} === modified file 'data/shaders/light-basic.frag' --- data/shaders/light-basic.frag 2011-09-14 16:53:37 +0000 +++ data/shaders/light-basic.frag 2011-10-11 09:51:17 +0000 @@ -1,7 +1,7 @@ -varying vec4 Color; -varying vec2 TextureCoord; - -void main(void) -{ - gl_FragColor = Color; -} +varying vec4 Color; +varying vec2 TextureCoord; + +void main(void) +{ + gl_FragColor = Color; +} === modified file 'data/shaders/light-basic.vert' --- data/shaders/light-basic.vert 2011-07-27 15:02:27 +0000 +++ data/shaders/light-basic.vert 2011-10-11 09:51:17 +0000 @@ -1,29 +1,29 @@ -attribute vec3 position; -attribute vec3 normal; -attribute vec2 texcoord; - -uniform mat4 ModelViewProjectionMatrix; -uniform mat4 NormalMatrix; - -varying vec4 Color; -varying vec2 TextureCoord; - -void main(void) -{ - // Transform the normal to eye coordinates - vec3 N = normalize(vec3(NormalMatrix * vec4(normal, 1.0))); - - // The LightSourcePosition is actually its direction for directional light - vec3 L = normalize(LightSourcePosition.xyz); - - // 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 * MaterialDiffuse; - - // Set the texture coordinates as a varying - TextureCoord = texcoord; - - // Transform the position to clip coordinates - gl_Position = ModelViewProjectionMatrix * vec4(position, 1.0); -} +attribute vec3 position; +attribute vec3 normal; +attribute vec2 texcoord; + +uniform mat4 ModelViewProjectionMatrix; +uniform mat4 NormalMatrix; + +varying vec4 Color; +varying vec2 TextureCoord; + +void main(void) +{ + // Transform the normal to eye coordinates + vec3 N = normalize(vec3(NormalMatrix * vec4(normal, 1.0))); + + // The LightSourcePosition is actually its direction for directional light + vec3 L = normalize(LightSourcePosition.xyz); + + // 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 * MaterialDiffuse; + + // Set the texture coordinates as a varying + TextureCoord = texcoord; + + // Transform the position to clip coordinates + gl_Position = ModelViewProjectionMatrix * vec4(position, 1.0); +} === modified file 'data/shaders/light-phong.frag' --- data/shaders/light-phong.frag 2011-09-19 16:18:59 +0000 +++ data/shaders/light-phong.frag 2011-10-11 09:51:17 +0000 @@ -1,29 +1,29 @@ -varying vec3 vertex_normal; -varying vec4 vertex_position; - -vec4 -compute_color(vec4 light_position, vec4 diffuse_light_color) -{ - const vec4 lightAmbient = vec4(0.1, 0.1, 0.1, 1.0); - const vec4 lightSpecular = vec4(0.8, 0.8, 0.8, 1.0); - const vec4 matAmbient = vec4(0.2, 0.2, 0.2, 1.0); - const vec4 matSpecular = vec4(1.0, 1.0, 1.0, 1.0); - const float matShininess = 100.0; - vec3 eye_direction = normalize(-vertex_position.xyz); - vec3 light_direction = normalize(light_position.xyz/light_position.w - - vertex_position.xyz/vertex_position.w); - vec3 normalized_normal = normalize(vertex_normal); - vec3 reflection = reflect(-light_direction, normalized_normal); - float specularTerm = pow(max(0.0, dot(reflection, eye_direction)), matShininess); - float diffuseTerm = max(0.0, dot(normalized_normal, light_direction)); - vec4 specular = (lightSpecular * matSpecular); - vec4 ambient = (lightAmbient * matAmbient); - vec4 diffuse = (diffuse_light_color * MaterialDiffuse); - vec4 result = (specular * specularTerm) + ambient + (diffuse * diffuseTerm); - return result; -} - -void main(void) -{ -$DO_LIGHTS$ -} +varying vec3 vertex_normal; +varying vec4 vertex_position; + +vec4 +compute_color(vec4 light_position, vec4 diffuse_light_color) +{ + const vec4 lightAmbient = vec4(0.1, 0.1, 0.1, 1.0); + const vec4 lightSpecular = vec4(0.8, 0.8, 0.8, 1.0); + const vec4 matAmbient = vec4(0.2, 0.2, 0.2, 1.0); + const vec4 matSpecular = vec4(1.0, 1.0, 1.0, 1.0); + const float matShininess = 100.0; + vec3 eye_direction = normalize(-vertex_position.xyz); + vec3 light_direction = normalize(light_position.xyz/light_position.w - + vertex_position.xyz/vertex_position.w); + vec3 normalized_normal = normalize(vertex_normal); + vec3 reflection = reflect(-light_direction, normalized_normal); + float specularTerm = pow(max(0.0, dot(reflection, eye_direction)), matShininess); + float diffuseTerm = max(0.0, dot(normalized_normal, light_direction)); + vec4 specular = (lightSpecular * matSpecular); + vec4 ambient = (lightAmbient * matAmbient); + vec4 diffuse = (diffuse_light_color * MaterialDiffuse); + vec4 result = (specular * specularTerm) + ambient + (diffuse * diffuseTerm); + return result; +} + +void main(void) +{ +$DO_LIGHTS$ +} === modified file 'data/shaders/light-phong.vert' --- data/shaders/light-phong.vert 2011-09-13 15:40:50 +0000 +++ data/shaders/light-phong.vert 2011-10-11 09:51:17 +0000 @@ -1,23 +1,23 @@ -attribute vec3 position; -attribute vec3 normal; - -uniform mat4 ModelViewProjectionMatrix; -uniform mat4 NormalMatrix; -uniform mat4 ModelViewMatrix; - -varying vec3 vertex_normal; -varying vec4 vertex_position; - -void main(void) -{ - vec4 current_position = vec4(position, 1.0); - - // Transform the normal to eye coordinates - vertex_normal = normalize(vec3(NormalMatrix * vec4(normal, 1.0))); - - // Transform the current position to eye coordinates - vertex_position = ModelViewMatrix * current_position; - - // Transform the current position to clip coordinates - gl_Position = ModelViewProjectionMatrix * current_position; -} +attribute vec3 position; +attribute vec3 normal; + +uniform mat4 ModelViewProjectionMatrix; +uniform mat4 NormalMatrix; +uniform mat4 ModelViewMatrix; + +varying vec3 vertex_normal; +varying vec4 vertex_position; + +void main(void) +{ + vec4 current_position = vec4(position, 1.0); + + // Transform the normal to eye coordinates + vertex_normal = normalize(vec3(NormalMatrix * vec4(normal, 1.0))); + + // Transform the current position to eye coordinates + vertex_position = ModelViewMatrix * current_position; + + // Transform the current position to clip coordinates + gl_Position = ModelViewProjectionMatrix * current_position; +} === modified file 'data/shaders/pulsar-light.vert' --- data/shaders/pulsar-light.vert 2011-08-17 09:21:24 +0000 +++ data/shaders/pulsar-light.vert 2011-10-11 09:51:17 +0000 @@ -1,31 +1,31 @@ -attribute vec3 position; -attribute vec3 normal; -attribute vec4 vtxcolor; -attribute vec2 texcoord; - -uniform mat4 ModelViewProjectionMatrix; -uniform mat4 NormalMatrix; - -varying vec4 Color; -varying vec2 TextureCoord; - -void main(void) -{ - // Transform the normal to eye coordinates - vec3 N = normalize(vec3(NormalMatrix * vec4(normal, 1.0))); - - // The LightSourcePosition is actually its direction for directional light - vec3 L = normalize(LightSourcePosition.xyz); - - // Multiply the diffuse value by the vertex color - // to get the actual color that we will use to draw this vertex with - float diffuse = max(abs(dot(N, L)), 0.0); - Color = diffuse * vtxcolor; - - // Set the texture coordinates as a varying - TextureCoord = texcoord; - - // Transform the position to clip coordinates - gl_Position = ModelViewProjectionMatrix * vec4(position, 1.0); -} - +attribute vec3 position; +attribute vec3 normal; +attribute vec4 vtxcolor; +attribute vec2 texcoord; + +uniform mat4 ModelViewProjectionMatrix; +uniform mat4 NormalMatrix; + +varying vec4 Color; +varying vec2 TextureCoord; + +void main(void) +{ + // Transform the normal to eye coordinates + vec3 N = normalize(vec3(NormalMatrix * vec4(normal, 1.0))); + + // The LightSourcePosition is actually its direction for directional light + vec3 L = normalize(LightSourcePosition.xyz); + + // Multiply the diffuse value by the vertex color + // to get the actual color that we will use to draw this vertex with + float diffuse = max(abs(dot(N, L)), 0.0); + Color = diffuse * vtxcolor; + + // Set the texture coordinates as a varying + TextureCoord = texcoord; + + // Transform the position to clip coordinates + gl_Position = ModelViewProjectionMatrix * vec4(position, 1.0); +} + === modified file 'data/shaders/pulsar.vert' --- data/shaders/pulsar.vert 2011-08-17 09:21:24 +0000 +++ data/shaders/pulsar.vert 2011-10-11 09:51:17 +0000 @@ -1,19 +1,19 @@ -attribute vec3 position; -attribute vec4 vtxcolor; -attribute vec2 texcoord; -attribute vec3 normal; - -uniform mat4 ModelViewProjectionMatrix; - -varying vec4 Color; -varying vec2 TextureCoord; - -void main(void) -{ - Color = vtxcolor; - TextureCoord = texcoord; - - // Transform the position to clip coordinates - gl_Position = ModelViewProjectionMatrix * vec4(position, 1.0); -} - +attribute vec3 position; +attribute vec4 vtxcolor; +attribute vec2 texcoord; +attribute vec3 normal; + +uniform mat4 ModelViewProjectionMatrix; + +varying vec4 Color; +varying vec2 TextureCoord; + +void main(void) +{ + Color = vtxcolor; + TextureCoord = texcoord; + + // Transform the position to clip coordinates + gl_Position = ModelViewProjectionMatrix * vec4(position, 1.0); +} +