Skybox
Reflection
Mapping environment to the object. This demo uses a skybox. In OpenGL, loadCubemap() should be called to generated a texture. When rendering reflection mapping, calculate reflection direction and sample the cubemap.
Incident ray is eye to fragment, reflected ray is the reflection of incident ray base on fragment’s normal vector.
Reflection Mapping:
Refraction
Refraction is similar with Reflection. Refracted ray is calculated base on Snell’s Law. In this demo, incident ray goes from Air to Glass.
Refractive index of Water: 1.00
Refractive index of Glass: 1.52
Refraction Mapping:
One thing to be noticed, in physics, Snell’s Law should be applied again when ray leaving glass entering air. This demo applys Snell’s Law only once(entering), since it should be fine for most purposes.
Resource
https://learnopengl.com/Advanced-OpenGL/Cubemaps