--- /dev/null
+//
+// Fragment shader for procedural bricks
+//
+// Authors: Dave Baldwin, Steve Koren, Randi Rost
+// based on a shader by Darwyn Peachey
+//
+// Copyright (c) 2002-2006 3Dlabs Inc. Ltd.
+//
+// See 3Dlabs-License.txt for license information
+//
+
+uniform vec3 BrickColor, MortarColor;
+uniform vec2 BrickSize;
+uniform vec2 BrickPct;
+
+varying vec2 MCposition;
+varying float LightIntensity;
+
+void main()
+{
+ vec3 color;
+ vec2 position, useBrick;
+
+ position = MCposition / BrickSize;
+
+ if (fract(position.y * 0.5) > 0.5)
+ position.x += 0.5;
+
+ position = fract(position);
+
+ useBrick = step(position, BrickPct);
+
+ color = mix(MortarColor, BrickColor, useBrick.x * useBrick.y);
+ color *= LightIntensity;
+ gl_FragColor = vec4(color, 1.0);
+}
+++ /dev/null
-//
-// Fragment shader for procedural bricks
-//
-// Authors: Dave Baldwin, Steve Koren, Randi Rost
-// based on a shader by Darwyn Peachey
-//
-// Copyright (c) 2002-2006 3Dlabs Inc. Ltd.
-//
-// See 3Dlabs-License.txt for license information
-//
-
-uniform vec3 BrickColor, MortarColor;
-uniform vec2 BrickSize;
-uniform vec2 BrickPct;
-
-varying vec2 MCposition;
-varying float LightIntensity;
-
-void main()
-{
- vec3 color;
- vec2 position, useBrick;
-
- position = MCposition / BrickSize;
-
- if (fract(position.y * 0.5) > 0.5)
- position.x += 0.5;
-
- position = fract(position);
-
- useBrick = step(position, BrickPct);
-
- color = mix(MortarColor, BrickColor, useBrick.x * useBrick.y);
- color *= LightIntensity;
- gl_FragColor = vec4(color, 1.0);
-}
--- /dev/null
+//
+// Vertex shader for procedural bricks
+//
+// Authors: Dave Baldwin, Steve Koren, Randi Rost
+// based on a shader by Darwyn Peachey
+//
+// Copyright (c) 2002-2006 3Dlabs Inc. Ltd.
+//
+// See 3Dlabs-License.txt for license information
+//
+
+uniform vec3 LightPosition;
+
+const float SpecularContribution = 0.3;
+const float DiffuseContribution = 1.0 - SpecularContribution;
+
+varying float LightIntensity;
+varying vec2 MCposition;
+
+void main()
+{
+ vec3 ecPosition = vec3(gl_ModelViewMatrix * gl_Vertex);
+ vec3 tnorm = normalize(gl_NormalMatrix * gl_Normal);
+ vec3 lightVec = normalize(LightPosition - ecPosition);
+ vec3 reflectVec = reflect(-lightVec, tnorm);
+ vec3 viewVec = normalize(-ecPosition);
+ float diffuse = max(dot(lightVec, tnorm), 0.0);
+ float spec = 0.0;
+
+ if (diffuse > 0.0)
+ {
+ spec = max(dot(reflectVec, viewVec), 0.0);
+ spec = pow(spec, 16.0);
+ }
+
+ LightIntensity = DiffuseContribution * diffuse +
+ SpecularContribution * spec;
+
+ MCposition = gl_Vertex.xy;
+ gl_Position = ftransform();
+}
+++ /dev/null
-//
-// Vertex shader for procedural bricks
-//
-// Authors: Dave Baldwin, Steve Koren, Randi Rost
-// based on a shader by Darwyn Peachey
-//
-// Copyright (c) 2002-2006 3Dlabs Inc. Ltd.
-//
-// See 3Dlabs-License.txt for license information
-//
-
-uniform vec3 LightPosition;
-
-const float SpecularContribution = 0.3;
-const float DiffuseContribution = 1.0 - SpecularContribution;
-
-varying float LightIntensity;
-varying vec2 MCposition;
-
-void main()
-{
- vec3 ecPosition = vec3(gl_ModelViewMatrix * gl_Vertex);
- vec3 tnorm = normalize(gl_NormalMatrix * gl_Normal);
- vec3 lightVec = normalize(LightPosition - ecPosition);
- vec3 reflectVec = reflect(-lightVec, tnorm);
- vec3 viewVec = normalize(-ecPosition);
- float diffuse = max(dot(lightVec, tnorm), 0.0);
- float spec = 0.0;
-
- if (diffuse > 0.0)
- {
- spec = max(dot(reflectVec, viewVec), 0.0);
- spec = pow(spec, 16.0);
- }
-
- LightIntensity = DiffuseContribution * diffuse +
- SpecularContribution * spec;
-
- MCposition = gl_Vertex.xy;
- gl_Position = ftransform();
-}
--- /dev/null
+//
+// Fragment shader for procedural bumps
+//
+// Authors: John Kessenich, Randi Rost
+//
+// Copyright (c) 2002-2006 3Dlabs Inc. Ltd.
+//
+// See 3Dlabs-License.txt for license information
+//
+
+varying vec3 LightDir;
+varying vec3 EyeDir;
+
+uniform vec3 SurfaceColor; // = (0.7, 0.6, 0.18)
+uniform float BumpDensity; // = 16.0
+uniform float BumpSize; // = 0.15
+uniform float SpecularFactor; // = 0.5
+
+void main()
+{
+ vec3 litColor;
+ vec2 c = BumpDensity * gl_TexCoord[0].st;
+ vec2 p = fract(c) - vec2(0.5);
+
+ float d, f;
+ d = p.x * p.x + p.y * p.y;
+ f = 1.0 / sqrt(d + 1.0);
+
+ if (d >= BumpSize)
+ { p = vec2(0.0); f = 1.0; }
+
+ vec3 normDelta = vec3(p.x, p.y, 1.0) * f;
+ litColor = SurfaceColor * max(dot(normDelta, LightDir), 0.0);
+ vec3 reflectDir = reflect(LightDir, normDelta);
+
+ float spec = max(dot(EyeDir, reflectDir), 0.0);
+ spec *= SpecularFactor;
+ litColor = min(litColor + spec, vec3(1.0));
+
+ gl_FragColor = vec4(litColor, 1.0);
+}
+++ /dev/null
-//
-// Fragment shader for procedural bumps
-//
-// Authors: John Kessenich, Randi Rost
-//
-// Copyright (c) 2002-2006 3Dlabs Inc. Ltd.
-//
-// See 3Dlabs-License.txt for license information
-//
-
-varying vec3 LightDir;
-varying vec3 EyeDir;
-
-uniform vec3 SurfaceColor; // = (0.7, 0.6, 0.18)
-uniform float BumpDensity; // = 16.0
-uniform float BumpSize; // = 0.15
-uniform float SpecularFactor; // = 0.5
-
-void main()
-{
- vec3 litColor;
- vec2 c = BumpDensity * gl_TexCoord[0].st;
- vec2 p = fract(c) - vec2(0.5);
-
- float d, f;
- d = p.x * p.x + p.y * p.y;
- f = 1.0 / sqrt(d + 1.0);
-
- if (d >= BumpSize)
- { p = vec2(0.0); f = 1.0; }
-
- vec3 normDelta = vec3(p.x, p.y, 1.0) * f;
- litColor = SurfaceColor * max(dot(normDelta, LightDir), 0.0);
- vec3 reflectDir = reflect(LightDir, normDelta);
-
- float spec = max(dot(EyeDir, reflectDir), 0.0);
- spec *= SpecularFactor;
- litColor = min(litColor + spec, vec3(1.0));
-
- gl_FragColor = vec4(litColor, 1.0);
-}
--- /dev/null
+//
+// Vertex shader for procedural bumps
+//
+// Authors: Randi Rost, John Kessenich
+//
+// Copyright (c) 2002-2006 3Dlabs Inc. Ltd.
+//
+// See 3Dlabs-License.txt for license information
+//
+
+varying vec3 LightDir;
+varying vec3 EyeDir;
+
+uniform vec3 LightPosition;
+
+attribute vec3 Tangent;
+
+void main()
+{
+ EyeDir = vec3(gl_ModelViewMatrix * gl_Vertex);
+ gl_Position = ftransform();
+ gl_TexCoord[0] = gl_MultiTexCoord0;
+
+ vec3 n = normalize(gl_NormalMatrix * gl_Normal);
+ vec3 t = normalize(gl_NormalMatrix * Tangent);
+ vec3 b = cross(n, t);
+
+ vec3 v;
+ v.x = dot(LightPosition, t);
+ v.y = dot(LightPosition, b);
+ v.z = dot(LightPosition, n);
+ LightDir = normalize(v);
+
+ v.x = dot(EyeDir, t);
+ v.y = dot(EyeDir, b);
+ v.z = dot(EyeDir, n);
+ EyeDir = normalize(v);
+}
+++ /dev/null
-//
-// Vertex shader for procedural bumps
-//
-// Authors: Randi Rost, John Kessenich
-//
-// Copyright (c) 2002-2006 3Dlabs Inc. Ltd.
-//
-// See 3Dlabs-License.txt for license information
-//
-
-varying vec3 LightDir;
-varying vec3 EyeDir;
-
-uniform vec3 LightPosition;
-
-attribute vec3 Tangent;
-
-void main()
-{
- EyeDir = vec3(gl_ModelViewMatrix * gl_Vertex);
- gl_Position = ftransform();
- gl_TexCoord[0] = gl_MultiTexCoord0;
-
- vec3 n = normalize(gl_NormalMatrix * gl_Normal);
- vec3 t = normalize(gl_NormalMatrix * Tangent);
- vec3 b = cross(n, t);
-
- vec3 v;
- v.x = dot(LightPosition, t);
- v.y = dot(LightPosition, b);
- v.z = dot(LightPosition, n);
- LightDir = normalize(v);
-
- v.x = dot(EyeDir, t);
- v.y = dot(EyeDir, b);
- v.z = dot(EyeDir, n);
- EyeDir = normalize(v);
-}
--- /dev/null
+//
+// Fragment shader for procedurally generated toy ball
+//
+// Author: Bill Licea-Kane
+//
+// Copyright (c) 2002-2003 ATI Research
+//
+// See ATI-License.txt for license information
+//
+
+varying vec4 ECposition; // surface position in eye coordinates
+varying vec4 ECballCenter; // ball center in eye coordinates
+
+uniform vec4 LightDir; // light direction, should be normalized
+uniform vec4 HVector; // reflection vector for infinite light source
+uniform vec4 SpecularColor;
+uniform vec4 Red, Yellow, Blue;
+
+uniform vec4 HalfSpace0; // half-spaces used to define star pattern
+uniform vec4 HalfSpace1;
+uniform vec4 HalfSpace2;
+uniform vec4 HalfSpace3;
+uniform vec4 HalfSpace4;
+
+uniform float InOrOutInit; // = -3
+uniform float StripeWidth; // = 0.3
+uniform float FWidth; // = 0.005
+
+void main()
+{
+ vec4 normal; // Analytically computed normal
+ vec4 p; // Point in shader space
+ vec4 surfColor; // Computed color of the surface
+ float intensity; // Computed light intensity
+ vec4 distance; // Computed distance values
+ float inorout; // Counter for computing star pattern
+
+ p.xyz = normalize(ECposition.xyz - ECballCenter.xyz); // Calculate p
+ p.w = 1.0;
+
+ inorout = InOrOutInit; // initialize inorout to -3
+
+ distance[0] = dot(p, HalfSpace0);
+ distance[1] = dot(p, HalfSpace1);
+ distance[2] = dot(p, HalfSpace2);
+ distance[3] = dot(p, HalfSpace3);
+
+ distance = smoothstep(-FWidth, FWidth, distance);
+ inorout += dot(distance, vec4(1.0));
+
+ distance.x = dot(p, HalfSpace4);
+ distance.y = StripeWidth - abs(p.z);
+ distance = smoothstep(-FWidth, FWidth, distance);
+ inorout += distance.x;
+
+ inorout = clamp(inorout, 0.0, 1.0);
+
+ surfColor = mix(Yellow, Red, inorout);
+ surfColor = mix(surfColor, Blue, distance.y);
+
+ // normal = point on surface for sphere at (0,0,0)
+ normal = p;
+
+ // Per fragment diffuse lighting
+ intensity = 0.2; // ambient
+ intensity += 0.8 * clamp(dot(LightDir, normal), 0.0, 1.0);
+ surfColor *= intensity;
+
+ // Per fragment specular lighting
+ intensity = clamp(dot(HVector, normal), 0.0, 1.0);
+ intensity = pow(intensity, SpecularColor.a);
+ surfColor += SpecularColor * intensity;
+
+ gl_FragColor = surfColor;
+}
+++ /dev/null
-//
-// Fragment shader for procedurally generated toy ball
-//
-// Author: Bill Licea-Kane
-//
-// Copyright (c) 2002-2003 ATI Research
-//
-// See ATI-License.txt for license information
-//
-
-varying vec4 ECposition; // surface position in eye coordinates
-varying vec4 ECballCenter; // ball center in eye coordinates
-
-uniform vec4 LightDir; // light direction, should be normalized
-uniform vec4 HVector; // reflection vector for infinite light source
-uniform vec4 SpecularColor;
-uniform vec4 Red, Yellow, Blue;
-
-uniform vec4 HalfSpace0; // half-spaces used to define star pattern
-uniform vec4 HalfSpace1;
-uniform vec4 HalfSpace2;
-uniform vec4 HalfSpace3;
-uniform vec4 HalfSpace4;
-
-uniform float InOrOutInit; // = -3
-uniform float StripeWidth; // = 0.3
-uniform float FWidth; // = 0.005
-
-void main()
-{
- vec4 normal; // Analytically computed normal
- vec4 p; // Point in shader space
- vec4 surfColor; // Computed color of the surface
- float intensity; // Computed light intensity
- vec4 distance; // Computed distance values
- float inorout; // Counter for computing star pattern
-
- p.xyz = normalize(ECposition.xyz - ECballCenter.xyz); // Calculate p
- p.w = 1.0;
-
- inorout = InOrOutInit; // initialize inorout to -3
-
- distance[0] = dot(p, HalfSpace0);
- distance[1] = dot(p, HalfSpace1);
- distance[2] = dot(p, HalfSpace2);
- distance[3] = dot(p, HalfSpace3);
-
- distance = smoothstep(-FWidth, FWidth, distance);
- inorout += dot(distance, vec4(1.0));
-
- distance.x = dot(p, HalfSpace4);
- distance.y = StripeWidth - abs(p.z);
- distance = smoothstep(-FWidth, FWidth, distance);
- inorout += distance.x;
-
- inorout = clamp(inorout, 0.0, 1.0);
-
- surfColor = mix(Yellow, Red, inorout);
- surfColor = mix(surfColor, Blue, distance.y);
-
- // normal = point on surface for sphere at (0,0,0)
- normal = p;
-
- // Per fragment diffuse lighting
- intensity = 0.2; // ambient
- intensity += 0.8 * clamp(dot(LightDir, normal), 0.0, 1.0);
- surfColor *= intensity;
-
- // Per fragment specular lighting
- intensity = clamp(dot(HVector, normal), 0.0, 1.0);
- intensity = pow(intensity, SpecularColor.a);
- surfColor += SpecularColor * intensity;
-
- gl_FragColor = surfColor;
-}
--- /dev/null
+//
+// Fragment shader for procedurally generated toy ball
+//
+// Author: Bill Licea-Kane
+//
+// Copyright (c) 2002-2003 ATI Research
+//
+// See ATI-License.txt for license information
+//
+
+varying vec4 ECposition; // surface position in eye coordinates
+varying vec4 ECballCenter; // ball center in eye coordinates
+uniform vec4 BallCenter; // ball center in modelling coordinates
+
+void main()
+{
+//orig: ECposition = gl_ModelViewMatrix * gl_Vertex;
+
+ ECposition = gl_TextureMatrix[0] * gl_Vertex;
+ ECposition = gl_ModelViewMatrix * ECposition;
+
+ ECballCenter = gl_ModelViewMatrix * BallCenter;
+ gl_Position = ftransform();
+}
+++ /dev/null
-//
-// Fragment shader for procedurally generated toy ball
-//
-// Author: Bill Licea-Kane
-//
-// Copyright (c) 2002-2003 ATI Research
-//
-// See ATI-License.txt for license information
-//
-
-varying vec4 ECposition; // surface position in eye coordinates
-varying vec4 ECballCenter; // ball center in eye coordinates
-uniform vec4 BallCenter; // ball center in modelling coordinates
-
-void main()
-{
-//orig: ECposition = gl_ModelViewMatrix * gl_Vertex;
-
- ECposition = gl_TextureMatrix[0] * gl_Vertex;
- ECposition = gl_ModelViewMatrix * ECposition;
-
- ECballCenter = gl_ModelViewMatrix * BallCenter;
- gl_Position = ftransform();
-}
--- /dev/null
+//
+// Fragment shader for drawing the Mandelbrot set
+//
+// Authors: Dave Baldwin, Steve Koren, Randi Rost
+// based on a shader by Michael Rivero
+//
+// Copyright (c) 2002-2005: 3Dlabs, Inc.
+//
+// See 3Dlabs-License.txt for license information
+//
+
+varying vec3 Position;
+varying float LightIntensity;
+
+uniform float MaxIterations;
+uniform float Zoom;
+uniform float Xcenter;
+uniform float Ycenter;
+uniform vec3 InnerColor;
+uniform vec3 OuterColor1;
+uniform vec3 OuterColor2;
+
+void main()
+{
+ float real = Position.x * Zoom + Xcenter;
+ float imag = Position.y * Zoom + Ycenter;
+ float Creal = real; // Change this line...
+ float Cimag = imag; // ...and this one to get a Julia set
+
+ float r2 = 0.0;
+ float iter;
+
+// for (iter = 0.0; iter < MaxIterations && r2 < 4.0; ++iter)
+ for (iter = 0.0; iter < 12 && r2 < 4.0; ++iter)
+ {
+ float tempreal = real;
+
+ real = (tempreal * tempreal) - (imag * imag) + Creal;
+ imag = 2.0 * tempreal * imag + Cimag;
+ r2 = (real * real) + (imag * imag);
+ }
+
+ // Base the color on the number of iterations
+
+ vec3 color;
+
+ if (r2 < 4.0)
+ color = InnerColor;
+ else
+ color = mix(OuterColor1, OuterColor2, fract(iter * 0.05));
+
+ color *= LightIntensity;
+
+ gl_FragColor = vec4(color, 1.0);
+}
+++ /dev/null
-//
-// Fragment shader for drawing the Mandelbrot set
-//
-// Authors: Dave Baldwin, Steve Koren, Randi Rost
-// based on a shader by Michael Rivero
-//
-// Copyright (c) 2002-2005: 3Dlabs, Inc.
-//
-// See 3Dlabs-License.txt for license information
-//
-
-varying vec3 Position;
-varying float LightIntensity;
-
-uniform float MaxIterations;
-uniform float Zoom;
-uniform float Xcenter;
-uniform float Ycenter;
-uniform vec3 InnerColor;
-uniform vec3 OuterColor1;
-uniform vec3 OuterColor2;
-
-void main()
-{
- float real = Position.x * Zoom + Xcenter;
- float imag = Position.y * Zoom + Ycenter;
- float Creal = real; // Change this line...
- float Cimag = imag; // ...and this one to get a Julia set
-
- float r2 = 0.0;
- float iter;
-
-// for (iter = 0.0; iter < MaxIterations && r2 < 4.0; ++iter)
- for (iter = 0.0; iter < 12 && r2 < 4.0; ++iter)
- {
- float tempreal = real;
-
- real = (tempreal * tempreal) - (imag * imag) + Creal;
- imag = 2.0 * tempreal * imag + Cimag;
- r2 = (real * real) + (imag * imag);
- }
-
- // Base the color on the number of iterations
-
- vec3 color;
-
- if (r2 < 4.0)
- color = InnerColor;
- else
- color = mix(OuterColor1, OuterColor2, fract(iter * 0.05));
-
- color *= LightIntensity;
-
- gl_FragColor = vec4(color, 1.0);
-}
--- /dev/null
+//
+// Vertex shader for drawing the Mandelbrot set
+//
+// Authors: Dave Baldwin, Steve Koren, Randi Rost
+// based on a shader by Michael Rivero
+//
+// Copyright (c) 2002-2005: 3Dlabs, Inc.
+//
+// See 3Dlabs-License.txt for license information
+//
+
+uniform vec3 LightPosition;
+uniform float SpecularContribution;
+uniform float DiffuseContribution;
+uniform float Shininess;
+
+varying float LightIntensity;
+varying vec3 Position;
+
+void main()
+{
+ vec3 ecPosition = vec3(gl_ModelViewMatrix * gl_Vertex);
+ vec3 tnorm = normalize(gl_NormalMatrix * gl_Normal);
+ vec3 lightVec = normalize(LightPosition - ecPosition);
+ vec3 reflectVec = reflect(-lightVec, tnorm);
+ vec3 viewVec = normalize(-ecPosition);
+ float spec = max(dot(reflectVec, viewVec), 0.0);
+ spec = pow(spec, Shininess);
+ LightIntensity = DiffuseContribution *
+ max(dot(lightVec, tnorm), 0.0) +
+ SpecularContribution * spec;
+ Position = vec3(gl_MultiTexCoord0 - 0.5) * 5.0;
+ gl_Position = ftransform();
+
+}
\ No newline at end of file
+++ /dev/null
-//
-// Vertex shader for drawing the Mandelbrot set
-//
-// Authors: Dave Baldwin, Steve Koren, Randi Rost
-// based on a shader by Michael Rivero
-//
-// Copyright (c) 2002-2005: 3Dlabs, Inc.
-//
-// See 3Dlabs-License.txt for license information
-//
-
-uniform vec3 LightPosition;
-uniform float SpecularContribution;
-uniform float DiffuseContribution;
-uniform float Shininess;
-
-varying float LightIntensity;
-varying vec3 Position;
-
-void main()
-{
- vec3 ecPosition = vec3(gl_ModelViewMatrix * gl_Vertex);
- vec3 tnorm = normalize(gl_NormalMatrix * gl_Normal);
- vec3 lightVec = normalize(LightPosition - ecPosition);
- vec3 reflectVec = reflect(-lightVec, tnorm);
- vec3 viewVec = normalize(-ecPosition);
- float spec = max(dot(reflectVec, viewVec), 0.0);
- spec = pow(spec, Shininess);
- LightIntensity = DiffuseContribution *
- max(dot(lightVec, tnorm), 0.0) +
- SpecularContribution * spec;
- Position = vec3(gl_MultiTexCoord0 - 0.5) * 5.0;
- gl_Position = ftransform();
-
-}
\ No newline at end of file
#include "shaderutil.h"
-static char *FragProgFile = "CH06-brick.frag.txt";
-static char *VertProgFile = "CH06-brick.vert.txt";
+static char *FragProgFile = "CH06-brick.frag";
+static char *VertProgFile = "CH06-brick.vert";
/* program/shader objects */
static GLuint fragShader;
#include "shaderutil.h"
-static char *FragProgFile = "CH11-bumpmap.frag.txt";
-static char *VertProgFile = "CH11-bumpmap.vert.txt";
+static char *FragProgFile = "CH11-bumpmap.frag";
+static char *VertProgFile = "CH11-bumpmap.vert";
/* program/shader objects */
static GLuint fragShader;
--- /dev/null
+// Fragment shader for cube-texture reflection mapping
+// Brian Paul
+
+
+uniform samplerCube cubeTex;
+varying vec3 normal;
+uniform vec3 lightPos;
+
+void main()
+{
+ // simple diffuse, specular lighting:
+ vec3 lp = normalize(lightPos);
+ float dp = dot(lp, normalize(normal));
+ float spec = pow(dp, 5.0);
+
+ // final color:
+ gl_FragColor = dp * textureCube(cubeTex, gl_TexCoord[0].xyz, 0.0) + spec;
+}
+++ /dev/null
-// Fragment shader for cube-texture reflection mapping
-// Brian Paul
-
-
-uniform samplerCube cubeTex;
-varying vec3 normal;
-uniform vec3 lightPos;
-
-void main()
-{
- // simple diffuse, specular lighting:
- vec3 lp = normalize(lightPos);
- float dp = dot(lp, normalize(normal));
- float spec = pow(dp, 5.0);
-
- // final color:
- gl_FragColor = dp * textureCube(cubeTex, gl_TexCoord[0].xyz, 0.0) + spec;
-}
#include "shaderutil.h"
-static char *FragProgFile = "CH18-mandel.frag.txt";
-static char *VertProgFile = "CH18-mandel.vert.txt";
+static char *FragProgFile = "CH18-mandel.frag";
+static char *VertProgFile = "CH18-mandel.vert";
/* program/shader objects */
static GLuint fragShader;
static const char *Demo = "multitex";
-static const char *VertFile = "multitex.vert.txt";
-static const char *FragFile = "multitex.frag.txt";
+static const char *VertFile = "multitex.vert";
+static const char *FragFile = "multitex.frag";
static const char *TexFiles[2] =
{
--- /dev/null
+// Multi-texture fragment shader
+// Brian Paul
+
+// Composite second texture over first.
+// We're assuming the 2nd texture has a meaningful alpha channel.
+
+uniform sampler2D tex1;
+uniform sampler2D tex2;
+
+void main()
+{
+ vec4 t1 = texture2D(tex1, gl_TexCoord[0].xy);
+ vec4 t2 = texture2D(tex2, gl_TexCoord[1].xy);
+ gl_FragColor = mix(t1, t2, t2.w);
+}
+++ /dev/null
-// Multi-texture fragment shader
-// Brian Paul
-
-// Composite second texture over first.
-// We're assuming the 2nd texture has a meaningful alpha channel.
-
-uniform sampler2D tex1;
-uniform sampler2D tex2;
-
-void main()
-{
- vec4 t1 = texture2D(tex1, gl_TexCoord[0].xy);
- vec4 t2 = texture2D(tex2, gl_TexCoord[1].xy);
- gl_FragColor = mix(t1, t2, t2.w);
-}
--- /dev/null
+// Multi-texture vertex shader
+// Brian Paul
+
+
+void main()
+{
+ gl_TexCoord[0] = gl_MultiTexCoord0;
+ gl_TexCoord[1] = gl_MultiTexCoord1;
+ gl_Position = ftransform();
+}
+++ /dev/null
-// Multi-texture vertex shader
-// Brian Paul
-
-
-void main()
-{
- gl_TexCoord[0] = gl_MultiTexCoord0;
- gl_TexCoord[1] = gl_MultiTexCoord1;
- gl_Position = ftransform();
-}
--- /dev/null
+// Vertex shader for cube-texture reflection mapping
+// Brian Paul
+
+
+varying vec3 normal;
+
+void main()
+{
+ vec3 n = gl_NormalMatrix * gl_Normal;
+ vec3 u = normalize(vec3(gl_ModelViewMatrix * gl_Vertex));
+ float two_n_dot_u = 2.0 * dot(n, u);
+ vec4 f;
+ f.xyz = u - n * two_n_dot_u;
+
+ // outputs
+ normal = n;
+ gl_TexCoord[0] = gl_TextureMatrix[0] * f;
+ gl_Position = ftransform();
+}
+++ /dev/null
-// Vertex shader for cube-texture reflection mapping
-// Brian Paul
-
-
-varying vec3 normal;
-
-void main()
-{
- vec3 n = gl_NormalMatrix * gl_Normal;
- vec3 u = normalize(vec3(gl_ModelViewMatrix * gl_Vertex));
- float two_n_dot_u = 2.0 * dot(n, u);
- vec4 f;
- f.xyz = u - n * two_n_dot_u;
-
- // outputs
- normal = n;
- gl_TexCoord[0] = gl_TextureMatrix[0] * f;
- gl_Position = ftransform();
-}
--- /dev/null
+// Fragment shader for 2D texture with shadow attenuation
+// Brian Paul
+
+
+uniform sampler2D tex2d;
+uniform vec3 lightPos;
+
+void main()
+{
+ // XXX should compute this from lightPos
+ vec2 shadowCenter = vec2(-0.25, -0.25);
+
+ // d = distance from center
+ float d = distance(gl_TexCoord[0].xy, shadowCenter);
+
+ // attenuate and clamp
+ d = clamp(d * d * d, 0.0, 2.0);
+
+ // modulate texture by d for shadow effect
+ gl_FragColor = d * texture2D(tex2d, gl_TexCoord[0].xy, 0.0);
+}
+++ /dev/null
-// Fragment shader for 2D texture with shadow attenuation
-// Brian Paul
-
-
-uniform sampler2D tex2d;
-uniform vec3 lightPos;
-
-void main()
-{
- // XXX should compute this from lightPos
- vec2 shadowCenter = vec2(-0.25, -0.25);
-
- // d = distance from center
- float d = distance(gl_TexCoord[0].xy, shadowCenter);
-
- // attenuate and clamp
- d = clamp(d * d * d, 0.0, 2.0);
-
- // modulate texture by d for shadow effect
- gl_FragColor = d * texture2D(tex2d, gl_TexCoord[0].xy, 0.0);
-}
--- /dev/null
+// Simple vertex shader
+// Brian Paul
+
+
+void main()
+{
+ gl_TexCoord[0] = gl_MultiTexCoord0;
+ gl_Position = ftransform();
+}
+++ /dev/null
-// Simple vertex shader
-// Brian Paul
-
-
-void main()
-{
- gl_TexCoord[0] = gl_MultiTexCoord0;
- gl_Position = ftransform();
-}
static const char *Demo = "texdemo1";
-static const char *ReflectVertFile = "reflect.vert.txt";
-static const char *CubeFragFile = "cubemap.frag.txt";
+static const char *ReflectVertFile = "reflect.vert";
+static const char *CubeFragFile = "cubemap.frag";
-static const char *SimpleVertFile = "simple.vert.txt";
-static const char *SimpleTexFragFile = "shadowtex.frag.txt";
+static const char *SimpleVertFile = "simple.vert";
+static const char *SimpleTexFragFile = "shadowtex.frag";
static const char *GroundImage = "../images/tile.rgb";
#include "shaderutil.h"
-static char *FragProgFile = "CH11-toyball.frag.txt";
-static char *VertProgFile = "CH11-toyball.vert.txt";
+static char *FragProgFile = "CH11-toyball.frag";
+static char *VertProgFile = "CH11-toyball.vert";
/* program/shader objects */
static GLuint fragShader;