drawEgg = regl({
vert: `
precision highp float;
attribute vec3 aPosition, aNormal;
uniform mat4 projectionView;
uniform float time;
varying vec3 position, normal;
void main () {
position = aPosition;
normal = aNormal;
gl_Position = projectionView * vec4(position, 1);
}
`,
frag: `
precision highp float;
varying vec3 position, normal;
uniform vec3 eye; // Position of the camera, for use in lighting
uniform float time;
vec3 applyGamma (vec3 c, float gamma) {
return vec3(pow(c.r, gamma), pow(c.g, gamma), pow(c.b, gamma));
}
void main () {
// Define your coloring function here!
vec3 color = vec3(
0.5 +
0.3 * cos(position * 5.0) *
sin(position * 10.0 - 4.0 * time)
);
gl_FragColor = vec4(applyGamma(color, (1.0 / 2.2)), 1);
}
`,
attributes: {
aPosition: regl.prop('positions'),
aNormal: regl.prop('normals')
},
cull: { enable: true, face: 'back' },
elements: regl.prop('cells')
})