traditional shadow mappingdisable back-face cullingUsing polygon offsetShadows 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:

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
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:
glPolygonOffset(1.0, 1.0);
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:

10 Comments to “Shadow Mapping and Back-face Culling”  

  1. 1 Igor

    Vorld is in shadovs, vere is light, shit in pants

  2. 2 wodamineralna

    I used to be very happy to find this net-site.I needed to thanks for your time for this glorious learn!! I undoubtedly having fun with every little little bit of it and I’ve you bookmarked to take a look at new stuff you weblog post. Forum Woda Mineralna

  3. 3 ilovewro

    I used to be very pleased to seek out this net-site.I needed to thanks in your time for this glorious read!! I undoubtedly having fun with every little little bit of it and I’ve you bookmarked to take a look at new stuff you blog post. I Love Wrocław


    Together with everything which seems to be building within this specific subject material, all your perspectives are actually quite refreshing. Nonetheless, I am sorry, because I can not give credence to your whole strategy, all be it stimulating none the less. It looks to me that your remarks are not totally rationalized and in fact you are your self not even totally confident of your assertion. In any event I did appreciate examining it.

  5. 5 Davidgloca

    аккаунты Telegram – Продать канал Ютуб, продать группу ВК

  6. 6 JamesAlbut
  7. 7 BennieSnups

    top article rent rdp desktop

  8. 8 AndrewHok

    поминальная трапеза бюджетное – поминальное меню стандарт, организация поминок в вао

  9. 9 cbd terpenes oil what is it

    Good Morning everyone , can anyone suggest where I can buy Green Roads CBD Topical Refresh Essential Oil Roller 50mg?

  1. 1

Leave a Reply