Graphics Programs Reference
In-Depth Information
+ "uniform mat4 uMV; \n"
+ "uniform mat4 uMVP; \n"
+ "uniform mat4 uMVLight; \n"
+ "const vec4 lightPositionWorld = vec4(10.0, 10.0,
0.0, 1.0); \n"
+ "void main() { \n"
+ " vec4 vertex = vec4(aPosition, aPosition,
aPosition, 1.0); \n"
+ " \n"
+ " vec3 normal = normalize(vec3(uNormal * aNormal));
\n"
+ " // vec3 normal = vec3(uNormal * aNormal); \n"
+ " vec4 vertexEye = vec4(uMV * vertex); \n"
+ " vec4 lightPositionEye = vec4(uMVLight *
lightPositionWorld); \n"
+ " vec3 ds = normalize(vec3(lightPositionEye -
vertexEye)); \n"
+ " // vec3 ds = vec3(lightPositionEye - vertexEye);
\n"
+ " \n"
+ " // diffuseIntensity = Ld * Kd * max(dot(ds,
normal), ambientIntensity); \n"
+ " diffuseIntensity = max(dot(ds, normal), 0.210);
\n"
+ " diffuseIntensity = 0.570 * 0.210 *
diffuseIntensity; \n"
+ " \n"
+ " gl_Position = vec4(uMVP * vertex); // ensures
that we provide a vec4 \n"
+ "} \n";
▪ Finally, obtain the S vector for the current vertex by taking its dif-
ference with the light source position. The variable ds
5-16 ) stores this difference.
▪ To determine the intensity of outgoing light ( Iout ) at the current
vertex, take the dot product of ds and normal vectors, using the
built-in function dot(vec*, vec*) .
Search WWH ::

Custom Search