home dev games gallery work
Lewpen.com»Research & Development»3D Graphics»OpenGL»Reflective Sphere

Reflective Sphere

Analytical reflections in OpenGL
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:

Files

common
Release
Debug
qe_ogl.h 915 bytes
Winmain.cpp 5,540 bytes
test.cpp 27,356 bytes
Main.cpp 4,097 bytes
Pattern.cpp 5,561 bytes
Pattern.h 931 bytes
qe_ogl.cpp 5,497 bytes
Vars.h 273 bytes
Related Articles

Procedural city block layout

Animated 4-dimensional objects mapped down to 3D

Simulating a cloth falling and slipping over objects

Windows C++ OpenGL example

Games

The Dodge Game
Flatspace

2-Player Games:

Quake 2D
Meteora

Puzzle Games:

Mini Tetris
Sudoku Solver

Development

3D Graphics:

3D Graphics Articles
WebGL Examples
OpenGL Examples
Flash 3D Engine
Java 3D Engine

Development:

Programming Articles
Game Development Examples

Work

Portfolio
Clients
Startups & Projects
Expertise

Links

CubeLogix Studios
PHP Charts & Graphs
Local Legends Football