void shader(float *color) { int i; vec_set(color,0,0,0); for(i=0 ; i<numLights ; i++) { float tmp[3]; float dot = -vec_dot(lights[i].direction,surfaceNormal); vec_scale2(dot,lights[i].color,tmp); vec_comp_mult(tmp,diffuseColor,tmp); vec_add(tmp,color,color); } vec_clamp(color, 0, 1); }
# # This stuff has nothing to do with the shader, only scene layout # string patchObject = models/patches/teapot.obj int loDice = 10 int hiDice = 20 int zNear = 10 float fieldOfView = 90 vec eyePosition = 0 0 20 int numLights = 2 vec light0Pos = 0 20 40 color light0Color = 1 0 0 vec light1Pos = 0 -20 40 color light1Color = 0 1 0 # # Shader variables go here # color diffuseColor = 0.5 0.5 0.5 string whichShader = directional