• Home
  • Textbooks
  • Computer Graphics with Open GL
  • Programmable Shaders

Computer Graphics with Open GL

Donald Hearn. M. Pauline. Baker, Warren R.Carithers

Chapter 20

Programmable Shaders - all with Video Answers

Educators


Chapter Questions

00:34

Problem 1

Determine whether or not your OpenGL installation supports GLSL. If it does, determine the version of GLSL it supports.

Hast Aggarwal
Hast Aggarwal
Numerade Educator
01:25

Problem 2

Write a function which takes two null-terminated strings as its parameters and returns the GLuint identifier for a shader program object. The parameters contain the names of vertex and fragment shader source files.

Jennifer Stoner
Jennifer Stoner
Numerade Educator
02:47

Problem 3

Write a program using the functions in the previous exercise to draw a square in the center of the display window and use the vertex shader program to color the square red.

MS
Malcom Smith
Numerade Educator
04:06

Problem 4

The example Phong shader performs its color calculations at each vertex. Convert it into a shader that does the color calculations in the fragment shader. Remember that some critical values must be computed in the vertex shader.

Gideon Idumah
Gideon Idumah
Numerade Educator
02:39

Problem 5

Write a program to display an origin-centered tetrahedron on a black background using the shader you wrote in the previous exercise to shade the object. Add the ability to rotate the object around the $y$-axis using keyboard input.

Muhammad Saleem
Muhammad Saleem
Numerade Educator
01:20

Problem 6

Modify the example Phong shader to use a light source specified through a global shader variable rather than just using light source 0 .

Khoobchandra Agrawal
Khoobchandra Agrawal
Numerade Educator
05:42

Problem 7

Modify the example Phong shader to work with multiple light sources. Use a global shader variable to tell the shader how many light sources are active.

Vipender Rao
Vipender Rao
Numerade Educator
02:20

Problem 8

Modify the program in Exercise 5 to add two more light sources to the scene. Use the shader you developed in the previous exercise to shade the object in the scene. The positions and orientations of the light sources should be taken as input parameters to the program.

Prabhu Ramji
Prabhu Ramji
Numerade Educator
00:48

Problem 9

Modify the simple texture mapping shader so that it performs Phong calculations using color information from the texture image instead of the material properties of the object being shaded.

Ashley High
Ashley High
Numerade Educator
06:07

Problem 10

Write program to display an origin-centered cube on a black background using the shader you wrote in the previous exercise to shade the object with a textured image on each of the faces of the cube.
Provide the ability to rotate the cube about the $y$ and z axes using keyboard input.

Zachary Warner
Zachary Warner
Numerade Educator
03:01

Problem 11

Modify the program and shader used in the previous exercise to add two more light sources to the scene and have the shader texture the object using lighting information from all three lights. The positions and orientations of the light sources should be taken as input parameters to the program.

Satpal Satpal
Satpal Satpal
Numerade Educator