drawSphere = regl({
frag: `
precision mediump float;
uniform vec4 color;
varying vec3 vertex_normal;
uniform vec3 light_dir;
void main () {
gl_FragColor = vec4(clamp(color.xyz*dot(vertex_normal,light_dir),0.0,1.0),1.0);
}`,
vert: `
attribute vec3 position;
attribute vec3 normal;
varying vec3 vertex_normal;
uniform mat4 modelview;
void main () {
gl_Position = modelview*vec4(position, 1.0);
vertex_normal = normal; //(modelview*vec4(normal,1.0)).xyz;
}`,
attributes: {
position: sphere.pos,
normal: sphere.normal
},
uniforms: {
color: [1, 1, 1, 1],
light_dir : [0.7,0.7,0.7],
modelview : regl.prop('modelview')
},
depth: {
enable: true,
mask: true,
func: '>',
range: [0, 1]
},
elements: sphere.faces
})