(Page under development. Please email corrections or suggestion for this page to the author.)
NoPerspective shows the effect of using smooth (hyperbolic) interpolation
versus using non-perspective interpolation. This shows rather dramatically the
benefits of using hyperbolic interpolation.
This is
part of a set of programs introducing the
use of Modern OpenGL, which are
intended to accompany a possible second edition
of the book 3D Computer Graphics: A mathematical
approach with OpenGL, Cambridge University Press, 2003.
The book describes the mathematics of hyperbolic interpolation.
For an early, succinct discussion of hyperbolic interpolation, see the
article Hyperbolic Interpolation, in Jim Blinn's Corner published in
1992.
|
|
Non-hyperbolic interpolation |
Hyperbolic interpolation |
NoPerspective has one main source file,
NoPerspective.cpp, plus shader programs
in the source file NoPerspective.glsl.
It uses the GlShaderMgr C++ package for
for compiling and linking shaders and GlLinearMath
software for handling the modelview and projection matrices.
Available for download:
- NoPerspective.zip: A zip file with
the primary source file NoPerspective.cpp,
the GLSL shader source file NoPerspective.glsl>,
and a Windows executable.
- Compiling the source code also requires the GlShaderMgr software
and GlLinearMath routines:
- The GlShaderMgr software compiles and links
shader programs.
You need the two C++ files GlShaderMgr.[cpp,.h].
- The GlLinearMath software supplies
classes for vectors, and miscellaneous mathematics routines.
You need the five files LinearR3.[cpp,h],
LinearR4.[cpp,h], and MathMisc.h.
- Documentation on the
new features in NoPerspective, not covered in
earlier programs in this collection.
Things to try out:
- Compile and run the program. Or run the executable.
You will see a flat plane that is textured with a regular
square pattern of black and white checkerboard squares. However,
it is rendered in
noperspective
mode, that is, without
hyperbolic interpolation, and looks very distorted.
-
Use the space bar, or 'P' or 'p' (perspective) toggle
using perspective (hyperbolic) interpolation, and non-perspective
interpolation. Note that the checkerboard is not rendered distorted
when using hyperbolic interpolation.
-
Examine the source code to see how polygon offset is used
to render the outlines of the two triangles that form the square without
having a z-fighting. Try turning off the polygon offset and seeing how
it affects the outlining of the two triangles.
-
Read the code documentation
for more information.,
Version 0.1 of NoPerspective, February 28, 2020. Copyrights reserved.