Stencil shadows in Ogre and Blender model exportation

If you are gonna use stencil shadows in Ogre, you should carefully read the manual page about this shadowing technique, and be sure to fully understand what is explained there. Besides, you can find some useful hints and tips regarding this topic that I have discovered while adding shadows to my scenes.

  1. Any object (mesh) casting shadows must contain an edge list, which can be generated either when exporting the mesh in Blender (or any other modelling tool) or calling Mesh::buildEdgeList before the mesh is used in run-time. If you are using Blender, make sure that the option Edge Lists is enabled when exporting your model (like I explained in a previous post).

    Edge Lists option when exporting.

    Edge Lists option when exporting.

  2. Current Ogre release (v1.8.1) has a bug when computing stencil shadows if a light source is placed inside an object. Read this thread. Solutions: a) do not place a light source inside an object (with edge list), b) apply the patch posted in the previous thread to your Ogre sources (this patch will be included in the next maintenance release), c) consider switching to the texture shadows technique.
  3. Stencil shadows project the object geometry. The shadow caster class (OgreShadowCaster) has a 16-bit index limit on the number of vertexes. This limit will only be shown to the user in debug mode with an assert. In release mode, this limit will not trigger anything, but shadows will not work properly. In addition, the performance may be seriously penalized, if big meshes are used with this technique due to the geometry projection. Therefore, if shadows do not work properly, make sure none of your meshes exceeds the 16-bit limit executing in debug mode. If this requirement is not meet, you can split the mesh in different pieces (that will help Ogre to cull non visible parts), or reduce the number of vertexes.

Compiling Ogre v1.8.1 under Windows 7 with Visual Studio

Today I am struggling with the compilation of Ogre under Windows 7 x86-64 with SP1 with Visual Studio 2010 SP1. The easiest way of generating the solution files is using CMake and these instructions. However, there are some complementary details that you can find in the following steps, which I have followed to build this amazing 3D graphic engine.

  1. Install Boost. Under Windows it is advisable to use precompiled binaries that can be found at BoostPro. I used version 1.51 and I installed the chrono, date-time, threads and system libraries.
  2. Install DirectX SDK in order to build the renderer for this API. This will allow the user to choose between OpenGL and DirectX.The newest version is June 2010.
  3. Download Ogre and Ogre Dependencies from the download page.
  4. Generate the solution file with CMake for the dependencies.
  5. Build and install the dependencies.
  6. Add the following environment variables: BOOST_ROOT, DXSDK_HOME, and OGRE_DEPENDENCIES_DIR with their values set to the respective installation directory. Note that there is a DXSDK_DIR variable, but I create my own variables for every library as XXXX_HOME. However, Boost and Ogre dependencies variable names are imposed, and their names can not be changed or the Ogre CMake files will not “configure” properly.
  7. Generate the solution file for Ogre with CMake, and build the solution with Visual Studio.