(May 2005)

This is the OpenGL version of my 3D renderer.

Rendered statue

In essence, it is a straightforward implementation of the core principles of "polygon related" graphics theory. The source code includes:

The code is available under the GNU license. It is using the autotools, so it compiles and runs cleanly under most platforms (tested so far on Linux/x86, Mac OS/X, Windows (using MinGW gcc), OpenBSD/amd64 and FreeBSD/amd64).

Unlike the corresponding pure-software implementation, these sources use OpenGL to do the rendering. In fact, they use fragment shaders and Vertex Buffer Objects (VBO) to perform all the graphics calculations in hardware (if supported by your card). A 70$ graphics card (an ATI 4670) provides around 100 million phong shaded triangles per second with this renderer.

Download, compile and run

The Source code is available under the GPL. Win32 binaries are also available (compiled with MinGW).

Compilation follows the well known procedure...

  bash$ ./configure
  bash$ make
After a successful make, you can then watch the packaged 3D objects:
  bash$ cd 3D-objects
  bash$ ../src/renderer/renderer statue.ply
  
To navigate... statue.ply is just one of the available objects. Have a look at the others as well.

Creating more 3D objects on your own

  1. Use MeshLab to convert your 3D object to .PLY.
  2. Load it up in shadevis and hit ENTER to have shadevis calculate the ambient occlusion factors per vertex. After that, hit 'D' as many times as necessary to lower the diffuse light to 0%, and hit 'a' to pump up the ambient to 100%. Hit 'S' to save the object.
  3. Load the saved '..._vis.ply' with my renderer.
You can also use the 3D objects from the pure-software implementation's package.

Phong shading

Notice that the Phong shading mode is real phong shading, done through the vertex and fragment shaders. The vertexes' normal vectors are interpolated per-pixel, and the complete lighting equation is then evaluated. To improve the areas not touched by the light source (the ambient ones), the shaders also interpolate the per-vertex ambient occlusion factor that shadevis generates, thus creating radiosity-look-alike renderings.

Since my renderer uses shaders and vertex buffer objects, rendering speed is amazing: my Radeon 4670 draws a huge object I have (1.6 million triangles) at 86 frames per second, for an unbelievable 134 million phong-shaded triangles per second!

And just look at the difference between gouraud and phong shading...

Gouraud shaded image Phong shaded image

Phong shading creates much better pictures than Gouraud; especially at low tessellations.
Notice how the fragment shader creates Phong higlights, and also how it
interpolates the vertex ambient occlusion factor per-pixel.

Enjoy!

profile for ttsiodras at Stack Overflow, Q&A for professional and enthusiast programmers
GitHub member ttsiodras
 
Index
 
 
CV
 
 
Updated: Sat Oct 8 12:33:59 2022