Time for action – working on the wall
Open the file
ch3_Wall.html
in your HTML5 browse. You will see something similar to the following screenshot:Now, open the file again, this time in your favorite text editor (for example, Notepad ++).
Go to the vertex shader (Hint: look for the tag
<script id="shader-vs" type="x-shader/x-vertex">
). Make sure that you identify the attributes uniforms and varyings that are declared there.Now go to the fragment shader. Notice that there are no attributes here (Remember: attributes are exclusive of the vertex shader).
Go to the
runWebGLApp
function. Verify that we are callinginitProgram
andinitLights
there.Go to
initProgram
. Make sure you understand how the program is built and how we obtain references to attributes and uniforms.Now go to
initLights
. Update the values of the uniforms, as shown here.gl.uniform3fv(prg.uLightDirection, [0.0, 0.0, -1.0]); gl.uniform4fv(prg.uLightAmbient, [0.1,0.1,0.1,1.0]); gl.uniform4fv(prg.uLightDiffuse, [0.6,0...