Updated shader examples

This commit is contained in:
codeanticode
2013-02-06 17:11:17 -05:00
parent a21a4fbe21
commit 121cba45a9
15 changed files with 178 additions and 156 deletions
@@ -3,38 +3,40 @@ precision mediump float;
precision mediump int;
#endif
uniform sampler2D textureSampler;
uniform vec2 texcoordOffset;
#define PROCESSING_TEXTURE_SHADER
uniform sampler2D texture;
uniform vec2 texOffset;
varying vec4 vertColor;
varying vec4 vertTexcoord;
varying vec4 vertTexCoord;
void main(void) {
// Grouping texcoord variables in order to make it work in the GMA 950. See post #13
// in this thread:
// http://www.idevgames.com/forums/thread-3467.html
vec2 tc0 = vertTexcoord.st + vec2(-texcoordOffset.s, -texcoordOffset.t);
vec2 tc1 = vertTexcoord.st + vec2( 0.0, -texcoordOffset.t);
vec2 tc2 = vertTexcoord.st + vec2(+texcoordOffset.s, -texcoordOffset.t);
vec2 tc3 = vertTexcoord.st + vec2(-texcoordOffset.s, 0.0);
vec2 tc4 = vertTexcoord.st + vec2( 0.0, 0.0);
vec2 tc5 = vertTexcoord.st + vec2(+texcoordOffset.s, 0.0);
vec2 tc6 = vertTexcoord.st + vec2(-texcoordOffset.s, +texcoordOffset.t);
vec2 tc7 = vertTexcoord.st + vec2( 0.0, +texcoordOffset.t);
vec2 tc8 = vertTexcoord.st + vec2(+texcoordOffset.s, +texcoordOffset.t);
vec4 col0 = texture2D(textureSampler, tc0);
vec4 col1 = texture2D(textureSampler, tc1);
vec4 col2 = texture2D(textureSampler, tc2);
vec4 col3 = texture2D(textureSampler, tc3);
vec4 col4 = texture2D(textureSampler, tc4);
vec4 col5 = texture2D(textureSampler, tc5);
vec4 col6 = texture2D(textureSampler, tc6);
vec4 col7 = texture2D(textureSampler, tc7);
vec4 col8 = texture2D(textureSampler, tc8);
vec2 tc0 = vertTexCoord.st + vec2(-texOffset.s, -texOffset.t);
vec2 tc1 = vertTexCoord.st + vec2( 0.0, -texOffset.t);
vec2 tc2 = vertTexCoord.st + vec2(+texOffset.s, -texOffset.t);
vec2 tc3 = vertTexCoord.st + vec2(-texOffset.s, 0.0);
vec2 tc4 = vertTexCoord.st + vec2( 0.0, 0.0);
vec2 tc5 = vertTexCoord.st + vec2(+texOffset.s, 0.0);
vec2 tc6 = vertTexCoord.st + vec2(-texOffset.s, +texOffset.t);
vec2 tc7 = vertTexCoord.st + vec2( 0.0, +texOffset.t);
vec2 tc8 = vertTexCoord.st + vec2(+texOffset.s, +texOffset.t);
vec4 col0 = texture2D(texture, tc0);
vec4 col1 = texture2D(texture, tc1);
vec4 col2 = texture2D(texture, tc2);
vec4 col3 = texture2D(texture, tc3);
vec4 col4 = texture2D(texture, tc4);
vec4 col5 = texture2D(texture, tc5);
vec4 col6 = texture2D(texture, tc6);
vec4 col7 = texture2D(texture, tc7);
vec4 col8 = texture2D(texture, tc8);
vec4 sum = (1.0 * col0 + 2.0 * col1 + 1.0 * col2 +
2.0 * col3 + 4.0 * col4 + 2.0 * col4 +
1.0 * col5 + 2.0 * col6 + 1.0 * col7) / 16.0;
gl_FragColor = vec4(sum.rgb, 1.0) * vertColor;
gl_FragColor = vec4(sum.rgb, 1.0) * vertColor;
}
@@ -3,27 +3,29 @@ precision mediump float;
precision mediump int;
#endif
uniform sampler2D textureSampler;
#define PROCESSING_TEXTURE_SHADER
uniform sampler2D texture;
uniform float time;
uniform vec2 resolution;
uniform vec2 mouse;
void main(void) {
vec2 p = -1.0 + 2.0 * gl_FragCoord.xy / resolution.xy;
vec2 m = -1.0 + 2.0 * mouse.xy / resolution.xy;
vec2 p = -1.0 + 2.0 * gl_FragCoord.xy / resolution.xy;
vec2 m = -1.0 + 2.0 * mouse.xy / resolution.xy;
float a1 = atan(p.y - m.y, p.x - m.x);
float r1 = sqrt(dot(p - m, p - m));
float a2 = atan(p.y + m.y, p.x + m.x);
float r2 = sqrt(dot(p + m, p + m));
float a1 = atan(p.y - m.y, p.x - m.x);
float r1 = sqrt(dot(p - m, p - m));
float a2 = atan(p.y + m.y, p.x + m.x);
float r2 = sqrt(dot(p + m, p + m));
vec2 uv;
uv.x = 0.2 * time + (r1 - r2) * 0.25;
uv.y = sin(2.0 * (a1 - a2));
vec2 uv;
uv.x = 0.2 * time + (r1 - r2) * 0.25;
uv.y = sin(2.0 * (a1 - a2));
float w = r1 * r2 * 0.8;
vec3 col = texture2D(textureSampler, 0.5 - 0.495 * uv).xyz;
float w = r1 * r2 * 0.8;
vec3 col = texture2D(texture, 0.5 - 0.495 * uv).xyz;
gl_FragColor = vec4(col / (0.1 + w), 1.0);
gl_FragColor = vec4(col / (0.1 + w), 1.0);
}
@@ -3,35 +3,37 @@ precision mediump float;
precision mediump int;
#endif
uniform sampler2D textureSampler;
uniform vec2 texcoordOffset;
#define PROCESSING_TEXTURE_SHADER
uniform sampler2D texture;
uniform vec2 texOffset;
varying vec4 vertColor;
varying vec4 vertTexcoord;
varying vec4 vertTexCoord;
void main(void) {
// Grouping texcoord variables in order to make it work in the GMA 950. See post #13
// in this thread:
// http://www.idevgames.com/forums/thread-3467.html
vec2 tc0 = vertTexcoord.st + vec2(-texcoordOffset.s, -texcoordOffset.t);
vec2 tc1 = vertTexcoord.st + vec2( 0.0, -texcoordOffset.t);
vec2 tc2 = vertTexcoord.st + vec2(+texcoordOffset.s, -texcoordOffset.t);
vec2 tc3 = vertTexcoord.st + vec2(-texcoordOffset.s, 0.0);
vec2 tc4 = vertTexcoord.st + vec2( 0.0, 0.0);
vec2 tc5 = vertTexcoord.st + vec2(+texcoordOffset.s, 0.0);
vec2 tc6 = vertTexcoord.st + vec2(-texcoordOffset.s, +texcoordOffset.t);
vec2 tc7 = vertTexcoord.st + vec2( 0.0, +texcoordOffset.t);
vec2 tc8 = vertTexcoord.st + vec2(+texcoordOffset.s, +texcoordOffset.t);
vec2 tc0 = vertTexCoord.st + vec2(-texOffset.s, -texOffset.t);
vec2 tc1 = vertTexCoord.st + vec2( 0.0, -texOffset.t);
vec2 tc2 = vertTexCoord.st + vec2(+texOffset.s, -texOffset.t);
vec2 tc3 = vertTexCoord.st + vec2(-texOffset.s, 0.0);
vec2 tc4 = vertTexCoord.st + vec2( 0.0, 0.0);
vec2 tc5 = vertTexCoord.st + vec2(+texOffset.s, 0.0);
vec2 tc6 = vertTexCoord.st + vec2(-texOffset.s, +texOffset.t);
vec2 tc7 = vertTexCoord.st + vec2( 0.0, +texOffset.t);
vec2 tc8 = vertTexCoord.st + vec2(+texOffset.s, +texOffset.t);
vec4 col0 = texture2D(textureSampler, tc0);
vec4 col1 = texture2D(textureSampler, tc1);
vec4 col2 = texture2D(textureSampler, tc2);
vec4 col3 = texture2D(textureSampler, tc3);
vec4 col4 = texture2D(textureSampler, tc4);
vec4 col5 = texture2D(textureSampler, tc5);
vec4 col6 = texture2D(textureSampler, tc6);
vec4 col7 = texture2D(textureSampler, tc7);
vec4 col8 = texture2D(textureSampler, tc8);
vec4 col0 = texture2D(texture, tc0);
vec4 col1 = texture2D(texture, tc1);
vec4 col2 = texture2D(texture, tc2);
vec4 col3 = texture2D(texture, tc3);
vec4 col4 = texture2D(texture, tc4);
vec4 col5 = texture2D(texture, tc5);
vec4 col6 = texture2D(texture, tc6);
vec4 col7 = texture2D(texture, tc7);
vec4 col8 = texture2D(texture, tc8);
vec4 sum = 8.0 * col4 - (col0 + col1 + col2 + col3 + col5 + col6 + col7 + col8);
gl_FragColor = vec4(sum.rgb, 1.0) * vertColor;
@@ -3,35 +3,37 @@ precision mediump float;
precision mediump int;
#endif
uniform sampler2D textureSampler;
uniform vec2 texcoordOffset;
#define PROCESSING_TEXTURE_SHADER
uniform sampler2D texture;
uniform vec2 texOffset;
varying vec4 vertColor;
varying vec4 vertTexcoord;
varying vec4 vertTexCoord;
void main(void) {
// Grouping texcoord variables in order to make it work in the GMA 950. See post #13
// in this thread:
// http://www.idevgames.com/forums/thread-3467.html
vec2 tc0 = vertTexcoord.st + vec2(-texcoordOffset.s, -texcoordOffset.t);
vec2 tc1 = vertTexcoord.st + vec2( 0.0, -texcoordOffset.t);
vec2 tc2 = vertTexcoord.st + vec2(+texcoordOffset.s, -texcoordOffset.t);
vec2 tc3 = vertTexcoord.st + vec2(-texcoordOffset.s, 0.0);
vec2 tc4 = vertTexcoord.st + vec2( 0.0, 0.0);
vec2 tc5 = vertTexcoord.st + vec2(+texcoordOffset.s, 0.0);
vec2 tc6 = vertTexcoord.st + vec2(-texcoordOffset.s, +texcoordOffset.t);
vec2 tc7 = vertTexcoord.st + vec2( 0.0, +texcoordOffset.t);
vec2 tc8 = vertTexcoord.st + vec2(+texcoordOffset.s, +texcoordOffset.t);
vec2 tc0 = vertTexCoord.st + vec2(-texOffset.s, -texOffset.t);
vec2 tc1 = vertTexCoord.st + vec2( 0.0, -texOffset.t);
vec2 tc2 = vertTexCoord.st + vec2(+texOffset.s, -texOffset.t);
vec2 tc3 = vertTexCoord.st + vec2(-texOffset.s, 0.0);
vec2 tc4 = vertTexCoord.st + vec2( 0.0, 0.0);
vec2 tc5 = vertTexCoord.st + vec2(+texOffset.s, 0.0);
vec2 tc6 = vertTexCoord.st + vec2(-texOffset.s, +texOffset.t);
vec2 tc7 = vertTexCoord.st + vec2( 0.0, +texOffset.t);
vec2 tc8 = vertTexCoord.st + vec2(+texOffset.s, +texOffset.t);
vec4 col0 = texture2D(textureSampler, tc0);
vec4 col1 = texture2D(textureSampler, tc1);
vec4 col2 = texture2D(textureSampler, tc2);
vec4 col3 = texture2D(textureSampler, tc3);
vec4 col4 = texture2D(textureSampler, tc4);
vec4 col5 = texture2D(textureSampler, tc5);
vec4 col6 = texture2D(textureSampler, tc6);
vec4 col7 = texture2D(textureSampler, tc7);
vec4 col8 = texture2D(textureSampler, tc8);
vec4 col0 = texture2D(texture, tc0);
vec4 col1 = texture2D(texture, tc1);
vec4 col2 = texture2D(texture, tc2);
vec4 col3 = texture2D(texture, tc3);
vec4 col4 = texture2D(texture, tc4);
vec4 col5 = texture2D(texture, tc5);
vec4 col6 = texture2D(texture, tc6);
vec4 col7 = texture2D(texture, tc7);
vec4 col8 = texture2D(texture, tc8);
vec4 sum = 8.0 * col4 - (col0 + col1 + col2 + col3 + col5 + col6 + col7 + col8);
gl_FragColor = vec4(sum.rgb, 1.0) * vertColor;
@@ -10,11 +10,13 @@ precision mediump float;
precision mediump int;
#endif
uniform sampler2D textureSampler;
uniform mat4 texcoordMatrix;
#define PROCESSING_TEXTURE_SHADER
uniform sampler2D texture;
uniform mat4 texMatrix;
varying vec4 vertColor;
varying vec4 vertTexcoord;
varying vec4 vertTexCoord;
uniform float aperture;
@@ -31,8 +33,8 @@ void main(void) {
// The st factor takes into account the situation when non-pot
// textures are not supported, so that the maximum texture
// coordinate to cover the entire image might not be 1.
vec2 stFactor = vec2(1.0 / abs(texcoordMatrix[0][0]), 1.0 / abs(texcoordMatrix[1][1]));
vec2 pos = (2.0 * vertTexcoord.st * stFactor - 1.0);
vec2 stFactor = vec2(1.0 / abs(texMatrix[0][0]), 1.0 / abs(texMatrix[1][1]));
vec2 pos = (2.0 * vertTexCoord.st * stFactor - 1.0);
float l = length(pos);
if (l > 1.0) {
@@ -52,6 +54,6 @@ void main(void) {
float u = r * cos(phi) + 0.5;
float v = r * sin(phi) + 0.5;
gl_FragColor = texture2D(textureSampler, vec2(u, v) / stFactor) * vertColor;
gl_FragColor = texture2D(texture, vec2(u, v) / stFactor) * vertColor;
}
}
@@ -10,11 +10,13 @@ precision mediump float;
precision mediump int;
#endif
uniform sampler2D textureSampler;
uniform mat4 texcoordMatrix;
#define PROCESSING_TEXTURE_SHADER
uniform sampler2D texture;
uniform mat4 texMatrix;
varying vec4 vertColor;
varying vec4 vertTexcoord;
varying vec4 vertTexCoord;
uniform float aperture;
@@ -31,8 +33,8 @@ void main(void) {
// The st factor takes into account the situation when non-pot
// textures are not supported, so that the maximum texture
// coordinate to cover the entire image might not be 1.
vec2 stFactor = vec2(1.0 / abs(texcoordMatrix[0][0]), 1.0 / abs(texcoordMatrix[1][1]));
vec2 pos = (2.0 * vertTexcoord.st * stFactor - 1.0);
vec2 stFactor = vec2(1.0 / abs(texMatrix[0][0]), 1.0 / abs(texMatrix[1][1]));
vec2 pos = (2.0 * vertTexCoord.st * stFactor - 1.0);
float l = length(pos);
if (l > 1.0) {
@@ -52,6 +54,6 @@ void main(void) {
float u = r * cos(phi) + 0.5;
float v = r * sin(phi) + 0.5;
gl_FragColor = texture2D(textureSampler, vec2(u, v) / stFactor) * vertColor;
gl_FragColor = texture2D(texture, vec2(u, v) / stFactor) * vertColor;
}
}
@@ -27,19 +27,18 @@ varying vec3 P;
varying vec3 V;
varying vec3 L;
void main()
{
float w = 0.18*(1.0-Sharpness);
void main() {
float w = 0.18*(1.0-Sharpness);
vec3 l = normalize(L);
vec3 n = normalize(N);
vec3 v = normalize(V);
vec3 h = normalize(l+v);
vec3 l = normalize(L);
vec3 n = normalize(N);
vec3 v = normalize(V);
vec3 h = normalize(l+v);
float diffuse = dot(l,n);
float specular = smoothstep(0.72-w,0.72+w,pow(max(0.0,dot(n,h)),1.0/Roughness));
float diffuse = dot(l,n);
float specular = smoothstep(0.72-w,0.72+w,pow(max(0.0,dot(n,h)),1.0/Roughness));
gl_FragColor = vec4(AmbientColour*AmbientIntensity +
DiffuseColour*diffuse*DiffuseIntensity +
SpecularColour*specular*SpecularIntensity,1);
gl_FragColor = vec4(AmbientColour*AmbientIntensity +
DiffuseColour*diffuse*DiffuseIntensity +
SpecularColour*specular*SpecularIntensity,1);
}
@@ -7,14 +7,16 @@
// Useful for ceramic or fluids - from Advanced
// Renderman, thanks to Larry Gritz
uniform mat4 modelviewMatrix;
uniform mat4 projmodelviewMatrix;
#define PROCESSING_LIGHT_SHADER
uniform mat4 modelview;
uniform mat4 transform;
uniform mat3 normalMatrix;
uniform vec4 lightPosition[8];
attribute vec4 inVertex;
attribute vec3 inNormal;
attribute vec4 vertex;
attribute vec3 normal;
varying vec3 N;
varying vec3 P;
@@ -22,10 +24,10 @@ varying vec3 V;
varying vec3 L;
void main() {
N = normalize(normalMatrix * inNormal);
P = inVertex.xyz;
V = -vec3(modelviewMatrix * inVertex);
L = vec3(modelviewMatrix * (lightPosition[0] - inVertex));
gl_Position = projmodelviewMatrix * inVertex;
N = normalize(normalMatrix * normal);
P = vertex.xyz;
V = -vec3(modelview * vertex);
L = vec3(modelview * (lightPosition[0] - vertex));
gl_Position = transform * vertex;
}
@@ -14,7 +14,7 @@ void setup() {
maskImage = createGraphics(srcImage.width, srcImage.height, P2D);
maskImage.noSmooth();
maskShader = loadShader("mask.glsl");
maskShader.set("maskSampler", maskImage);
maskShader.set("mask", maskImage);
background(255);
}
@@ -3,15 +3,17 @@ precision mediump float;
precision mediump int;
#endif
uniform sampler2D textureSampler;
uniform sampler2D maskSampler;
#define PROCESSING_TEXTURE_SHADER
uniform vec2 texcoordOffset;
uniform sampler2D texture;
uniform sampler2D mask;
uniform vec2 texOffset;
varying vec4 vertColor;
varying vec4 vertTexcoord;
varying vec4 vertTexCoord;
void main() {
vec4 texColor = texture2D(textureSampler, vertTexcoord.st).rgba;
vec4 maskColor = texture2D(maskSampler, vec2(vertTexcoord.s, 1.0 - vertTexcoord.t)).rgba;
vec4 texColor = texture2D(texture, vertTexCoord.st).rgba;
vec4 maskColor = texture2D(mask, vec2(vertTexCoord.s, 1.0 - vertTexCoord.t)).rgba;
gl_FragColor = mix(texColor, vec4(0, 0, 0, 0), 1.0 - maskColor.r);
}
@@ -12,6 +12,7 @@
precision highp float;
#endif
#define PROCESSING_COLOR_SHADER
uniform vec2 resolution;
uniform float time;
@@ -1,29 +1,30 @@
#define PROCESSING_COLOR_SHADER
uniform vec2 resolution;
uniform float time;
void main(void)
{
vec2 p = -1.0 + 2.0 * gl_FragCoord.xy / resolution.xy;
float a = time*40.0;
float d,e,f,g=1.0/40.0,h,i,r,q;
e=400.0*(p.x*0.5+0.5);
f=400.0*(p.y*0.5+0.5);
i=200.0+sin(e*g+a/150.0)*20.0;
d=200.0+cos(f*g/2.0)*18.0+cos(e*g)*7.0;
r=sqrt(pow(i-e,2.0)+pow(d-f,2.0));
q=f/r;
e=(r*cos(q))-a/2.0;f=(r*sin(q))-a/2.0;
d=sin(e*g)*176.0+sin(e*g)*164.0+r;
h=((f+d)+a/2.0)*g;
i=cos(h+r*p.x/1.3)*(e+e+a)+cos(q*g*6.0)*(r+h/3.0);
h=sin(f*g)*144.0-sin(e*g)*212.0*p.x;
h=(h+(f-e)*q+sin(r-(a+h)/7.0)*10.0+i/4.0)*g;
i+=cos(h*2.3*sin(a/350.0-q))*184.0*sin(q-(r*4.3+a/12.0)*g)+tan(r*g+h)*184.0*cos(r*g+h);
i=mod(i/5.6,256.0)/64.0;
if(i<0.0) i+=4.0;
if(i>=2.0) i=4.0-i;
d=r/350.0;
d+=sin(d*d*8.0)*0.52;
f=(sin(a*g)+1.0)/2.0;
gl_FragColor=vec4(vec3(f*i/1.6,i/2.0+d/13.0,i)*d*p.x+vec3(i/1.3+d/8.0,i/2.0+d/18.0,i)*d*(1.0-p.x),1.0);
void main(void) {
vec2 p = -1.0 + 2.0 * gl_FragCoord.xy / resolution.xy;
float a = time*40.0;
float d,e,f,g=1.0/40.0,h,i,r,q;
e=400.0*(p.x*0.5+0.5);
f=400.0*(p.y*0.5+0.5);
i=200.0+sin(e*g+a/150.0)*20.0;
d=200.0+cos(f*g/2.0)*18.0+cos(e*g)*7.0;
r=sqrt(pow(i-e,2.0)+pow(d-f,2.0));
q=f/r;
e=(r*cos(q))-a/2.0;f=(r*sin(q))-a/2.0;
d=sin(e*g)*176.0+sin(e*g)*164.0+r;
h=((f+d)+a/2.0)*g;
i=cos(h+r*p.x/1.3)*(e+e+a)+cos(q*g*6.0)*(r+h/3.0);
h=sin(f*g)*144.0-sin(e*g)*212.0*p.x;
h=(h+(f-e)*q+sin(r-(a+h)/7.0)*10.0+i/4.0)*g;
i+=cos(h*2.3*sin(a/350.0-q))*184.0*sin(q-(r*4.3+a/12.0)*g)+tan(r*g+h)*184.0*cos(r*g+h);
i=mod(i/5.6,256.0)/64.0;
if(i<0.0) i+=4.0;
if(i>=2.0) i=4.0-i;
d=r/350.0;
d+=sin(d*d*8.0)*0.52;
f=(sin(a*g)+1.0)/2.0;
gl_FragColor=vec4(vec3(f*i/1.6,i/2.0+d/13.0,i)*d*p.x+vec3(i/1.3+d/8.0,i/2.0+d/18.0,i)*d*(1.0-p.x),1.0);
}
@@ -1,7 +1,8 @@
#define PROCESSING_COLOR_SHADER
uniform float time;
uniform vec2 resolution;
// NEBULA - CoffeeBreakStudios.com (CBS)
// Work in progress...
//
@@ -6,13 +6,15 @@ precision mediump float;
precision mediump int;
#endif
uniform sampler2D textureSampler;
#define PROCESSING_TEXTURE_SHADER
uniform sampler2D texture;
// The inverse of the texture dimensions along X and Y
uniform vec2 texcoordOffset;
uniform vec2 texOffset;
varying vec4 vertColor;
varying vec4 vertTexcoord;
varying vec4 vertTexCoord;
uniform int blurSize;
uniform int horizontalPass; // 0 or 1 to indicate vertical or horizontal pass
@@ -39,15 +41,15 @@ void main() {
float coefficientSum = 0.0;
// Take the central sample first...
avgValue += texture2D(textureSampler, vertTexcoord.st) * incrementalGaussian.x;
avgValue += texture2D(texture, vertTexCoord.st) * incrementalGaussian.x;
coefficientSum += incrementalGaussian.x;
incrementalGaussian.xy *= incrementalGaussian.yz;
// Go through the remaining 8 vertical samples (4 on each side of the center)
for (float i = 1.0; i <= numBlurPixelsPerSide; i++) {
avgValue += texture2D(textureSampler, vertTexcoord.st - i * texcoordOffset *
avgValue += texture2D(texture, vertTexCoord.st - i * texOffset *
blurMultiplyVec) * incrementalGaussian.x;
avgValue += texture2D(textureSampler, vertTexcoord.st + i * texcoordOffset *
avgValue += texture2D(texture, vertTexCoord.st + i * texOffset *
blurMultiplyVec) * incrementalGaussian.x;
coefficientSum += 2.0 * incrementalGaussian.x;
incrementalGaussian.xy *= incrementalGaussian.yz;
@@ -2,25 +2,27 @@
// tutorial from lighthouse 3D:
// http://www.lighthouse3d.com/tutorials/glsl-tutorial/toon-shader-version-ii/
uniform mat4 modelviewMatrix;
uniform mat4 projmodelviewMatrix;
#define PROCESSING_LIGHT_SHADER
uniform mat4 modelview;
uniform mat4 transform;
uniform mat3 normalMatrix;
uniform vec3 lightNormal[8];
attribute vec4 inVertex;
attribute vec3 inNormal;
attribute vec4 vertex;
attribute vec3 normal;
varying vec3 vertNormal;
varying vec3 vertLightDir;
void main() {
// Vertex in clip coordinates
gl_Position = projmodelviewMatrix * inVertex;
gl_Position = transform * vertex;
// Normal vector in eye coordinates is passed
// to the fragment shader
vertNormal = normalize(normalMatrix * inNormal);
vertNormal = normalize(normalMatrix * normal);
// Assuming that there is only one directional light.
// Its normal vector is passed to the fragment shader