Skip to main content

Jet: Cascading Shadow Maps

This is a demo of my homegrown cascading shadow mapping.  Notice how the shadows remain sharp at all distances.  This is currently using 4 2048 byte shadow textures, but it looks similar with 1024 byte textures. Cascading shadow maps work by dividing the view frustum into sections, and assigning a shadow texture to each section.  This allows shadows to be rendered at great distance without loss of visual fidelity during close-up shots of a shadow.  The great thing about shadow mapping is that you get self-shadowing for free.

The performance isn't too bad either.  This demo ran at 270 frames per second on my EVGA 8800 GTS, with normal mapping and specular mapping.  Modern GPUs have really great texture lookup performance: the shader I wrote for this demo performs 7 texture lookups per pixel (1 for normal mapping, 1 for the diffuse map, 1 for specular mapping, and 4 for shadow mapping).  A previous iteration of this demo (with only 1 shadow texture lookup) ran on an Intel GMA at 35 frames per second, which isn't bad for an integrated graphics card.

The performance of this demo is fill-rate bound.  This is actually good, because it means I have plenty of vertex processing and CPU overhead to work with.  Also, most of the fill-rate-intensive shader work is done already so I don't really need anymore fill-rate.

My next couple of goals: multiple shadow-casting lights, spotlights, and point lights.


Popular posts from this blog

Lua-Style Coroutines in C++

Lua's implementation of coroutines is one of my all-time favorite features of the language. This (short) paper explains the whole reasoning behind the Lua's coroutine implementation and also a little about the history of coroutines. Sadly, coroutines are not supported out-of-the box by many modern languages, C++ included. Which brings me to the subject of this post: Lua-style coroutines in C++! For those who don't know (or were too lazy to read the paper!), Lua's coroutines support three basic operations: Create: Create a new coroutine object Resume: Run a coroutine until it yields or returns Yield: Suspend execution and return to the caller To implement these three operations, I'll use a great header file: ucontext.h. #include <vector> #include <ucontext.h> class Coroutine { public: typedef void (*Function)(void); Coroutine(Function function); void resume(); static void yield(); private: ucontext_t context_; std

Password Generator for Chrome

This week, I finally got fed up with typing in/managing passwords on a billion different sites. Since things like OpenID haven't really taken off, I decided to take matters into my own hands...and write a password generator extension for Google Chrome. There are actually a ton of such apps on the Chrome web store, but I'm paranoid about security, so I wrote my own and open-sourced it. By virtue of being open source, perhaps people will trust my version a bit more. Anyway, the extension is available here , and the source code is hosted at github . May all your online transactions be secure! UPDATE: Fixed github link.

Sparse Voxel Octrees

Terrain implementation for games is a subject with a lot of depth. At the surface, it's very easy to get rudimentary terrain working via a noise function and fixed triangle grid. As you add more features, though, the complexity builds quickly. Overhangs, caves Multiple materials Destructive terrain Collision detection Persistence Dynamic loading Regions, biomes Very large scale Smooth features Sharp features Dynamic level of detail Extremely long view distances In isolation, each of these features can make terrain difficult to implement. Taken together, it takes a lot of care and attention to make it all work. Minecraft is probably the canonical example for terrain generation in the last generation of games. In fact, I'd say Minecraft's terrain is the killer feature that makes the game so great. Minecraft does an excellent job at 1-8, but for a recent planetary renderer project I was working on, I really wanted 9-12 too. In a series of articles, I'm planning to break do