In this update, I'll briefly talk about two of the major new features I've added to Quake2World.
Recently, having spent a handful of hours several weeks ago playing AprQ2, I was tempted to add stencil shadows to the Quake2World renderer. Stencil shadows are the result of re-drawing an object using a transform matrix to project the object onto a "floor," and using GL_STENCIL_TEST
so that the object appears as a silhouette. I was able to do this without incurring much of a performance penalty because I reuse the populated and bound vertex arrays used to draw the primary instance of the object. You can see an example of stencil shadows here:
You'll also notice that the shadow is translated away from the strongest light source on the character model. That brings us to the next topic: BSP light sources. I was never pleased with the "lightmap tracing" and flat shading that Quake II used to light mesh models, and had made several attempts to extract more meaningful lighting information from the level files which environment artists provide. Unfortunately, this information is geared towards the needs of the BSP compiler, and was prohibitively large and complex to process efficiently in-game.
Enter: a caching strategy. What my code now does is cache the results of a static lighting lookup for each entity. My algorithm identifies as many as 8 contributing light sources for the mesh model in question, and stores references to these light sources in client memory. Thus, the only time lighting is [re-]calculated for an entity is when it is being rendered for the first time, or when it moves.
With references to the strongest static light sources for each entity at hand, I'm able to populate GL_LIGHTn
with the color and intensity of point and surface lights specified by the level designer. The end result is a natural looking, directionally correct, multi-source light application for every mesh model appearing within the scene.
You can see some more screenshots of this on our Flickr Photostream.
Questions? Hit us up on IRC; #quetoo on irc.Freenode.net.