From c0dd9122fdedd4bcab5bc0b3bbb490e6b62fac83 Mon Sep 17 00:00:00 2001 From: Brian Paul Date: Sat, 16 Aug 2008 09:36:46 -0600 Subject: remove .txt suffix from shader source files --- progs/glsl/CH06-brick.frag | 36 +++++++++++++++++++ progs/glsl/CH06-brick.frag.txt | 36 ------------------- progs/glsl/CH06-brick.vert | 41 ++++++++++++++++++++++ progs/glsl/CH06-brick.vert.txt | 41 ---------------------- progs/glsl/CH11-bumpmap.frag | 41 ++++++++++++++++++++++ progs/glsl/CH11-bumpmap.frag.txt | 41 ---------------------- progs/glsl/CH11-bumpmap.vert | 38 ++++++++++++++++++++ progs/glsl/CH11-bumpmap.vert.txt | 38 -------------------- progs/glsl/CH11-toyball.frag | 75 ++++++++++++++++++++++++++++++++++++++++ progs/glsl/CH11-toyball.frag.txt | 75 ---------------------------------------- progs/glsl/CH11-toyball.vert | 24 +++++++++++++ progs/glsl/CH11-toyball.vert.txt | 24 ------------- progs/glsl/CH18-mandel.frag | 55 +++++++++++++++++++++++++++++ progs/glsl/CH18-mandel.frag.txt | 55 ----------------------------- progs/glsl/CH18-mandel.vert | 35 +++++++++++++++++++ progs/glsl/CH18-mandel.vert.txt | 35 ------------------- progs/glsl/brick.c | 4 +-- progs/glsl/bump.c | 4 +-- progs/glsl/cubemap.frag | 18 ++++++++++ progs/glsl/cubemap.frag.txt | 18 ---------- progs/glsl/mandelbrot.c | 4 +-- progs/glsl/multitex.c | 4 +-- progs/glsl/multitex.frag | 15 ++++++++ progs/glsl/multitex.frag.txt | 15 -------- progs/glsl/multitex.vert | 10 ++++++ progs/glsl/multitex.vert.txt | 10 ------ progs/glsl/reflect.vert | 19 ++++++++++ progs/glsl/reflect.vert.txt | 19 ---------- progs/glsl/shadowtex.frag | 21 +++++++++++ progs/glsl/shadowtex.frag.txt | 21 ----------- progs/glsl/simple.vert | 9 +++++ progs/glsl/simple.vert.txt | 9 ----- progs/glsl/texdemo1.c | 8 ++--- progs/glsl/toyball.c | 4 +-- 34 files changed, 451 insertions(+), 451 deletions(-) create mode 100644 progs/glsl/CH06-brick.frag delete mode 100644 progs/glsl/CH06-brick.frag.txt create mode 100644 progs/glsl/CH06-brick.vert delete mode 100644 progs/glsl/CH06-brick.vert.txt create mode 100644 progs/glsl/CH11-bumpmap.frag delete mode 100644 progs/glsl/CH11-bumpmap.frag.txt create mode 100644 progs/glsl/CH11-bumpmap.vert delete mode 100644 progs/glsl/CH11-bumpmap.vert.txt create mode 100644 progs/glsl/CH11-toyball.frag delete mode 100644 progs/glsl/CH11-toyball.frag.txt create mode 100644 progs/glsl/CH11-toyball.vert delete mode 100644 progs/glsl/CH11-toyball.vert.txt create mode 100644 progs/glsl/CH18-mandel.frag delete mode 100644 progs/glsl/CH18-mandel.frag.txt create mode 100644 progs/glsl/CH18-mandel.vert delete mode 100644 progs/glsl/CH18-mandel.vert.txt create mode 100644 progs/glsl/cubemap.frag delete mode 100644 progs/glsl/cubemap.frag.txt create mode 100644 progs/glsl/multitex.frag delete mode 100644 progs/glsl/multitex.frag.txt create mode 100644 progs/glsl/multitex.vert delete mode 100644 progs/glsl/multitex.vert.txt create mode 100644 progs/glsl/reflect.vert delete mode 100644 progs/glsl/reflect.vert.txt create mode 100644 progs/glsl/shadowtex.frag delete mode 100644 progs/glsl/shadowtex.frag.txt create mode 100644 progs/glsl/simple.vert delete mode 100644 progs/glsl/simple.vert.txt diff --git a/progs/glsl/CH06-brick.frag b/progs/glsl/CH06-brick.frag new file mode 100644 index 0000000000..06ef04e3af --- /dev/null +++ b/progs/glsl/CH06-brick.frag @@ -0,0 +1,36 @@ +// +// 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); +} diff --git a/progs/glsl/CH06-brick.frag.txt b/progs/glsl/CH06-brick.frag.txt deleted file mode 100644 index 06ef04e3af..0000000000 --- a/progs/glsl/CH06-brick.frag.txt +++ /dev/null @@ -1,36 +0,0 @@ -// -// 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); -} diff --git a/progs/glsl/CH06-brick.vert b/progs/glsl/CH06-brick.vert new file mode 100644 index 0000000000..e95e6f42f0 --- /dev/null +++ b/progs/glsl/CH06-brick.vert @@ -0,0 +1,41 @@ +// +// 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(); +} diff --git a/progs/glsl/CH06-brick.vert.txt b/progs/glsl/CH06-brick.vert.txt deleted file mode 100644 index e95e6f42f0..0000000000 --- a/progs/glsl/CH06-brick.vert.txt +++ /dev/null @@ -1,41 +0,0 @@ -// -// 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(); -} diff --git a/progs/glsl/CH11-bumpmap.frag b/progs/glsl/CH11-bumpmap.frag new file mode 100644 index 0000000000..063576f5a3 --- /dev/null +++ b/progs/glsl/CH11-bumpmap.frag @@ -0,0 +1,41 @@ +// +// 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); +} diff --git a/progs/glsl/CH11-bumpmap.frag.txt b/progs/glsl/CH11-bumpmap.frag.txt deleted file mode 100644 index 063576f5a3..0000000000 --- a/progs/glsl/CH11-bumpmap.frag.txt +++ /dev/null @@ -1,41 +0,0 @@ -// -// 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); -} diff --git a/progs/glsl/CH11-bumpmap.vert b/progs/glsl/CH11-bumpmap.vert new file mode 100644 index 0000000000..d3d19f62ac --- /dev/null +++ b/progs/glsl/CH11-bumpmap.vert @@ -0,0 +1,38 @@ +// +// 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); +} diff --git a/progs/glsl/CH11-bumpmap.vert.txt b/progs/glsl/CH11-bumpmap.vert.txt deleted file mode 100644 index d3d19f62ac..0000000000 --- a/progs/glsl/CH11-bumpmap.vert.txt +++ /dev/null @@ -1,38 +0,0 @@ -// -// 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); -} diff --git a/progs/glsl/CH11-toyball.frag b/progs/glsl/CH11-toyball.frag new file mode 100644 index 0000000000..90ec1c27fc --- /dev/null +++ b/progs/glsl/CH11-toyball.frag @@ -0,0 +1,75 @@ +// +// 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; +} diff --git a/progs/glsl/CH11-toyball.frag.txt b/progs/glsl/CH11-toyball.frag.txt deleted file mode 100644 index 90ec1c27fc..0000000000 --- a/progs/glsl/CH11-toyball.frag.txt +++ /dev/null @@ -1,75 +0,0 @@ -// -// 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; -} diff --git a/progs/glsl/CH11-toyball.vert b/progs/glsl/CH11-toyball.vert new file mode 100644 index 0000000000..b7da3ac839 --- /dev/null +++ b/progs/glsl/CH11-toyball.vert @@ -0,0 +1,24 @@ +// +// 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(); +} diff --git a/progs/glsl/CH11-toyball.vert.txt b/progs/glsl/CH11-toyball.vert.txt deleted file mode 100644 index b7da3ac839..0000000000 --- a/progs/glsl/CH11-toyball.vert.txt +++ /dev/null @@ -1,24 +0,0 @@ -// -// 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(); -} diff --git a/progs/glsl/CH18-mandel.frag b/progs/glsl/CH18-mandel.frag new file mode 100644 index 0000000000..a472d81252 --- /dev/null +++ b/progs/glsl/CH18-mandel.frag @@ -0,0 +1,55 @@ +// +// 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); +} diff --git a/progs/glsl/CH18-mandel.frag.txt b/progs/glsl/CH18-mandel.frag.txt deleted file mode 100644 index a472d81252..0000000000 --- a/progs/glsl/CH18-mandel.frag.txt +++ /dev/null @@ -1,55 +0,0 @@ -// -// 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); -} diff --git a/progs/glsl/CH18-mandel.vert b/progs/glsl/CH18-mandel.vert new file mode 100644 index 0000000000..c4ca66405d --- /dev/null +++ b/progs/glsl/CH18-mandel.vert @@ -0,0 +1,35 @@ +// +// 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 diff --git a/progs/glsl/CH18-mandel.vert.txt b/progs/glsl/CH18-mandel.vert.txt deleted file mode 100644 index c4ca66405d..0000000000 --- a/progs/glsl/CH18-mandel.vert.txt +++ /dev/null @@ -1,35 +0,0 @@ -// -// 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 diff --git a/progs/glsl/brick.c b/progs/glsl/brick.c index 4be266622b..526ef0e2e3 100644 --- a/progs/glsl/brick.c +++ b/progs/glsl/brick.c @@ -16,8 +16,8 @@ #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; diff --git a/progs/glsl/bump.c b/progs/glsl/bump.c index e42421d489..a2e0916861 100644 --- a/progs/glsl/bump.c +++ b/progs/glsl/bump.c @@ -16,8 +16,8 @@ #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; diff --git a/progs/glsl/cubemap.frag b/progs/glsl/cubemap.frag new file mode 100644 index 0000000000..9c27648aaf --- /dev/null +++ b/progs/glsl/cubemap.frag @@ -0,0 +1,18 @@ +// 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; +} diff --git a/progs/glsl/cubemap.frag.txt b/progs/glsl/cubemap.frag.txt deleted file mode 100644 index 9c27648aaf..0000000000 --- a/progs/glsl/cubemap.frag.txt +++ /dev/null @@ -1,18 +0,0 @@ -// 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; -} diff --git a/progs/glsl/mandelbrot.c b/progs/glsl/mandelbrot.c index fa67a3c2ca..e6361b429b 100644 --- a/progs/glsl/mandelbrot.c +++ b/progs/glsl/mandelbrot.c @@ -16,8 +16,8 @@ #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; diff --git a/progs/glsl/multitex.c b/progs/glsl/multitex.c index 5574ed4139..096d40f64d 100644 --- a/progs/glsl/multitex.c +++ b/progs/glsl/multitex.c @@ -35,8 +35,8 @@ 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] = { diff --git a/progs/glsl/multitex.frag b/progs/glsl/multitex.frag new file mode 100644 index 0000000000..a2633ceba7 --- /dev/null +++ b/progs/glsl/multitex.frag @@ -0,0 +1,15 @@ +// 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); +} diff --git a/progs/glsl/multitex.frag.txt b/progs/glsl/multitex.frag.txt deleted file mode 100644 index a2633ceba7..0000000000 --- a/progs/glsl/multitex.frag.txt +++ /dev/null @@ -1,15 +0,0 @@ -// 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); -} diff --git a/progs/glsl/multitex.vert b/progs/glsl/multitex.vert new file mode 100644 index 0000000000..5518ca1ddd --- /dev/null +++ b/progs/glsl/multitex.vert @@ -0,0 +1,10 @@ +// Multi-texture vertex shader +// Brian Paul + + +void main() +{ + gl_TexCoord[0] = gl_MultiTexCoord0; + gl_TexCoord[1] = gl_MultiTexCoord1; + gl_Position = ftransform(); +} diff --git a/progs/glsl/multitex.vert.txt b/progs/glsl/multitex.vert.txt deleted file mode 100644 index 5518ca1ddd..0000000000 --- a/progs/glsl/multitex.vert.txt +++ /dev/null @@ -1,10 +0,0 @@ -// Multi-texture vertex shader -// Brian Paul - - -void main() -{ - gl_TexCoord[0] = gl_MultiTexCoord0; - gl_TexCoord[1] = gl_MultiTexCoord1; - gl_Position = ftransform(); -} diff --git a/progs/glsl/reflect.vert b/progs/glsl/reflect.vert new file mode 100644 index 0000000000..402be38bf7 --- /dev/null +++ b/progs/glsl/reflect.vert @@ -0,0 +1,19 @@ +// 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(); +} diff --git a/progs/glsl/reflect.vert.txt b/progs/glsl/reflect.vert.txt deleted file mode 100644 index 402be38bf7..0000000000 --- a/progs/glsl/reflect.vert.txt +++ /dev/null @@ -1,19 +0,0 @@ -// 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(); -} diff --git a/progs/glsl/shadowtex.frag b/progs/glsl/shadowtex.frag new file mode 100644 index 0000000000..a6a80da47f --- /dev/null +++ b/progs/glsl/shadowtex.frag @@ -0,0 +1,21 @@ +// 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); +} diff --git a/progs/glsl/shadowtex.frag.txt b/progs/glsl/shadowtex.frag.txt deleted file mode 100644 index a6a80da47f..0000000000 --- a/progs/glsl/shadowtex.frag.txt +++ /dev/null @@ -1,21 +0,0 @@ -// 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); -} diff --git a/progs/glsl/simple.vert b/progs/glsl/simple.vert new file mode 100644 index 0000000000..a0abe0dc0b --- /dev/null +++ b/progs/glsl/simple.vert @@ -0,0 +1,9 @@ +// Simple vertex shader +// Brian Paul + + +void main() +{ + gl_TexCoord[0] = gl_MultiTexCoord0; + gl_Position = ftransform(); +} diff --git a/progs/glsl/simple.vert.txt b/progs/glsl/simple.vert.txt deleted file mode 100644 index a0abe0dc0b..0000000000 --- a/progs/glsl/simple.vert.txt +++ /dev/null @@ -1,9 +0,0 @@ -// Simple vertex shader -// Brian Paul - - -void main() -{ - gl_TexCoord[0] = gl_MultiTexCoord0; - gl_Position = ftransform(); -} diff --git a/progs/glsl/texdemo1.c b/progs/glsl/texdemo1.c index 3dd19eaf4b..41010746ee 100644 --- a/progs/glsl/texdemo1.c +++ b/progs/glsl/texdemo1.c @@ -35,11 +35,11 @@ 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"; diff --git a/progs/glsl/toyball.c b/progs/glsl/toyball.c index b870435f66..2daaedd6df 100644 --- a/progs/glsl/toyball.c +++ b/progs/glsl/toyball.c @@ -16,8 +16,8 @@ #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; -- cgit v1.2.3