To Do

  1. Download the Vizard resources that accompany the Vizard Teacher in a Book (unless you have already done so).

  2. Follow the lighting tutorial and complete the lighting exercises at the end of the chapter (unless you have already done so). Demo your code to your TA or your instructor when finished.

  3. Follow the texture tutorial and complete the texture exercises at the end of the chapter. Demo your code to your TA or your instructor when finished.

  4. You can write your own shaders in Vizard. Try out the examples in this shader tutorial.

    Important note: Recall that our fragment shaders (written in GLSL 1.50) used user-defined variables for texture coordinates. The fragment code from the Vizard tutorial uses the built-in variables gl_TexCoord and gl_FragColor, which were deprecated after GLSL 1.20 and removed in GLSL 1.40. Vizard creates a compatibility context that makes these deprecated variables available to your shaders. You may use them in your project to add shader effects similar to the ones we created in the third week of classes.

    Here is a Vizard code snippet that uses a fragment shader that flips the texture image upside down:

    olaf = viz.addTexture('olaf256.jpg')
    quad = viz.addTexQuad()
    quad.setPosition([-1,2,3]) # place quad in view
    quad.texture(olaf)         # by default attached to texture unit 0, equivalent to quad.texture(olaf,'',0)
    fragCode = """
    uniform sampler2D tex;
    void main()
        gl_FragColor = texture(tex, vec2(gl_TexCoord[0].s, 1-gl_TexCoord[0].t));
    shader = viz.addShader(frag=fragCode)
    texunit = viz.addUniformInt('tex', 0) # create an integer shader uniform and initialize it with 0
    shader.attach(texunit)                # pass the index of the texture unit to the fragment shader
    quad.apply(shader)                    # apply the fragment shader to the quad