As a lab exercise:
shader_programsto draw from
skybox.f.glsl. Run it to see what happens.
environment.v.glsland open it for editing. Because we consider the cube map as a box surrounding our world, it’s easiest to compute the reflection vector using world coordinates. We will need three things:
This shader already receives the vertex’s position in model space. Add an attribute for the normal in model space, a uniform for the camera’s position in world space (which you can get from the
Camera class), and a uniform for the transformation matrix that takes us from model space to world space. We’ll use the matrix to turn our model space coordinates to world space coordinates.
OnDraw. The normal attribute has already been uploaded; it just went unused.
vec3 reflection = reflect(incident, normal_world);
skybox.f.glsl) to do your texture lookup. Run your code and walk close to an object. Do the surfaces facing you reflect what’s behind you? Do the top faces reflect the sky? What do the bottom faces reflect?