![]()
![]()
Shadows and Shadow Mapping
Shadows has remained as a big challenge for years in computer graphics. There are many ways to achieve “shadows”, some methods require special data structures and coding, and some has quality and speed falloffs.
Shadow mapping is one of methods been used by now, presenting relatively easy implementation and reasonable speed, at cost of aliasing effect for shadows far from the camera, a shadow texture to hold information for each point light (more for soft shadows) and big sized shadow map texture memory space requirement.
For more information:
http://en.wikipedia.org/wiki/Shadow_mapping
http://www.paulsprojects.net/tutorials/smt/smt.html
Back-face Culling
Back-face culling is the process of discarding polygons that are not facing towards the camera where the image is taken from. So often used in 3D video games, the process allows rendering of scene much faster by eliminating the calculation of back-facing polygons-those eventually will be covered by another front-facing polygons. To get a better understanding, one can imagine a box, having all the 6 faces facing outer from the cube, that means the top face will orient towards above the cube, and bottom face will orient below. So, any camera that is in the outer space of the cube will see the all 6 faces, but a camera in the cube will not see any.
Back-face Culling and Shadow Maps
In general purpose 3D drawing software and CAD applications, it is often impossible to determine the correct orientation of faces. Any single face in 3D space may be clock-wise or counter clock-wise, constructing a outer face of an entity or should be just a plane with both sides visible, depending on the whole drawing. So, all faces in CAD applications are simply rendered without back-face culling, remaining both sides visible.
On the other hand, shadowing with shadow map method requires back-face culling turned on, makes it impossible to use with CAD applications. After searching everywhere to find a way to make shadow mapping work while back-face culling is off, I haven’t came to any solution. Then I have decided to play a bit and finally made it! So here it is.
The Sample
I will be using a very good, yet simple to understand sample project, developed by Paul Baker. You can find his tutorial at http://www.paulsprojects.net/tutorials/smt/smt.html.
Load the project into Microsoft Visual Studio and run. Then open the file main.cpp and locate glEnable(GL_CULL_FACE); in function bool Init(void) on line 70 and replace it with glEnable(GL_CULL_FACE); and run again. When back-face culling disabled, you will see there is disturbing Z-fight effect, due to multi pass rendering required for shadow maps (Three passes actually, in this example).
The fix
This time, comment out glEnable(GL_CULL_FACE); and after that, insert:
glDisable(GL_CULL_FACE);
glPolygonOffset(1.0, 1.0);
glEnable(GL_POLYGON_OFFSET_FILL);
Shadows should be rendering correct again.
Polygon Offset
Polygon offset is useful when you face coplanar faces, ie: faces on the same exact location and depth to the camera. If such coplanar faces are fed to OpenGL pipeline for drawing, you will see the disturbing z-fight effect, random colors from both faces, as in the image at the top line of this post. The reason of the z-fight effect in the previous example is that the lit and dark areas both are the same distance to the camera, having the same depth values causing the trouble. Polygon offset comes for help:
Polygon offset does not only correct z-fight effects but can also be used for highlighting the edges of a solid object and create some other effects. For more information on polygon offset, refer to: http://www.opengl.org/resources/faq/technical/polygonoffset.htm
SIGGRAPH, international conference on computer graphics and interactive technologies was held on 31 July-4August in Los Angeles Convention Center. That was really a great experience for me to face cutting-edge technologies and latest improvements all in one place. The conference was too dense and it was impossible to miss some precious seminers, that were simultaneously presented. http://www.siggraph.org/s2005/
I had the opportunity to present the components we have developed for IntelliCAD, a general purpose 3D drawing application, in IntelliCAD WorldMeeting 2005 - the Netherlands to professional CAD developers from all around the world. The components were picking entities by ray tracing, the raster module, the photo-realistic rendering module, CNC and some other components. The impression was great and thanks to all attenders for listening and interest. www.intellicad.org
This small graphical application will solve you the Tower of Hanoi problem for 31 pieces max, recursively, and at desired speed.
Hanoi Towers-Win32 application (page)
Hanoi Towers-Win32 application (direct link to file)
Hanoi Towers-source
Fonts Viewer: View and print multiple fonts at a glance
0 Comments Published May 7th, 2007 in DevelopmentVery simple utility to view a text in various fonts at a glance, printing also supported, with source code.
.
.
Blogs will go here, soon.
Credits goes to Halit YEŞİL from globya.net, for kindly supporting this web site. You rock!
Search Blog |
Categories
|
|||


