DirectX Stencil Shadows, Filtering & Scene Switching
Stencils appear to be quite a tricky thing to get working well in DirectX. They’re extremely handy, but they’re not one of the easiest things. Fortunately I was able to implement a pre-existing shadow example that showed a teapot shadowed on a white plane and implemented it into my own engine.
You can immediately see the FPS isn’t at a very pretty value. This is for good reason however. I may not be using any optimization techniques such as portals yet, but my code is structured quite well. It just so happens that the model that is being shown has around 300,000 polys. Still no biggy. Except, instead of having a simplified mesh for the shadow, I’m rendering all 300,000 polygons for the shadow as well which takes a lot more calculations. Without the shadow I receive around 160FPS. Without the terrain I get a more decent 600FPS, and without the model around 3000FPS. This is all still with 16xAF and 8xAA filtering enabled.
The DirectX demonstration has all the necessary features so far, and although you can’t see this in the screenshot I’ve been working on making the memory management efficient as well as adding a scene manager that now allows me to very quickly swap between different ‘scenes’. These scenes basically consist of two arrays, one for drawn objects and one for the lights. Text can also be individually added per scene and the key buffer is directly linked to both objects as well as the scene so user input can be efficiently managed.
With everything I need written in code, for both rendering and math demonstrations, I just need to write the actual separate showcase items with the base code that I’ve written so far.