Reflective Sphere
Analytical reflections in OpenGL
Flash Jan 2008
This renders non-reflective objects in a first pass, then uses reverse reflection mapping to transform objects to their reflected positions inside the sphere for a second rendering pass. There is no closed formula for working out the reverse reflection (this involves solving a quartic) so an iterative aproximation is used instead.
The floor is reflected using a different method, by raycasting reflected rays at each vertex of the sphere mesh and finding the co-ordinates of intersection with the ground plane, then using that to map the ground texture directly onto the sphere.


Here is a short clip of the code in action:
Source 19 files
- source/Main.cpp C++ · 204 lines
- source/Pattern.cpp C++ · 268 lines
- source/Pattern.h C header · 33 lines
- source/qe_ogl.cpp C++ · 245 lines
- source/qe_ogl.h C header · 55 lines
- source/test.cpp C++ · 1437 lines
- source/Vars.h C header · 16 lines
- source/Winmain.cpp C++ · 286 lines
- source/WINMAIN.H C header · 10 lines
- source/common/001/cylinder.cpp C++ · 180 lines
- source/common/001/cylinder.h C header · 90 lines
- source/common/001/interpolate.cpp C++ · 36 lines
- source/common/001/interpolate.h C header · 41 lines
- source/common/001/radialobject.cpp C++ · 429 lines
- source/common/001/radialobject.h C header · 90 lines
- source/common/001/stack.cpp C++ · 84 lines
- source/common/001/stack.h C header · 41 lines
- source/common/001/vector.cpp C++ · 107 lines
- source/common/001/vector.h C header · 38 lines