Getting ready

Set up your OpenGL program to provide the vertex position in attribute location 0 and the vertex normal in attribute location 1. As with the previous recipe, we'll need to provide the model matrix in the uniform variable ModelMatrix.

Load the cube map using the technique shown in the previous recipe. Place it in texture unit zero.

Set the uniform variable WorldCameraPosition to the location of your viewer in world coordinates. Set the value of the uniform variable Material.Eta to the ratio between the index of refraction of the environment n1 and the index of refraction of the material n2 (n1/n2). Set the value of the uniform Material.ReflectionFactor to the fraction of light that is reflected at the interface (a small value is probably what you want).

As with the preceding example, if you want to draw the environment, draw a large cube surrounding the scene and use a separate shader to apply the texture to the cube. See the example code for details.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
18.118.2.15